First, Ostu know
Ostu assumes that the image is composed of a foreground region and a background region, by traversing the gray histogram of the foreground region and the background area in the segmentation results under different thresholds (usually [0 255] interval), and then comparing the variance between the two, the gray threshold that maximizes the variance is the value of the binary threshold.
Introduction to the principle of Otsu algorithm
For an image, set the current scene and the background of the segmentation threshold is T, the foreground point of the image ratio of w0, the mean is u0, the back of the image is the ratio of W1, the average value is U1. The average value of the entire image is U = w0*u0+w1*u1. The objective function g (t) =w0* (u0-u) ^2+w1* (u1-u) ^2,g (t) is the inter-class variance expression when the segmentation threshold is T. The Otsu algorithm allows G (t) to achieve the global maximum, when G (t) is the maximum, the corresponding T is called the optimal threshold. The Otsu algorithm is also called the Maximal inter-class variance method
Three, Ostu Dajing method algorithm thought:
One has a depth gray level, according to each gray level t, you can divide a picture into foreground and background.
Foreground refers to all pixels below or equal to T, and the background refers to pixels greater than t.
W0 refers to the number of foreground pixels; W1 refers to the number of background pixels; u0 refers to the foreground weighted average, i.e.
Temp=0;
For I=1:t
Temp=temp+i*hist (i)
End
U0=temp/w0;
where W0=hist (0) +hist (1) +......+hist (t)
hist refers to the number of pixels on each gray level
U1 corresponds to the background weighted average
U-weighted average for the entire picture
U=u0*w0+u1*w1. (*)
The result of the Dajing method refers to the maximum T value of G:
g=w0* (u0-u) ^2+w1* (u1-u) ^2=w0*w1* (u1-u0) ^2 (substituting * available)
Iv. in the image processing toolbox of MATLAB, the Dajing (Ostu) Threshold segmentation method has a ready-made function implementation graythreshold.