Re: Using API to create mask with multiple rectangles
Posted by
Albert Cardona on
Nov 19, 2007; 8:27pm
URL: http://imagej.273.s1.nabble.com/Using-API-to-create-mask-with-multiple-rectangles-tp3697968p3697969.html
Use the ShapeRoi. You can add any other roi to it. For example:
// make ShapeRoi from a rectangle roi:
ShapeRoi sroi = new ShapeRoi(new Roi(0, 0, width1, height1));
// add a second rectangle
sroi.add(new ShapeRoi(new Roi(x,y,w,h));
All the above can be done with the java.lang.geom.Area as well, with
regular java.awt.Rectangle instances.
To get the sum of the pixel values within the ROI, get the mask first
from the roi, and if the pixel in the mask in non-zero, add the
corresponding pixel from the image.
Albert
--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona