(18) Threshold segmentation

1. Maximum between-class variance method: otsu

The idea of ​​clustering is used, and the gray level of the image is divided into two parts according to the gray level, so that the gray value difference between the two parts is the largest, and the gray difference between each part is the smallest. Calculate to find a suitable gray level to divide.

Let t be the set threshold, w0 is the ratio of the foreground pixels to the image after separation, u0 is the average grayscale of the foreground pixels after separation, w1 is the ratio of the background pixels to the image after separation, and u1 is the background pixels after separation. The average gray level of the number of points, u=w0*u0+w1*u1 is the total average gray level of the image. 

Traverse t from L gray levels, so that when t is a certain value, the variance of foreground and background is the largest, then the threshold value required by this t value.

 Since the otsu algorithm is to cluster the gray levels of the image, the gray histogram of the image needs to be calculated before executing the otsu algorithm.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324134807&siteId=291194637