Login  Register

Re: getting ROI coordinates

Posted by dscho on Jul 06, 2007; 1:11pm
URL: http://imagej.273.s1.nabble.com/getting-ROI-coordinates-tp3698929p3698930.html

Hi,

On Thu, 5 Jul 2007, J?r?my Ohana wrote:

> How can I get the coordinates of the drawn ROI in my plugin in
> order to use this coordinates after on a serie of pictures?

You can get the ROI with the method "getRoi()" of ImagePlus. This Roi is
usually a subclass of ij.gui.Roi. In your case, I guess that it is either
ij.gui.PolygonRoi or ij.gui.PointRoi.

After casting to PolygonRoi (which is a superclass of PoitRoi, so it is
possible in both cases) you can access the coordinates with the methods
"getXCoordinates()" and "getYCoordinates()", both returning "int[]", and
with "getNCoordinates()" you can get the number of coordinates, which does
not have to be the same as the length of the x and y arrays.

Hth,
Dscho