Please ignore this, I fixed it (and it was indeed because
ImagePlus.getImageStack.getProcessor(int i) returns an ImageProcessor
without an ROI, so you have to reset the ROI each time...)
On 15/07/10 10:59, Michael Doube wrote:
> 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
--
Dr Michael Doube BPhil BVSc PhD MRCVS
Research Associate
Department of Bioengineering
Imperial College London
South Kensington Campus
London SW7 2AZ
United Kingdom