Login  Register

How to get the centoid coordinates of any shaped roi

Posted by Maximilian Maske on Oct 12, 2016; 3:20am
URL: http://imagej.273.s1.nabble.com/How-to-get-the-centoid-coordinates-of-any-shaped-roi-tp5017351.html

Dear ImageJ list,


I am trying to get the coordinates of the centroid of my ROI, which is in my case a polygon roi I think. I can see the centroid coordinates by using the Analyzer but I need to call this from my plugin.


I tried like this:

Roi roi = image.getRoi();
ImageStatistics stats = roi.getImage().getStatistics();
System.out.println("(" + stats.xCentroid + " : " + stats.yCentroid + ")");


But at the moment I will get an output (0.0 : 0.0) which I don't understand.

Can you help me here?


Thank you,

Maximilian


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