> On Oct 11, 2016, at 11:20 PM, Maximilian Maske <
[hidden email]> wrote:
>
> 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.
The ImagePlus.getStatistics() method calculates area, mean, min/max, standard deviation, mode and median. To get the centroid, use ImagePlus.getStatistics(Measurements.CENTROID), as in this JavaScript example:
stats = image.getStatistics(Measurements.CENTROID);
IJ.log(stats.xCentroid+" : "+stats.yCentroid);
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html