understanding selection coordinates

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

understanding selection coordinates

Neil Fazel
I have sampled the pixels on a 32-bit grayscale image (attached) using a selection and a macro call to getSelectionCoordinates(). (The selection itself was created using the Contour Plotter plugin for a contour with grayscale value of 157 on another image of same size.)

I am now inspecting the values of the pixels crossed by the selection. In the array returned by getSelectionCoordinates(), some pixels show up twice. How is that possible? Isn't a selection supposed to cross each pixel only once?

I have also magnified the image so I can see the individual pixels and the selection that goes through them. (An image for this is attached.) How do the values returned by getSelectionCoordinates() relate to the points on the selection, i.e. when I see a little white dot on the selection (see attached image), how do I know which pixel it refers to?

Thanks,
Neil

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

visual inspection of selected pixels.tiff (111K) Download Attachment
recovered reference intensity - 5671 - with contour 157.tiff (228K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: understanding selection coordinates

Michael Schmid
Hi Neil,

if you find double entries in getSelectionCoordinates(), this is probably caused by the ContourPlotter plugin.

If this is a problem and you are just interested in the outline, you can also threshold the image and run Edit>Selection>Create Selection or (if there can be several outlines) use the Wand tool to create a roi. These should not cause double entries in getSelectionCoordinates(), but they only create rois consisting of horizontal and vertical lines (the ContourPlotter also does diagonal lines across pixels).

At high magnification, the roi outline is shown *between* the pixels (if you do a contour, the line is between a pixel above and one below the threshold).

The convention in ImageJ is such that the pixel at coordinates (0,0) is encompassed by the contour with the (x,y) values of (0,0), (1,0), (1,1), (0,1).
Thus, getPixel(x,y) for (x,y) values along a contour will return the values of the pixels to the lower right of the contour.

If you want to know the interpolated pixel value at a vertex (x,y) of the contour, use
  getPixel(x-0.5, y-0.5);


Michael
________________________________________________________________
On Feb 16, 2014, at 02:10, Neil Fazel wrote:

> I have sampled the pixels on a 32-bit grayscale image (attached) using a selection and a macro call to getSelectionCoordinates(). (The selection itself was created using the Contour Plotter plugin for a contour with grayscale value of 157 on another image of same size.)
>
> I am now inspecting the values of the pixels crossed by the selection. In the array returned by getSelectionCoordinates(), some pixels show up twice. How is that possible? Isn't a selection supposed to cross each pixel only once?
>
> I have also magnified the image so I can see the individual pixels and the selection that goes through them. (An image for this is attached.) How do the values returned by getSelectionCoordinates() relate to the points on the selection, i.e. when I see a little white dot on the selection (see attached image), how do I know which pixel it refers to?
>
> Thanks,
> Neil
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> <visual inspection of selected pixels.tiff><recovered reference intensity - 5671 - with contour 157.tiff>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: understanding selection coordinates

Neil Fazel
In reply to this post by Neil Fazel
Hi Michael,

   Thanks so much for the response. I read it carefully but I'm still not clear when you say "the pixel at coordinates (0,0) is encompassed by the contour with the (x,y) values of (0,0), (1,0), (1,1), (0,1)." Maybe I don't understand the difference between pixel coordinates and selection coordinates. (I tried to look it up in the macro guide but it doesn't seem to explain this clearly.)

I understand from your reply that when a contour is drawn for a given contour level, it (usually) passes between pixels having value above and below that value. Now what I would like to do is to get the value of those pixels; is getPixels(x,y) applied to (x,y) returned by getSelectionCoordinates() not the way to do it?

Thanks,
Neil

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