> On Mar 13, 2024, at 8:39 AM, Jeremy Adler <[email protected]> wrote:
>
> Hi,
> 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.
The getPixel(x,y) function returns zero for locations outside the image, and
this can’t be changed without breaking existing code, but you can use
getValue(x,y), which returns NaN.
-wayne
> Is there a reason for getPixel returning zeros rather than a NaN or simply
> crashing?
>
> The code below demos the issue
>
> // testing getPixel
> print("\\Clear");
> selectWindow("Log");
> newImage("RAMP", "8-bit ramp", 256, 20, 1);
> wdth=getWidth();
> for (xpos=wdth-5; xpos < wdth+5; xpos++) {
> print("xpos",xpos,"getPixel",getPixel(xpos,10));
> run("Specify...", "width=1 height=3 x=xpos y=10");
> getRawStatistics(nPixels, mean, min, max, std, histogram);
> print(" mean from ROI ",mean);
> }
>
> Jeremy
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html