Retrieving perimeter pixel coordinates (all of them) in a macro

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

Retrieving perimeter pixel coordinates (all of them) in a macro

BenTupper
Hello,

The doWand() macro command will outline an object, but where the edge  
of the object is horizontal or vertical it includes only the  
endpoints.  In a sense, the wand reduces the number of outline points  
by skipping repeats.  For example, in the macro below a square is  
drawn.  Using the wand, the ROI outline contains 4 points even though  
the perimeter includes some 400 pixels.  However, by uncommenting the  
rotation line in the macro the square is rotated and the outline  
contains 555 points (which is fine because of rounding, interpolation  
(or not), etc.).  In this case, the outline is the representation of  
the perimeter pixels.  How might I get the coordinates of the all  
perimeter points for the unrotated perimeter?  Or, more generally, how  
might I get all the perimeter points regardless of shape?

Thanks!
Ben Tupper


// begin of macro
newImage("one-rect", "8-bit White", 200, 200, 1);
run("Specify...", "width=100 height=100 x=50 y=50");
run("Draw");
makeRectangle(50, 50, 100, 100);
floodFill(96, 103);
run("Select None");

// Comment the next line to have a square - otherise a diamond is shown
//run("Arbitrarily...", "angle=45 grid=1 interpolation=None fill");
//

setThreshold(0, 254);
run("Convert to Mask");
doWand(39, 98);
getSelectionCoordinates(x,y);
for (i = 0; i < x.length ; i++){
        print("i=", i, " x=",x[i], " y=",y[i]);
}
// end of macro