Posted by
Burger Wilhelm on
May 16, 2017; 4:32pm
URL: http://imagej.273.s1.nabble.com/Combined-surface-area-of-all-ROI-in-an-image-tp5018716p5018735.html
Just to elaborate on the idea to use the Roi iterator, below is a small ImageJ plugin that calculates the cumulative roi area in a stack. No masks, no files required. Perhaps you want to give it a try...
--Wilhelm
// -----------------------------------------------------------------------------
import java.awt.Point;
import ij.IJ;
import ij.ImagePlus;
import ij.gui.Overlay;
import ij.gui.Roi;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class Stack_Roi_Sum_Area implements PlugInFilter {
ImagePlus im = null;
public int setup(String arg, ImagePlus im) {
this.im = im;
return DOES_ALL + STACK_REQUIRED + NO_CHANGES;
}
public void run(ImageProcessor ip) {
int area = 0;
Overlay oly = im.getOverlay();
if (oly != null) {
for (int i = 0; i < oly.size(); i++) {
Roi roi = oly.get(i);
if (roi != null) {
for(Point p : roi) {
area++;
}
}
}
}
IJ.log("Cumulative roi area = " + area);
}
}
// -----------------------------------------------------------------------------
-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of mmettlen
Sent: Dienstag, 16. Mai 2017 15:49
To:
[hidden email]
Subject: Re: Combined surface area of all ROI in an image
Thanks for your replies! I've worked on it too and wrote a little macro that does what Kees suggested. In a nutshell, the macro takes a stack of images and the corresponding ROI manager that contains all the ROIs. It than makes a new 8-bit black stack with the same dimension as the original stack, copies the ROIs into it, flattens them, and uses them to quantify the total area of all ROIs/slice:
.....
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html