Greetings,

Both of these results are what I would expect, as per:
https://wsr.imagej.net/developer/macro/functions.html#G

getPixel is a low level routine, "Returns the raw value of the pixel at
(x, y)"
NaN is not a valid numeric representation in 8-bit integers. If the pixel
values were 32-bit, i.e., float, then NaN is a valid value perfectly
suited for this purpose. It is the caller's responsibility to determine if
the location is valid and thus how to use the value.

getRawStatistics is a higher level routine that needs to deal with the
requested collection of values, and the validity thereof.

Enjoy,

Fred

On Wed, March 13, 2024 8:07 am, Gabriel Landini wrote:
> On 13/03/2024 12:30, Jeremy Adler wrote:
>> When getPixel(x,y) is asked to read a location that is outside the
>> selected image it returns the value 0.
>> While a selection that is outside the image returns NaN - flagging the
>> mistake.
>>
>> Is there a reason for getPixel returning zeros rather than a NaN or
>> simply crashing?
>
> Hi, I do not have an answer, but I believe a lot of code already written
> assumes zero outside the image.
> If that is to be changed to NAN, I would welcome that to be an option
> and not the only behaviour so no code is broken.
>
> Regards
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Reply via email to