Two-dimensional maximum entropy threshold segmentation principle and OPENCV implementation

Source: Internet
Author: User
Tags scale image
Two-dimensional maximum entropy principleRecently, in the study of gray scale segmentation of image processing, it is found that there are many articles and program codes that divide one-dimensional maximum entropy threshold, but the resource of two-dimensional maximum entropy is relatively small. So the purpose of this blog is that, in the process of learning to record the relevant notes, in order to help the back of the researchers to take a few detours. We hope to make progress together and improve together. 1, based on two-dimensional maximum entropy threshold segmentationThresholding is an important technique in image segmentation. Most of the existing methods use a one-dimensional grayscale histogram of the image to select a threshold value. However, when the signal-to-noise ratio of images decreases, the use of these methods will result in many segmentation errors. In recent years, there have been some methods to use the histogram of the image's two-dimensional gray-scale histogram ——— the gray-scale value distribution of the pixels and the distribution of the average gray value in the neighborhood to divide the threshold. The results of these methods are better than the traditional methods because of the gray information of the image and the space-related information of the neighborhood. 1.1 Two-dimensional histogramUsually, the image can be regarded as a two-dimensional gray function, which contains nxn pixel points, g={0, 2,⋯, L-1} is a range of gray values, here l=256. Defined in
The gray value of the coordinates (x, y) pixels is f (x, y). Set T∈g to a split threshold, the result of the gray value T threshold for the image function f (x, y) is the two value function ft (x, y):
FT (x, y) =
B0 f (x, y) ≤t
B1 f (x, y) > # T
(1)
Among them: 0≤b0, T, B1≤l-1. The two-dimensional thresholding method considers both the gray value of pixels and the average gray value of its neighborhood. The average gray value of the NxN neighborhood at pixels (x, y) is: n≤n, n is usually odd, [N2] means rounding, this article takes n=3. A two-dimensional histogram is constructed from the original image and the smoothed image by averaging another "smoothed image" on the adjacent field. Because the correlation between image pixels and their neighborhood pixels is quite large, the distribution of objects and backgrounds in a two-dimensional histogram is more easily distinguishable than in one-dimensional histograms. In general, two-dimensional histograms are characterized by bimodal or multi-peaks. such as grayscale, neighborhood average gray value pairs [f (x, Y), g (x, y)] to represent the image, and a two-dimensional vector (S, T) to split the image, here, 0≤s, T≤l-1. The two-dimensional thresholding function can be defined as: {PIJ} is a two-dimensional grayscale histogram of the image, as shown in the figure. Its starting point is in the upper left, the gray value is increased from left to right, and the neighborhood average gray value is top-down
Increase. There are L2 points on two-dimensional histogram, and the function value of each point is Rij. If the image segmentation threshold vector is (S, T), then the histogram is divided into 4 blocks, according to the homomorphism
, in the target and background, the gray value of pixels and the average gray value of the neighborhood are close to each other, and the gray value of the pixel differs greatly from the neighborhood average gray value in the boundary neighborhood of the target and the background. Therefore, the pixels in the target and background will appear around the diagonal, so blocks 0 and 1 contain the distribution of the target class and the background class; Blocks 2 and 3 away from the diagonal, corresponding to edges and noise.

Basic idea: Using the two-dimensional histogram of point gray level and regional gray mean, the best threshold value is found according to the maximum entropy principle.

Practice: First, the original grayscale image (L gray level) of each pixel and its 4 neighborhood group as a region, the calculation of the regional gray-scale image (L gray scale), so that each pixel in the original image corresponds to a point gray-area gray-level mean pairs, such data on the existence of LX L kinds of possible values.

Set N i,j for the image midpoint grayscale to I and its region gray mean value is J the pixel points, P i,j to point grayscale - the regional gray-scale mean value pairs (i,j) The probability of occurrence, then

then {pi,j,i,j=0,1,...... L-1} is the two-dimensional histogram of the image about the gray-area gray-scale of the point.

Conclusion: 1. Under the interference of strong noise, the one-dimensional histogram is single-peak, and the two-dimensional histogram uses the relevant information of the neighborhood of the image, and the Shuangfeng of the target and background are still obvious.

2. The probability peaks of point gray-area gray mean appear mainly near the diagonal of the Xoy plane, and present the state of Shuangfeng and a valley in general;

This is due to the image of all the pixels, the target point and the background of the largest proportion, and the target region and the background area of the pixel gray level is relatively uniform, the point gray scale and its regional gray scale difference is not small, so all concentrated in the diagonal, two peaks are corresponding to the target and background; away from the coordinates of the Xoy plane diagonal The height of the peaks drops sharply, which reflects the noise points, edge points, and spurious points in the image.

3. The optimal threshold value should be determined by the two-dimensional maximum entropy method of point gray-area gray-scale in Area A and B, so that the amount of information that truly represents the target and background is greatest. This is due to the image of all the pixels, the target point and the background of the largest proportion, and the target region and the background area of the pixel gray level is relatively uniform, the point gray scale and its regional gray scale difference is not small, so all concentrated in the diagonal, two peaks are corresponding to the target and background; away from the coordinates of the Xoy plane diagonal The height of the peaks drops sharply, which reflects the noise points, edge points, and spurious points in the image.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.