Login  Register

Re: A problem with hiding the Roi manager

Posted by Avital Steinberg on Jul 14, 2016; 8:28am
URL: http://imagej.273.s1.nabble.com/A-problem-with-hiding-the-Roi-manager-tp5016880p5016884.html

Thanks, Gabriel - I figured it out now. I can use the Roi manager in hidden
mode by using the following code:

importClass(Packages.ij.IJ);
importClass(Packages.ij.plugin.frame.RoiManager);
importClass(Packages.ij.ImagePlus);
importClass(Packages.ij.process.ImageProcessor);
importClass(Packages.ij.gui.Overlay);
importClass(Packages.ij.plugin.filter.ParticleAnalyzer);
importClass(Packages.ij.gui.Roi);
importClass(Packages.ij.plugin.filter.Analyzer);
importPackage(java.awt);


imp = IJ.getImage();
ip = imp.getProcessor();
ovr = imp.getOverlay();
rm = new RoiManager(true);// The Roi manager is not displayed
ParticleAnalyzer.setRoiManager(rm);
segRoi = ovr.get(0);
imp.setRoi(segRoi);
IJ.setThreshold(imp, 362,695);
IJ.run(imp, "Analyze Particles...", "size=50-Infinity add");
rois = rm.getRoisAsArray();
areas = new Array();
for(i=0;i<rois.length;i++){
    ip.setRoi(rois[i]);
    stats = ip.getStatistics();
    areas[i] = stats.area;
    ovr.add(rois[i]);
}

print("The area of the first particle is: " + areas[0]);
IJ.resetThreshold(imp);


The following command:

ParticleAnalyzer.setRoiManager(rm);

Binds the Roi manager with the particle analyzer, so that I can get the
Rois even thought the Roi manager is hidden.

Best,
Avital

On Thu, Jul 14, 2016 at 11:18 AM, Gabriel Landini <[hidden email]>
wrote:

> Avital Steinberg <[hidden email]> wrote:
> > Is this a bug? How can I used the Roi manager in hidden mode?
>
> No bug there. If you close the ROI manager, you lose the ROIs.
> You can check that by closing the ROI manager and opening again (it will be
> empty).
>
> Cheers
>
> Gabriel
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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