MATLAB: How to compute threshold by dividing the histogram of the image into 2 classes

threshold computation

How to compute threshold by dividing the histogram of the image into two classes and calculates the optimum threshold T that separates these two classes so that their combined spread (intraclass variance) to be minimal.
Please can someone help me…
i found histogram of image
histgray = imhist(denoisedImage);
then how to get the value that separates two classes… please do reply…

Best Answer

I think what you need is Otsu image global threshold,
I = imread('myimage.png');
level = graythresh(I);
This function performs the gray-level histogram and select the optimal threshold by the discriminant criterion so as to maximize the separability of the resultant classes in gray levels.
You can read the complete paper here
Type edit graythresh on your Matlab console to watch the code.
Related Question