Login  Register

Histogram modification before auto thresholding

Posted by yccheok on Apr 24, 2006; 3:56am
URL: http://imagej.273.s1.nabble.com/Histogram-modification-before-auto-thresholding-tp3703002.html

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