how to get the coordinates of a PointRoi?

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

how to get the coordinates of a PointRoi?

Ben Liu-3
Hi there,

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?
Thanks.

Best wishes,
Bian Liu
Reply | Threaded
Open this post in threaded view
|

Re: how to get the coordinates of a PointRoi?

Wayne Rasband
> 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