Re: multiple ROIs in stack -> one histogram
Posted by Norbert Vischer-2 on Mar 20, 2009; 10:35am
URL: http://imagej.273.s1.nabble.com/multiple-ROIs-in-stack-one-histogram-help-needed-tp3693241p3693244.html
The second macro creates a cumulative histogram of many rois.
The first macro is intended for test only.
regards, Norbert Vischer
//testcase: resulting cumulative histo
//should show double height (=20) at 110..139
macro "make rois [F1]"{
newImage("TwoSlices", "8-bit Ramp", 256, 200, 2);
roiManager("reset");
setSlice(1);
makeRectangle(10, 10, 130, 10);
roiManager("Add");
setSlice(2);
makeRectangle(110, 10, 130, 10);
roiManager("Add");
}
//Creates a cumulative histogram of all rois in roi manager
macro "Cumulative Roi Histogram [F2]"{
nRois = roiManager("count");
cumulHisto = newArray(256);
for (ii=0; ii<nRois; ii++) {
roiManager("select", ii);
getStatistics(area, mean, min, max, std, histogram);
for (jj = 0; jj < 256; jj++){
cumulHisto[jj]+= histogram[jj];
}
}
Plot.create("Cumulative Histo", "Gray value", "count", cumulHisto);
}