[Fwd: Re: understanding selection coordinates]

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

[Fwd: Re: understanding selection coordinates]

Michael Schmid
On Wed, February 19, 2014 20:10, Neil Fazel wrote:

> 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?


Hi Neil,

it is unclear to me which pixel values you want.

I'll try with ascii graphics; pixels are denoted by their x&y coordinates.
Then I can draw the top-left corner of the image like this:

  00  01  02  03
  10  11  12  13
  20  21  22  23

Now, if you select, say, pixel '11', i.e, a rectangle around the pixel
with x=1, y=1.  According to the definition of pixels in ImageJ, this
rectangle has its upper-left border at (1,1), and width=1, height=1, so
getSelectionCoordinates() will give you (1,1), (1,2), (2,2), (2,1).

The lines of this rectangle are actually *between* the pixels, because the
rectangle encompasses pixel '11'. Also the vertices (corners) that define
the rectangle are *between* the pixels.
Now, what do you define as the pixel value at a position between two pixels?
For me, the most obvious option would be interpolating between the pixels
neighboring each vertex.
So I would defint the pixel values at the vertices as getPixel(0.5, 0.5),
getPixel(0.5, 1.5), getPixel(1.5, 1.5), and getPixel(1.5, 0.5).  That is,
subtract 0.5 from the x and y coodinates that you get from
getSelectionCoordinates().

Michael

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

Re: [Fwd: Re: understanding selection coordinates]

Neil Fazel
Hi Michael,

    Thank you for explaining ImageJ pixel coordinates. I understand it now.

> it is unclear to me which pixel values you want.

I think it's because there is an ambiguity in the notion of a contour. One would expect a contour for a given grayscale value to go "through" pixels having that value (within some tolerance). However, Contour Plotter contours pass "between" pixels. In the first case (contour "through" pixels), the pixels of interest would be the ones "crossed" by the contour; I would use getPixel() to get their value and there would be no ambiguity. However, the contours drawn by the Contour Plotter pass "between" pixels, so there is an ambiguity as to which pixels they refer to. I'm trying to figure out how a contour meant to go from pixel (x,y) to pixel (x',y') is routed; then, having the route (returned by getSelectionCoordinates()) I could figure out (x,y) and (x',y') and use getPixel(x,y) and getPixel(x',y') to get the pixel values I'm interested in.

Best regards,
Neil

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