Yes, you can check how many ROIs there are in the manager, get the area for each and find the largest are. The code below should hopefully do this.
if (roiManager("count")>1);{
Area=newArray(roiManager("count"));
for (i=0; i<roiManager("count");i++){
roiManager("select", i);
getStatistics(Area[i], mean, min, max, std, histogram);
}
AreaLarge = 0;
for (i=0; i<(roiManager("count"));i++){
if (Area[i]>AreaLarge){
AreaLarge=Area[i];
large = i;
}
}
}
roiManager("Select", large);
Best wishes
Kees
Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of burt46
Sent: 18 January 2016 00:46
To:
[hidden email]
Subject: Select largest ROI from multiple
Hi,
I have a macro that runs a binary mask of a stack to generate ROIs within a polygon. Sometime when the macro runs, two or three ROIs are generated per slice rather than just one. Is there a way that you can force ImageJ to select only the largest ROI and ignore/delete the others. I need to extract one ROI per slice.
Many thanks
--
View this message in context:
http://imagej.1557.x6.nabble.com/Select-largest-ROI-from-multiple-tp5015401.htmlSent 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