Posted by
Avital Steinberg on
Sep 25, 2016; 4:39pm
URL: http://imagej.273.s1.nabble.com/A-problem-with-area-measurements-tp5017237.html
Hi,
I'm having trouble measuring areas of composite Rois in Javascript. When I
run the following code, I get a strange answer for the area of the
composite:
importClass(Packages.ij.IJ);
importClass(Packages.ij.plugin.frame.RoiManager);
importClass(Packages.ij.ImagePlus);
importClass(Packages.ij.process.ImageProcessor);
importClass(Packages.ij.gui.Roi);
importClass(Packages.ij.gui.ShapeRoi);
importPackage(java.awt);
rm = RoiManager.getInstance();
if (rm==null) rm = new RoiManager();
imp = IJ.createImage("Untitled", "8-bit ramp", 2000, 2048, 1);
ip = imp.getProcessor();
imp.setRoi(324,366,231,120);
IJ.run("ROI Manager...", "");
rm.addRoi(imp.getRoi());
roi1 = imp.getRoi();
imp.setRoi(231,261,549,354);
rm.addRoi(imp.getRoi());
roi2 = imp.getRoi();
shpRoi1 = ShapeRoi(roi1);
shpRoi2 = ShapeRoi(roi2);
rm.addRoi(shpRoi1);
rm.addRoi(shpRoi2);
imp.show();
ip.setRoi(shpRoi1);
stats = ip.getStatistics();
area = stats.area;
IJ.log("The area for shpRo1 is: " + area);
ip.setRoi(shpRoi2);
stats = ip.getStatistics();
area = stats.area;
IJ.log("The area for shpRo2 is: " + area);
shpRoi3 = shpRoi2.not(shpRoi1);
rm.addRoi(shpRoi3);
ip.setRoi(shpRoi3);
stats = ip.getStatistics();
area = stats.area;
IJ.log("The area for shpRo3 is: " + area);
Selecting the area and using Analyze, measure from the gui gives the
results I would expect, but when I try to get the area from the
ImageStatistics object, I get the wrong result.
When you try to run the code, do you also get a strange result?
Thanks,
Avital
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html