Controlling range/scale on histograms

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

Controlling range/scale on histograms

Jeff Brandenburg
Hi, all --

I'm trying to set up a macro that allows a user to compare histograms
for the same ROI in multiple (16-bit signed or unsigned) stacks.  It's
easy enough to use ROI manager to stamp the same ROI onto multiple
stacks, but I can't find a way to normalize the resulting histograms to
the same scale.

I'd like to just set the min and max for the histogram (say, 0 to
32767), and use that same range repeatably.  I can do that if I'm
working with 32-bit images, but not with 16-bit images.

I've fiddled a bit with the Histogram code, but when I activate the
range dialog, I still get a histogram that's scaled between the minimum
and maximum values actually present in the data -- the min and max that
I specify are ignored.  I've traced through the code a bit to try to
figure out what's happening, but I get lost pretty quickly.

Has anyone else managed (or even tried) to do this?  Am I missing
something obvious?

Thanks in advance...
--
        -jeffB (Jeff Brandenburg, Duke Center for In-Vivo Microscopy)
Reply | Threaded
Open this post in threaded view
|

Re: Controlling range/scale on histograms

Wayne Rasband
> I'm trying to set up a macro that allows a user to compare
> histograms for the same ROI in multiple (16-bit signed or
> unsigned) stacks.  It's easy enough to use ROI manager to
> stamp the same ROI onto multiple stacks, but I can't find a
> way to normalize the resulting histograms to the same scale.
>
> I'd like to just set the min and max for the histogram
> (say, 0 to 32767), and use that same range repeatably.

The CustomHistogram macro at

     http://rsb.info.nih.gov/ij/macros/CustomHistogram.txt

does this.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Controlling range/scale on histograms

Jeff Brandenburg
Okay, if I'm following this correctly, the macro essentially duplicates
each image, converts the duplicate to 32-bit, and then runs a histogram
of the 32-bit image.  Since 32-bit histograms do properly let you set
the min and max, this works, albeit VERY slowly for large stacks. :-)

If converting to 32-bit is the way to go, then that's what I'll do.  It
looks like the auto-ranging for 16-bit-image histograms is hard-coded
deep within ShortStatistics, and not amenable to outside modification.  
Maybe later I'll see if there's a way to fix this without rewriting
ShortStatistics.  (Is there a reason that non-float images ignore
ImageProcessor.histogramMin and histogramMax, or did it just grow that
way?)

Thanks, Wayne!

On Aug 4, 2005, at 10:49 AM, Wayne Rasband wrote:

>> I'm trying to set up a macro that allows a user to compare
>> histograms for the same ROI in multiple (16-bit signed or
>> unsigned) stacks.  It's easy enough to use ROI manager to
>> stamp the same ROI onto multiple stacks, but I can't find a
>> way to normalize the resulting histograms to the same scale.
>>
>> I'd like to just set the min and max for the histogram
>> (say, 0 to 32767), and use that same range repeatably.
>
> The CustomHistogram macro at
>
>     http://rsb.info.nih.gov/ij/macros/CustomHistogram.txt
>
> does this.
>
> -wayne
>
--
        -jeffB (Jeff Brandenburg, Duke Center for In-Vivo Microscopy)