Login  Register

Re: understanding selection coordinates

Posted by Michael Schmid on Feb 17, 2014; 11:31am
URL: http://imagej.273.s1.nabble.com/understanding-selection-coordinates-tp5006538p5006550.html

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