Login  Register

Re: polygon selection

Posted by Wayne Rasband on Dec 07, 2006; 4:06pm
URL: http://imagej.273.s1.nabble.com/polygon-selection-tp3700848p3700849.html

 > 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