The class implements Otsu thresholding, which is described in N. Otsu, "A threshold selection method from gray-level histograms", IEEE Trans. Systems, Man and Cybernetics 9(1), pp. 62–66, 1979.
This implementation instead of minimizing the weighted within-class variance does maximization of between-class variance, what gives the same result. The approach is described in this presentation.
The filter accepts 8 bpp grayscale images for processing.
Sample usage:
// create filter OtsuThreshold filter = new OtsuThreshold( ); // apply the filter filter.ApplyInPlace( image ); // check threshold value byte t = filter.ThresholdValue; // ...
Initial image:
Result image (calculated threshold is 97):