Re: Get (straight) line coordinates ?

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

Re: Get (straight) line coordinates ?

dscho
Hi,

On Mon, 22 Jul 2013, greendoki wrote:

> how can i do Get (straight) line coordinates ? in java because i'm
> writing a plugin.  actually i need the first and last coordinates but
> nevermind i need all of them.

From your description I *guess* that you are talking about segmented line
selections.

For those, you can cast the result of imp.getRoi() to PolygonRoi and
obtain the coordinates via getXCoordinates() and getYCoordinates(). Beware
that

1) the resulting arrays may be larger than what getNCoordinates() returns,
but only that number of entries is actually valid

2) the coordinates are relative to the bounding box, so you will have to
call "Rectangle bounds = roi.getBounds();" and then add bounds.x and
bounds.y to the x and y coordinates, respectively.

For an example, see:

        http://fiji.sc/Introduction_into_Developing_Plugins#Regions_of_interest

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Get (straight) line coordinates ?

John Dunsmuir
The original question is a bit confusing.  I took it to ask how to recover the list of x,y coordinates of each sampled pixel along a linear ROI.  I did a little exercise and it was easy to get the values along the line and the line endpoints but I couldn't find an API function for the list of x,y coordinates used to form the line. That list will depend on the line drawing algorithm.  Did I miss it?

Thanks,
John D.


Johannes Schindelin wrote
Hi,

On Mon, 22 Jul 2013, greendoki wrote:

> how can i do Get (straight) line coordinates ? in java because i'm
> writing a plugin.  actually i need the first and last coordinates but
> nevermind i need all of them.

From your description I *guess* that you are talking about segmented line
selections.

For those, you can cast the result of imp.getRoi() to PolygonRoi and
obtain the coordinates via getXCoordinates() and getYCoordinates(). Beware
that

1) the resulting arrays may be larger than what getNCoordinates() returns,
but only that number of entries is actually valid

2) the coordinates are relative to the bounding box, so you will have to
call "Rectangle bounds = roi.getBounds();" and then add bounds.x and
bounds.y to the x and y coordinates, respectively.

For an example, see:

        http://fiji.sc/Introduction_into_Developing_Plugins#Regions_of_interest

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html