polygon selection

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

polygon selection

Girault France
Dear all,

 

I'm trying to make a selection around segmented particles (with a black background). When I make the normal selection, there is no problem and the selection follows the outline of the particle, but when I select it as a polygon, on many particles, I get a rectangle instead of the outline of the particle.

Does any body have an idea why? Is it possible to get this polygon selection properly?

 

Thanks,

 

France

 

 

This is what I'm doing:

 

setThreshold(1, 255);

run("Create Selection");

run("Enlarge...", "enlarge=0");

getSelectionCoordinates(selX, selY);

run("Select None");

makeSelection("polygon", selX, selY);

 

 

France Girault

Geological Institute

CAB E-62

ETH Zürich

Universitätstrasse 6

8092 Zürich

[hidden email]

Private phone : ++4178/726.99.20

Office phone : ++4144/632 84 16

 
Reply | Threaded
Open this post in threaded view
|

Re: polygon selection

Wayne Rasband
 > I'm trying to make a selection around segmented particles (with a  
black
 > background). When I make the normal selection, there is no problem and
 > the selection follows the outline of the particle, but when I select  
it as a polygon,
 > on many particles, I get a rectangle instead of the outline of the  
particle.

 > Does any body have an idea why? Is it possible to get this polygon  
selection properly?

 > This is what I'm doing:

 > setThreshold(1, 255);
 > run("Create Selection");
 > run("Enlarge...", "enlarge=0");
 > getSelectionCoordinates(selX, selY);
 > run("Select None");
 > makeSelection("polygon", selX, selY);

ImageJ 1.38b fixes a bug that can cause this problem. From the release  
notes:

    Edit/Selection/Create Selection creates, if possible, a
    non-composite  selection. The "Issue with ROI closing"
   workaround on the Documentation Wiki at
   
<http://imagejdocu.tudor.lu/imagej-documentation-wiki/gui-commands/ 
selection>
   no longer needed.

Isolated pixels, or pixels that are only corner-connected, can also  
cause this problem. You can remove such pixels by doing binary erosion  
with a count of 7, as in this example:

     setThreshold(1, 255);
     run("Convert to Mask");
     run("Options...", "iterations=1 count=7");
     run("Erode");
     run("Create Selection");
     getSelectionCoordinates(selX, selY);
     makeSelection("polygon", selX, selY);

There is an example of a segmented particle with a single  
corner-connected pixel at:

    http://rsbweb.nih.gov/ij/images/8-connected-pixel.gif

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: polygon selection

Pawel Znojek
 
Hi Wane
Do you know something about any good macros for analizing comet assay?
Pawal
Reply | Threaded
Open this post in threaded view
|

Point selection: center of the pixel

Nas-5
Dear all,

I understand that with point tool, the (x,y) that you
get for a pixel depends on which corner of the pixel
you are pointing with the point tool. I would like to
have (x,y) corresponding to the center of the pixel
(the same way it is done in MATLAB). how could I do
this?
Thanks for your help,

Nas



 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: Point selection: center of the pixel

Wayne Rasband
> I understand that with point tool, the (x,y) that you
> get for a pixel depends on which corner of the pixel
> you are pointing with the point tool. I would like to
> have (x,y) corresponding to the center of the pixel
> (the same way it is done in MATLAB). how could I do
> this?

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. A
future version of ImageJ will support sub-pixel addressing and then
(x,y) will be the point within the pixel you clicked on. Currently,
only the straight line tool supports sub-pixel addressing.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Point selection: center of the pixel

Gabriel Landini
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
Reply | Threaded
Open this post in threaded view
|

Re: Point selection: center of the pixel

Kenneth Sloan-2
On Dec 9, 2006, at 4:57 AM, Gabriel Landini wrote:


>
> Since the pixels are point samples, not areas,

This is a common point of view, but in my opinion it is not the most  
useful one.

There are at least 3 different working assumptions you can make about  
how to treat pixels and co-ordinates - and I fear that there is not  
universal agreement among all IJ users/developers.

The dangerous part is that each camp often assumes that their view is  
"obviously" the correct one.  That way be religious wars.

--
Kenneth Sloan                                          
[hidden email]
Computer and Information Sciences                        +1-205-934-2213
University of Alabama at Birmingham              FAX +1-205-934-5473
Birmingham, AL 35294-1170                http://www.cis.uab.edu/sloan/
Reply | Threaded
Open this post in threaded view
|

Re: Point selection: center of the pixel

H. Gluender
Dear Kenneth Sloan,

nice to hear some current news about the apparently advanced
religious debate in your country...


>>Since the pixels are point samples, not areas,
>
>This is a common point of view, but in my opinion it is not the most
>useful one.
>
>There are at least 3 different working assumptions you can make
>about  how to treat pixels and co-ordinates - and I fear that there
>is not  universal agreement among all IJ users/developers.
>
>The dangerous part is that each camp often assumes that their view
>is  "obviously" the correct one.  That way be religious wars.
>
>--
>Kenneth Sloan                                          
>[hidden email]
>Computer and Information Sciences                        +1-205-934-2213
>University of Alabama at Birmingham              FAX +1-205-934-5473
>Birmingham, AL 35294-1170                http://www.cis.uab.edu/sloan/


Because on this list we are dealing with scientific image processing,
we should try to solve certain issues mathematically, i.e. in a
hopefully objective fashion.

Images in digital computers are represented as arrays of numbers and
numbers aren't spatially extended.

Pixels (Picture Elements) -- sometimes (and in the following)
understood as more or less tiny and mostly square areas -- mainly are
a means for visualization and printing, they represent the most
simple interpolation between samples, i.e. the above mentioned
numbers. As we all know, this interpolation is cheap but inadequate.

Regarded as interpolated samples, such extended pixels of course have
a defined area and side-length(s) that may be even calibrated.

To answer the original question, of where to localize the sample
value (with respect to the pixel area), depends on how the
interpolation function -- i.e. the square or rectangular area -- is
defined. The origin of this interpolation function may be at the
center, or at one of its corners, or wherever you like.

If one knows the exact way digital images have been acquired, this
knowledge could be used to choose the origin of the interpolation
function more adequately, but this is a topic that should be treated
in a different thread...

Best
--


                   Herbie

          ------------------------

          <http://www.gluender.de>