Login  Register

How to construct the ROI manager

Posted by Avital Steinberg on Aug 23, 2015; 9:00am
URL: http://imagej.273.s1.nabble.com/How-to-construct-the-ROI-manager-tp5014113.html

Hi,
I'm trying to count the number of objects in the roi manager in Javascript.
I wrote the following code:

importClass(Packages.ij.IJ);
importClass(Packages.ij.plugin.frame.RoiManager);
importClass(Packages.ij.io.OpenDialog);
importClass(Packages.ij.io.DirectoryChooser);
importClass(Packages.java.io.File);
importClass(Packages.ij.gui.GenericDialog);
importClass(Packages.ij.util.Tools);
importClass(Packages.ij.plugin.Duplicator);

IJ = IJ();
rm = RoiManager();
returnedRm = rm.getInstance();
print("The returned rm is: " + returnedRm);
var nObjects = rm.getCount();
print("nObjects is: " + nObjects);

And I get the following error message:

javax.script.ScriptException:
sun.org.mozilla.javascript.internal.WrappedException: Wrapped
java.lang.NullPointerException

When I comment out the problematic line (var nObjects = rm.getCount();) I
get the following Roi Manager type for the rm: (getInstance returned this)

The returned rm is:
ij.plugin.frame.RoiManager[frame61,884,327,240x330,invalid,layout=java.awt.BorderLayout,title=ROI
Manager,resizable,normal]

How would I count the number of ROIs in the Roi manager? And how can I use
the RoiManager class methods?

Thanks,
Avital

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