Dear ImageJ users,
In versions 1.44p and earlier, I could set zero values as NaN (not a number) with the following macro: if(v==0)v=NaN; In version 1.50d this does not work (no change to the image), but it also doesn't give an error message. This problem happens for all image types I've tested (8-bit, 32-bit, RGB) and in both Fiji and plain ImageJ. Has the syntax for defining NaN changed at some point between version 1.44p and 1.50d? Does any one know of an alternative method to set pixels than meet a certain criteria as NaN? Kind regards James |
The change in NaN behavior occurs between ImageJ version 1.50a and 1.50d (I haven't yet tried the intermediate versions to find out exactly where) and also with java versions 1.6, 1.7 and OpenJDK8. If I create an 8-bit image with a block of 255 and a value of 1 everywhere else, then run the macro if(v==1)v=NaN, the 255 remains unchanged whilst the 1 is set to 0, not NaN. Would anyone by able to test if they get the same behaviour with their setup? Cheers James |
james_minto wrote
> > In versions 1.44p and earlier, I could set zero values as NaN (not a > > number) with the following macro: > > > > if(v==0)v=NaN; Are you sure that 8-bit images support NAN? Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by james_minto
> On Nov 6, 2015, at 4:40 AM, james_minto <[hidden email]> wrote:
> > james_minto wrote >> In versions 1.44p and earlier, I could set zero values as NaN (not a >> number) with the following macro: >> >> if(v==0)v=NaN; >> >> In version 1.50d this does not work (no change to the image), but it also >> doesn't give an error message. This problem happens for all image types >> I've tested (8-bit, 32-bit, RGB) and in both Fiji and plain ImageJ. >> >> Has the syntax for defining NaN changed at some point between version >> 1.44p and 1.50d? >> >> Does any one know of an alternative method to set pixels than meet a >> certain criteria as NaN? This test macro v = 0; if (v==0) v=NaN; print(v); outputs “NaN” on my Mac with both Java 1.6.0_65 and Java 1.8.0_60. 32-bit (float) images are the only image type that support NaN pixel values. Pixels in 8-bit images can only have integer values in the range 0 to 255. -wayne > > The change in NaN behavior occurs between ImageJ version 1.50a and 1.50d (I > haven't yet tried the intermediate versions to find out exactly where) and > also with java versions 1.6, 1.7 and OpenJDK8. > > If I create an 8-bit image with a block of 255 and a value of 1 everywhere > else, then run the macro if(v==1)v=NaN, the 255 remains unchanged whilst the > 1 is set to 0, not NaN. > > Would anyone by able to test if they get the same behaviour with their > setup? > > Cheers > > James > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Setting-values-to-NaN-with-a-macro-tp5014841p5014873.html > Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi all,
On my system [1], the following macro reproduces the issue: newImage("Untitled", "8-bit black", 400, 400, 1); run("32-bit"); makeRectangle(83, 88, 235, 228); setForegroundColor(50, 50, 50); run("Draw"); run("Macro...", "code=[if (v==0) v=NaN]"); print("(1, 1) = " + getPixel(1, 1)); It outputs the line: (1, 1) = 0 But I would expect it to read: (1, 1) = NaN Regards, Curtis [1] ImageJ 2.0.0-rc-41/1.50d; Java 1.8.0_45 [64-bit]) On Fri, Nov 6, 2015 at 9:40 AM, Rasband, Wayne (NIH/NIMH) [E] < [hidden email]> wrote: > > On Nov 6, 2015, at 4:40 AM, james_minto <[hidden email]> wrote: > > > > james_minto wrote > >> In versions 1.44p and earlier, I could set zero values as NaN (not a > >> number) with the following macro: > >> > >> if(v==0)v=NaN; > >> > >> In version 1.50d this does not work (no change to the image), but it > also > >> doesn't give an error message. This problem happens for all image types > >> I've tested (8-bit, 32-bit, RGB) and in both Fiji and plain ImageJ. > >> > >> Has the syntax for defining NaN changed at some point between version > >> 1.44p and 1.50d? > >> > >> Does any one know of an alternative method to set pixels than meet a > >> certain criteria as NaN? > > This test macro > > v = 0; > if (v==0) > v=NaN; > print(v); > > outputs “NaN” on my Mac with both Java 1.6.0_65 and Java 1.8.0_60. 32-bit > (float) images are the only image type that support NaN pixel values. > Pixels in 8-bit images can only have integer values in the range 0 to 255. > > -wayne > > > > > The change in NaN behavior occurs between ImageJ version 1.50a and 1.50d > (I > > haven't yet tried the intermediate versions to find out exactly where) > and > > also with java versions 1.6, 1.7 and OpenJDK8. > > > > If I create an 8-bit image with a block of 255 and a value of 1 > everywhere > > else, then run the macro if(v==1)v=NaN, the 255 remains unchanged whilst > the > > 1 is set to 0, not NaN. > > > > Would anyone by able to test if they get the same behaviour with their > > setup? > > > > Cheers > > > > James > > > > -- > > View this message in context: > http://imagej.1557.x6.nabble.com/Setting-values-to-NaN-with-a-macro-tp5014841p5014873.html > > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by james_minto
>> On Nov 6, 2015, at 4:40 AM, james_minto <[hidden email]> wrote:
>> >> james_minto wrote >>> In versions 1.44p and earlier, I could set zero values as NaN (not a >>> number) with the following macro: >>> >>> if(v==0)v=NaN; >>> >>> In version 1.50d this does not work (no change to the image), but it also >>> doesn't give an error message. This problem happens for all image types >>> I've tested (8-bit, 32-bit, RGB) and in both Fiji and plain ImageJ. >>> >>> Has the syntax for defining NaN changed at some point between version >>> 1.44p and 1.50d? >>> >>> Does any one know of an alternative method to set pixels than meet a >>> certain criteria as NaN? This regression is fixed in the latest ImageJ daily build (1.50e13). Here is a test macro that reproduces the problem. newImage("Untitled", "32-bit black", 400, 400, 1); run("Macro...", "code=[if (v==0) v=NaN]"); print("(0, 0) = " + getPixel(0, 0)); On ImageJ 1.50e13, it outputs (0, 0) = NaN On ImageJ 1.50d it outputs (0, 0) = 0 -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by james_minto
On 11/06/2015 10:40 AM, james_minto wrote:
>> In versions 1.44p and earlier, I could set zero values as NaN (not a >> number) with the following macro: >> >> if(v==0)v=NaN; > > The change in NaN behavior occurs between ImageJ version 1.50a and 1.50d (I > haven't yet tried the intermediate versions to find out exactly where) and > also with java versions 1.6, 1.7 and OpenJDK8. I can reduce the regression interval by one step: 1.50b could also set pixels of 32bit images to NaN, but now that I upgraded to 1.50d I also observe the bug. Note that a similar change holds for infinity: 1.50d 1.50b and 1.49v (at least) v=0.0/0.0 0 NaN v=1.0/0.0 2^31-1 Infinity v=-1.0/0.0 -2^31 -Infinity It looks as if there was an integer conversion somewhere in the process, that would map Float.POSITIVE_INFINITY to Integer.MAX_VALUE and so forth. Adrian -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |