A problem with hiding the Roi manager

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

A problem with hiding the Roi manager

Avital Steinberg
Hi,
I'm using Javascript and running the following code on the attached image,
and it works well.
The number of rois in the manager is one, like I expect:

mportClass(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 = RoiManager();// The Roi manager is displayed
segRoi = ovr.get(0);
imp.setRoi(segRoi);
IJ.setThreshold(imp, 362,695);
IJ.run(imp, "Analyze Particles...", "size=50-Infinity add");
n = rm.getCount();
IJ.log("The number of rois in the manager is: " + n);

But when I try to hide the Roi manager, I get a strange result - the number
of Rois in the Roi
manager is zero:

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 = RoiManager(true);// The Roi manager is not displayed
segRoi = ovr.get(0);
imp.setRoi(segRoi);
IJ.setThreshold(imp, 362,695);
IJ.run(imp, "Analyze Particles...", "size=50-Infinity add");
n = rm.getCount();
IJ.log("The number of rois in the manager is: " + n);

Is this a bug? How can I used the Roi manager in hidden mode?

Thanks,
Avital






I'm using ImageJ 1.51a13, java 1.6.0_65 on a mac OSX 10.9.5.

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

Thresh105to362cropped.tif (694K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A problem with hiding the Roi manager

Gabriel Landini
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
Reply | Threaded
Open this post in threaded view
|

Re: A problem with hiding the Roi manager

Avital Steinberg
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