Posted by
Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Hide-ROI-Manager-Window-tp3682446p3682447.html
On Nov 24, 2011, at 12:54 PM, Rafael Ballester wrote:
> Hi everybody,
>
> I have generated a binary image consisting of segmented particles. With
> ImageJ's API, I would like to obtain its particles as ROIs, so as to analyze
> them later. What is the easiest way to obtain those ROIs?
>
> The following way works using the ParticleAnalyzer class to store the
> detected ROIs into the RoiManager, so that I can retrieve them later. But I
> can't prevent this approach from opening the ROI Manager Window, which is
> annoying in an automatised context.
>
> int options = ParticleAnalyzer.ADD_TO_MANAGER;
> ParticleAnalyzer pa = new ParticleAnalyzer(options, 0, new ResultsTable(),
> 0, Double.MAX_VALUE, 0, 1);
> pa.analyze(imSegmented); // imSegmented is my binary image
> RoiManager manager = RoiManager.getInstance();
> Roi[] rois = manager.getRoisAsArray();
>
> Do you know how to prevent that window from appearing? Or any different way
> to obtain the ROIs?
The ImageJ 1.46b daily build adds a ParticleAnalyzer.setRoiManager() method that can be used to prevent the ROI Manager window from appearing. Here is a JavaScript example:
imp = IJ.openImage("
http://imagej.nih.gov/ij/images/blobs.gif");
IJ.setAutoThreshold(imp, "Default");
manager = new RoiManager(true);
ParticleAnalyzer.setRoiManager(manager);
IJ.run(imp, "Analyze Particles...", "size=600 exclude add");
rois = manager.getRoisAsArray();
for (i=0; i<rois.length; i++) {
imp.setRoi(rois[i]);
print(i+" "+imp.getStatistics());
}
And here is a lower level example:
imp = IJ.openImage("
http://imagej.nih.gov/ij/images/blobs.gif");
IJ.setAutoThreshold(imp, "Default");
manager = new RoiManager(true);
ParticleAnalyzer.setRoiManager(manager);
pa = new ParticleAnalyzer(0, 0, new ResultsTable(), 600, Double.MAX_VALUE, 0, 1);
pa.analyze(imp);
rois = manager.getRoisAsArray();
-wayne