Login  Register

Using API to create mask with multiple rectangles

Posted by Leonard Sitongia on Nov 19, 2007; 8:11pm
URL: http://imagej.273.s1.nabble.com/Using-API-to-create-mask-with-multiple-rectangles-tp3697968.html

Hi,

What's the best way to create a mask that is composed of multiple
rectangles?

That is, I have an image which I want to measure the value of the pixels
in several rectangular areas in the image.  With the GUI, I could use
the ROI Manager to draw several rectangles, and Measure to get the
values in the rectangles.

It looks like there are several ways I could do this with the API,
including using the GUI to draw and save the ROIs, and reading them in
with the API, which is slick.  But, I'm wondering about the basics in
the API.

I can easily create an AWT Rectangle, and set it on an ImageProcessor.

How do I set multiple Rectangles on an ImageProcessor?  I guess that I
need to create a mask, perhaps using an AWT Shape?  Can a ROI have the
shape of multiple separate Rectangles?  Or, do I need to apply each
rectangular ROI one-at-a-time to the image and add up the values from each?

Can I easily get the sum of the values of the image in the rectangles?  
I see Measurements and ImageStatistics, but I don't see simply the sum
of the pixels.  Can I easily get the sum?  Without calculating all the
other statistics?

Thanks!

--
==Leonard E. Sitongia
   High Altitude Observatory
   National Center for Atmospheric Research
   P.O. Box 3000 Boulder CO 80307  USA
   [hidden email]  voice: (303)497-2454  fax: (303)497-1589