Hi group,
I'm trying to auto threshold an 8-bit image using the code below. However, this creates a NullPointerException and I don't understand why. IJ.setAutoThreshold(imp, "Mean dark"); IJ.run(imp, "Convert to Mask", ""); -Colin |
Hi,
On Aug 8, 2011, at 1:26 PM, ColinWhite wrote: > Hi group, > > I'm trying to auto threshold an 8-bit image using the code below. However, > this creates a NullPointerException and I don't understand why. > > IJ.setAutoThreshold(imp, "Mean dark"); > IJ.run(imp, "Convert to Mask", ""); > I don't have any issues with the following java script on ImageJ 1.45l or the daily build (1.45m). imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif"); imp.show(); IJ.log("imp is null? " + (imp == null)); IJ.setAutoThreshold(imp, "Mean dark"); IJ.run(imp, "Convert to Mask", ""); It seems that your image processor, imp, might not be what you are expecting it to be. You'll want to verify that the creation of your instance of the imp is successful, somewhere upstream of your commands. Cheers, Ben |
Hi,
Thanks for your response. The imp variable is actually an ImagePlus; should that argument be an ImageProcessor? Either way, I'm almost sure the creation of my instance of the imp is successful because if I replace IJ.setAutoThreshold(imp, "Mean dark"); with IJ.setThreshold(40.0, 255.0); then my program works fine. I would prefer if the former bit of code worked, however. -Colin ________________________________ From: Ben Tupper <[hidden email]> To: [hidden email] Sent: Monday, August 8, 2011 2:48 PM Subject: Re: IJ.setAutoThreshold(...); Hi, On Aug 8, 2011, at 1:26 PM, ColinWhite wrote: > Hi group, > > I'm trying to auto threshold an 8-bit image using the code below. However, > this creates a NullPointerException and I don't understand why. > > IJ.setAutoThreshold(imp, "Mean dark"); > IJ.run(imp, "Convert to Mask", ""); > I don't have any issues with the following java script on ImageJ 1.45l or the daily build (1.45m). imp = IJ.openImage("http://imagej.nih.gov/ij/images/blobs.gif"); imp.show(); IJ.log("imp is null? " + (imp == null)); IJ.setAutoThreshold(imp, "Mean dark"); IJ.run(imp, "Convert to Mask", ""); It seems that your image processor, imp, might not be what you are expecting it to be. You'll want to verify that the creation of your instance of the imp is successful, somewhere upstream of your commands. Cheers, Ben |
In reply to this post by BenTupper
Hello All,
I have an image stack with Overlays that correspond to individual slices. Each Overlay contains some text ROIs. I would like for my plug-in to flatten each individual Overlay onto its corresponding slice ONLY (not the whole stack!) and then save the image stack. I like the result of the Overlay -> Flatten command, however I don't think that outputting each individual flattened image and then merging them all into a stack is a clean solution. So, I was wondering if someone could give me some code to draw an Overlay onto a single slice in a stack. Thanks in Advance, Alex |
On Aug 8, 2011, at 5:07 PM, Watson, David (NIH/NIEHS) [F] wrote:
> Hello All, > > I have an image stack with Overlays that correspond to individual slices. Each Overlay contains some text ROIs. I would like for my plug-in to flatten each individual Overlay onto its corresponding slice ONLY (not the whole stack!) and then save the image stack. I like the result of the Overlay -> Flatten command, however I don't think that outputting each individual flattened image and then merging them all into a stack is a clean solution. So, I was wondering if someone could give me some code to draw an Overlay onto a single slice in a stack. The ImageProcessor.drawOverlay(Overlay) method will draw an overlay on a single slice of an 8-bit or RGB stack. This method is available in ImageJ 1.45i or later. -wayne |
Free forum by Nabble | Edit this page |