This post was updated on .
Hi,
I would like to calculate one histogram from the areas of multiple ROIs. For example, I draw 1 ROI per slice on 10 of 24 slices in a stack. Now I would like to calculate ONE histogram for the 10 areas of the ROIs. Any ideas how to do that in imageJ? I know how to use the ROI manager to create multiple ROIs, but I cannot figure out how to create ONE histogram. Thanks, dm |
You could simply add the individual histogram arrays (and optionally show the result as a plot). In macro language, create an array for accumulation, select each roi, use command 'getRawStatistics(...)', and add the individual array to the accumulation array. You can use the plot functions to show the resulting accumulated histogram graphically. If you are uncomfortable with macro language, there are enough people (including myself) to give you some sample code.
Norbert Vischer -----Original Message----- From: ImageJ Interest Group on behalf of deutschmed Sent: Thu 3/19/2009 2:37 AM To: [hidden email] Subject: multiple ROIs in stack -> one histogram Hi, I would like to calculate one histogram from the areas of multiple ROIs. For example, I draw 1 ROI per slice on 10 of 24 slices in a stack. Now I would like to calculate ONE histogram for the 10 areas of the ROIs. Any ideas how to do that in imageJ? I know how to use the ROI manager to create multiple ROIs, but I cannot figure out how to create ONE histogram. Thanks, dm -- View this message in context: http://n2.nabble.com/multiple-ROIs-in-stack--%3E-one-histogram-tp2500671p2500671.html Sent from the ImageJ mailing list archive at Nabble.com. |
Thanks very much Norbert,
I am still unfamiliar with the macro language as I have just started using imageJ. I will try to implement your suggestions but I would also be more than happy for any piece of sample code from you (or anyone :-)) to make the start easier. dm
|
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); } |
Free forum by Nabble | Edit this page |