Limiting histogram to ROI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Limiting histogram to ROI

Michael Doube
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
Reply | Threaded
Open this post in threaded view
|

Re: Limiting histogram to ROI

Michael Doube
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
Reply | Threaded
Open this post in threaded view
|

Cropping multiple ROIs from one image

Jacqueline Ross
In reply to this post by Michael Doube
Dear All,

Can anyone tell me how I might create multiple ROIs in a single image,
crop them all out as individual images and then run the "Draw Random
Dots" inside each individual ROI?

Kind regards,

Jacqui

Jacqueline Ross

Biomedical Imaging Microscopist
Biomedical Imaging Research Unit
School of Medical Sciences
Faculty of Medical & Health Sciences
The University of Auckland
Private Bag 92019
Auckland, NEW ZEALAND

Tel: 64 9 373 7599 Ext 87438
Fax: 64 9 373 7484

http://www.fmhs.auckland.ac.nz/sms/biru/