PANDORE Version 6 | GREYC-IMAGE |
pvariancebinarization classifies pixels of the input image im_in into 2 clusters. The threshold value is determined as the gray level value that maximizes the interclass variance (according to Otsu's algorithm)
The principle of the algorithm is as follows:
Let h be the histogram of the gray levels, pi the probability
of the gray level i and N the total number of pixels:
pi=h[i]/N
To classify the pixel into 2 clusters C0 and C1 with the threshold t:
Let p(c) and p(c1) the probabilities for a pixel x to belong
respectively to the class C0 and C1:
p(C0) = SUM(i=0;s){ pi } p(C1) = SUM(i=s+1;N){ pi }
The means for each class C0 and C1 are:
M0 = SUM(i=0;s){ pi/p(C0) } M1 = SUM(i=s+1;N){ pi/p(C1) }
The total mean for the input image is:
Mt = SUM(i=0;N){ i.pi }
The optimal threshold t maximizes the interclass variance V(t):
V(t) = SUM(i=1;2) { P(Ci).(Mi-Mt).(Mi-Mt) }
Returns the threshold value..
Segments the tangram pieces:
pvariancebinarization tangram.pan a.pan
Binarisation de l'image par analyse de la variance interclasse.
N. Otsu, "A threshold selection method from grey scale histogram", IEEE Trans. on Syst. Man and Cyber., vol 1, pp 62-66, 1979.
Author: Régis Clouard