Login  Register

Re: Histogram modification before auto thresholding

Posted by Wayne Rasband on Apr 24, 2006; 9:01pm
URL: http://imagej.273.s1.nabble.com/Histogram-modification-before-auto-thresholding-tp3703002p3703004.html

The Image->Adjust->Threshold tool modifies the histogram so that
largest count is no larger than 1.5x the next largest count. It does
this to increase the y scale in the histogram plot for images with a
large number of pixels with the same value. The fact that this modified
histogram is used for auto-thresholding is a bug.

-wayne


On Apr 23, 2006, at 10:56 PM, Cheok Yan Cheng wrote:

> Recently, when I try out the auto-threshold function
> in ImageJ, I found that two following two methods
> produce completely different result:
>
> (A) Process->Binary->Threshold
>
> (B) Image->Adjust->Threshold…
>
> After some reading into the ImageJ source code
> (ij134s), I found that the (B) operation did some
> modification on the original image histogram before
> proceeding to auto threshold based on histogram.
>
> In ij\plugin\frame\ThresholdAdjuster, method
> ImageStatistics setHistogram(ImagePlus imp), it does
> modify the histogram with the following code:
>
> for (int i = 0; i < stats.nBins; i++)
> if ((histogram[i] > maxCount2) && (i !=
> stats.mode))
> maxCount2 = histogram[i];
> hmax = stats.maxCount;
> if ((hmax>(maxCount2 * 2)) && (maxCount2 != 0)) {
> hmax = (int)(maxCount2 * 1.5);
> histogram[stats.mode] = hmax;
>         }
>
> It seems that if the largest histogram is much greater
> (2x) than the 2nd largest histogram, the largest
> histogram will be reduced to 1.5x of the 2nd largest
> histogram.
>
> May I know what is the reasons behind for doing so? Is
> there any more information on this?
>
> Yccheok
>
> P/s For my case, my image get much better result
> through (B)
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>