Adding coordinates of points in ROI manager to array

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

Adding coordinates of points in ROI manager to array

KKiek
I am new to scripting in ImageJ, and I was wondering if there is a way to add the coordinates of all points in the ROI manager to two arrays (one for x-coordinates and one for y-coordinates). I'm making a macro.

I have been looking at the forums, and only found how to add the coordinates of boudaries. What I have instead are points saved to the ROI manager with the Point tool. I use this to track a bird in a short image sequence.

I thought about using Roi.getCoordinates, but I don't know if that will work.
Reply | Threaded
Open this post in threaded view
|

Adding coordinates of points in ROI manager to array

Jeremy Adler
Use the Multi-point tool rather than many single point entries - for single points you would have to open a series of ROIs and read the single entries.

Then this script gives the distances between points

// assumes a Roi is selected
Roi.getCoordinates(xlist,ylist);// list of x and y coordinates
l=xlist.length;// number of entries in each list
print('entries ',l);
// run thru list
for (n=0;n<l-1;n++){
        print(n,'position ',xlist[n],',',ylist[n]);
        move=sqrt(((xlist[n]-xlist[n+1])*(xlist[n]-xlist[n+1]))+((ylist[n]-ylist[n+1])*(ylist[n]-ylist[n+1])));
        print('   moved ',d2s(move,1));// 1 decimal place
}

A minor oddity is that in addition to selecting the ROI you also need an open image large enough to contain all the points stored in the ROI - a smaller image will only use the points that fit within it.

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of KKiek
Sent: den 10 maj 2016 13:42
To: [hidden email]
Subject: Adding coordinates of points in ROI manager to array

I am new to scripting in ImageJ, and I was wondering if there is a way to add the coordinates of all points in the ROI manager to two arrays (one for x-coordinates and one for y-coordinates). I'm making a macro.

I have been looking at the forums, and only found how to add the coordinates of boudaries. What I have instead are points saved to the ROI manager with the Point tool. I use this to track a bird in a short image sequence.

I thought about using Roi.getCoordinates, but I don't know if that will work.



--
View this message in context: http://imagej.1557.x6.nabble.com/Adding-coordinates-of-points-in-ROI-manager-to-array-tp5016382.html
Sent from the ImageJ mailing list archive at Nabble.com.

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

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