Login  Register

Limiting histogram to ROI

Posted by Michael Doube on Jul 15, 2010; 9:59am
URL: http://imagej.273.s1.nabble.com/Limiting-histogram-to-ROI-tp3687612.html

Dear all,

A small code question.  I want to generate an autothreshold using a
histogram generated from all slices in a stack, and limited to an ROI if
one is present.  I thought that simply calling

ImageProcessor sliceIP = stack.getProcessor(z);
int[] sliceHistogram = sliceIP.getHistogram();

would give me a histogram of the slice, or the pixels in the ROI if an
ROI was drawn, because of this method description:

"int[] ij.process.ImageProcessor.getHistogram()

Returns the histogram of the image or ROI. Returns a luminosity
histogram for RGB images and null for float images."

However, it seems like the ROI is being ignored.
Is this because I call ImageStack.getProcessor() rather than
ImagePlus.getProcessor()?

I use this approach in getStackHistogram, line 338 here:
http://github.com/mdoube/BoneJ/blob/master/src/org/doube/bonej/ThresholdMinConn.java

Michael