Login  Register

Re: how to get the coordinates of a PointRoi?

Posted by Wayne Rasband on May 11, 2006; 7:16pm
URL: http://imagej.273.s1.nabble.com/how-to-get-the-coordinates-of-a-PointRoi-tp3702829p3702830.html

> I need to get the coordinates of a PointRoi in a plugin. But i did not
> find such method in this class. How to do this?

    Polygon p = roi.getPolygon();
    for (int i=0; i<p.npoints; i++)
        IJ.log(i+": "+p.xpoints[i]+","+p.ypoints[i]);

Works for all other selection types as well.

In a macro use

     getSelectionCoordinates(x, y);
     for (i=0; i<x.length; i++)
         print(i+": "+x[i]+","+y[i]);

-wayne