The watershed segmentation method is a mathematical morphology Segmentation Method Based on topological theory. Its basic idea is to regard the image as the topological landform of the survey, the gray value of each pixel in the image indicates the altitude of the point. Each local minimum value and its affected area are called a collection basin, while the border of the collection basin forms a watershed. The concept and formation of watershed can be illustrated by simulating the immersion process. On each surface with a local minimum value, a small hole is passed through, and the entire model is slowly immersed in water. As the immersion deepens, the influence domain of each local minimum value gradually expands outward and a dam is built at the convergence of the two collection basins, it forms a watershed.
The watershed calculation process is an iterative tagging process. The typical calculation method of watershed is L. Vincent Proposed. InAlgorithmIn, the watershed calculation is divided into two steps, one is the sorting process, and the other is the drowning process. First, the gray level of each pixel is sorted from low to high, and then each local minimum value is H Level-and-level impact domains adopt first-in-first-out (FIFO) Structure.
The Watershed Transformation produces the image of the input image's collection basin, and the boundary point between the collection basins is the watershed. Obviously, the watershed indicates the maximum vertex of the input image. Therefore, to obtain the edge information of an image, the gradient image is usually used as the input image, that is
G (x, y) = Grad (f (x, y) = {[F (x, y)-f (x-1, y)] 2 [F (x, y)-f (x, Y-1)] 2} 0.5
Formula,F (x, y)Indicates the original image,Grad {.}Indicates the gradient operation.
The watershed algorithm has a good response to the weak edge. Noise in the image and slight gray changes on the object surface will lead to over-segmentation. At the same time, however, we can see that the watershed algorithm has a good response to the weak edge and ensures the closed continuous edge. In addition, the closed collection basin obtained by the watershed algorithm makes it possible to analyze the regional features of the image.
To eliminate excessive segmentation produced by the watershed algorithm, two processing methods can be used. One is to use a prior knowledge to remove irrelevant edge information. Second, modify the gradient function so that the Set basin only responds to the target to be tested.
To reduce the excessive segmentation produced by the watershed algorithm, the gradient function is usually modified. A simple method is to process the threshold of the gradient image to eliminate excessive segmentation caused by small gray changes. That is
G (x, y) = max (GRAD (f (x, y )),Gθ)
Formula,GθIndicates the threshold value.
BenProgramThe method is to use the threshold value to limit the excessive segmentation of gradient images to eliminate small changes in the gray value, and obtain an appropriate amount of area, then, the gray level of edge points in these areas is sorted from low to high, and then the process of drowning is realized from low to high.SobelOperator calculation. When performing threshold processing on a gradient image, selecting an appropriate threshold has a great impact on the final split image. Therefore, selecting a threshold is a key to the effect of image segmentation. Disadvantage: the actual image may contain weak edges, but the gray-scale changes do not have obvious numerical differences. If the selected threshold is too large, these weak edges may be eliminated.