Login  Register

Re: setThreshold NaN value

Posted by Volker Baecker on Aug 30, 2007; 1:24pm
URL: http://imagej.273.s1.nabble.com/setThreshold-NaN-value-tp3698503p3698506.html

Hi,
the following works fine for me:

ImagePlus imp = NewImage.createFloatImage("test", 300, 200, 1,
NewImage.FILL_BLACK);
imp.getProcessor().setThreshold(1d, 500.0d, ImageProcessor.RED_LUT);
WindowManager.setTempCurrentImage(imp);
IJ.run("NaN Background");
System.out.println(imp.getProcessor().getf(0, 0));

You have to use a method with a float result like getf or getPixelValue,
since if the return type is int the NaN will automatically be converted
into 0 of type int.

Volker

erwan bocher a écrit :

> Hi,
>
> Thank you but it doesn't work.
>
> I obtain the value 0 for the pixel. If I use imp.show() the pixel value is
> NaN.
>
> R1.
>
> 2007/8/30, Volker Bäcker <[hidden email]>:
>> Try WindowManager.setTempCurrentImage(imp) instead of imp.show();
>>
>> Volker
>>
>> erwan bocher a écrit :
>>> Dear all,
>>>
>>> I try to set a NaN value to my image.
>>>
>>> I use this
>>>
>>> ip.setThreshold(0.0d, 500.0d, ImageProcessor.RED_LUT);
>>>
>>>  ImagePlus imp = new ImagePlus("",ip);
>>> imp.show();
>>>  IJ.run("NaN Background");
>>>
>>> It works fine but I don't want to show the imagePlus.
>>>
>>> Is it another way to do this ?
>>>
>>> Thanks
>>>
>>> R1.
>>>
>>> Ps :  I use this code in a java application.
>>>
>> --
>> passerelle antivirus du campus CNRS de Montpellier
>> --
>>
>
>
>

--
passerelle antivirus du campus CNRS de Montpellier
--