Login  Register

Re: IJ.setAutoThreshold(...);

Posted by ColinWhite on Aug 08, 2011; 7:36pm
URL: http://imagej.273.s1.nabble.com/IJ-setAutoThreshold-tp3683573p3683577.html

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