Login  Register

Re: Point selection: center of the pixel

Posted by Gabriel Landini on Dec 09, 2006; 10:57am
URL: http://imagej.273.s1.nabble.com/polygon-selection-tp3700848p3700853.html

On Friday 08 December 2006 19:51, Wayne Rasband wrote:
> When you click on a pixel with the point tool, the (x,y) you get is the
> point at the upper left corner of the pixel. You can see this by
> zooming an image 3200% and clicking with the point tool. You can get
> the center of the pixel by adding 0.5 to each of the coordinates.

Moreover, if you just "think" that the pixels are addressed at their centres,
then there is no difference at all.
Just think that the polygons have to be achored at some coordinate in the
image and currently IJ does it at the top left corner of each pixel, but the
polygon would be exactly the same if anchored in the centres.

Since the pixels are point samples, not areas, then where one is addressing
should not make a difference.
When positioning coordinates like the centre of mass or centroid (which can be
fractional) of course it makes a difference, but as soon as one has to
address the image pixels again, it is the same as rounding the coodinates,
since (at the moment) you cannot have image objects smaller than the image
sample size (the pixel).

In IJ there is, however, a difference between the draw and fill results.
If you create a polygon and "fill" it, and then you apply "draw" there are
more pixels added to it. (This is not so for the rectangular selection).

Also, when creating some polygons such as triangles, "draw" followed by "fill"
sometimes leaves empty pixels next to the perimeter:

makePolygon(58,63,168,44,113,218);
run("Draw");
run("Fill");
run("Select None");

(this can be resolved by applying Process>Binary>Fill Holes).

So, not-drawn-but-filled polygons tend to have less pixels than
drawn-and-filled ones.
One has to be aware of this.

Cheers,

Gabriel