Disclosure of Invention
The invention aims to provide an image threshold segmentation method and device based on a fuzzy set and Otsu, which are used for solving the problem of poor effect when the image segmentation is carried out by the conventional method.
In order to achieve the above object, the present invention provides an image threshold segmentation method based on a fuzzy set and Otsu, comprising:
the first method scheme comprises the following steps:
carrying out fuzzy enhancement processing on the original image by using a fuzzy algorithm;
carrying out normalization processing on the new image after enhancement processing;
respectively obtaining a threshold th1 of Renyi entropy and a threshold th2 of Otsu entropy;
respectively obtaining the between-class variance corresponding to the threshold th1 and the between-class variance corresponding to the threshold th 2;
calculating the weight S of the inter-class variance according to the threshold th1 and the inter-class variance corresponding to the threshold th21And the weight S corresponding to the Renyi entropy2;
Obtaining a segmentation threshold th ═ S1th2+S2th 1; and carrying out image segmentation according to the segmentation threshold th.
In the second method, based on the first method, the formula for determining the threshold th1 of Renyi entropy and the threshold th2 of Otsu entropy includes:
wherein th1 is a threshold of Renyi entropy; th2 is the Otsu threshold; eOThe Renyi entropy of the target domain of the original image is obtained; eBThe Renyi entropy of the background domain of the original image is obtained; l is the gray level of the original image; t is a gray threshold and t takes the value of [0, L-1 ]];w0Proportion of occurrence of gray scale of the first kind, w1Dividing the first class of gray scale and the second class of gray scale according to the gray scale threshold value t for the proportion of the second class of gray scale; sigma0Mean square error of gray scale, sigma, of the corresponding image for gray scale of the first type1The mean square error of the gray scale of the image corresponding to the second type of gray scale; and sigma is the gray level average value of the original image after the fuzzy enhancement and the normalization processing.
In the third method, on the basis of the first method or the second method, the process of calculating the inter-class variance includes:
inter-class variance σ of threshold th1 of Renyi entropy2And σ3Comprises the following steps:
between-class variance σ of threshold th2 of Otsu4、σ5Are respectively correspondingly represented as
Wherein p isiFor the number of pixel points being niProbability of occurrence of gray levels of (a); u. ofTL1 is 0, and L2 is L-1, which is the average value of the gray levels of the original image.
In the fourth method, on the basis of the third method, the process of calculating the weight of the inter-class variance includes:
wherein S is1Is the weight of the between-class variance, and S2=1–S1。
In the fifth embodiment, on the basis of the fourth embodiment, the normalization process includes:
adopting a min or max operator to extract edges;
cutting off the extracted edge data;
the truncation processing is as follows:
wherein, Tr (u)ij) Is the edge data; u. ofijIs a membership function in the fuzzy algorithm.
The invention also provides an image threshold segmentation device based on the fuzzy set and Otsu, which comprises the following steps:
the device scheme one comprises a processor and a memory, wherein the processor stores instructions for realizing the following method:
carrying out fuzzy enhancement processing on the original image by using a fuzzy algorithm;
carrying out normalization processing on the new image after enhancement processing;
respectively obtaining a threshold th1 of Renyi entropy and a threshold th2 of Otsu entropy;
respectively obtaining the between-class variance corresponding to the threshold th1 and the between-class variance corresponding to the threshold th 2;
calculating the weight S of the inter-class variance according to the threshold th1 and the inter-class variance corresponding to the threshold th21And the weight S corresponding to the Renyi entropy2;
Obtaining a segmentation threshold th ═ S1th2+S2th 1; and carrying out image segmentation according to the segmentation threshold th.
In the second device configuration, the formula for determining the threshold th1 of Renyi entropy and the threshold th2 of Otsu entropy includes:
wherein th1 is a threshold of Renyi entropy; th2 is the Otsu threshold; eOThe Renyi entropy of the target domain of the original image is obtained; eBThe Renyi entropy of the background domain of the original image is obtained; l is the gray level of the original image; t is a gray threshold and t takes the value of [0, L-1 ]];w0Proportion of occurrence of gray scale of the first kind, w1Dividing the first class of gray scale and the second class of gray scale according to the gray scale threshold value t for the proportion of the second class of gray scale; sigma0Mean square error of gray scale, sigma, of the corresponding image for gray scale of the first type1The mean square error of the gray scale of the image corresponding to the second type of gray scale; and sigma is the gray level average value of the original image after the fuzzy enhancement and the normalization processing.
In the third device solution, the process of finding the inter-class variance on the basis of the first device solution or the second device solution includes:
inter-class variance σ of threshold th1 of Renyi entropy2And σ3Comprises the following steps:
between-class variance σ of threshold th2 of Otsu4、σ5Are respectively correspondingly represented as
Wherein p isiFor the number of pixel points being niProbability of occurrence of gray levels of (a); u. ofTL1 is 0, and L2 is L-1, which is the average value of the gray levels of the original image.
In the fourth embodiment, on the basis of the third embodiment, the calculating of the weight of the inter-class variance includes:
wherein S is1Is the weight of the between-class variance, and S2=1–S1。
In the fifth embodiment, on the basis of the fourth embodiment, the normalization process includes:
adopting a min or max operator to extract edges;
cutting off the extracted edge data;
the truncation processing is as follows:
wherein, Tr (u)ij) Is the edge data; u. ofijIs a membership function in the fuzzy algorithm.
The invention has the beneficial effects that: firstly, a new fuzzy enhancement membership function is given based on a fuzzy set; then, constructing the between-class variance of Otsu by using a discretization method of mean square error; and finally, combining a Renyi entropy theory, introducing a Renyi entropy of the image obtained by weight calculation, and completing image segmentation by using a threshold value of the maximum Renyi entropy. Compared with the traditional threshold segmentation algorithm, the method has better advantages in the accuracy of segmentation edges and the robustness to noise, has good stability and segmentation effect, and can effectively improve the precision of image segmentation.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings.
In order to solve the problems that the traditional Otsu algorithm has an unobvious and inaccurate image segmentation effect on images containing noise and uneven illumination, a fuzzy set and Otsu-based image threshold segmentation method and device are provided. Firstly, a new fuzzy enhancement membership function is given based on a fuzzy set; then, constructing the between-class variance of Otsu by using a discretization method of mean square error; and finally, combining a Renyi entropy theory, introducing a Renyi entropy of the image obtained by weight calculation, and completing image segmentation by using a threshold value of the maximum Renyi entropy.
According to the concept of blur set, an image with size of M × N and gray level of L can be expressed as an M × N blur matrix as follows:
wherein each element in the matrix
Representing the gray scale x of a pixel (i, j) in an image
ijThis is a problem for finding the blur distribution with respect to the degree of membership of the corresponding gray level x in the original image. Among the classical fuzzy enhancement algorithms, Pal and King propose a fuzzy enhancement algorithm in which the membership functions used are:
wherein the parameter Fd、FeAnd uijCan be determined by the transition point. In general, take Fe2 to yield uijThen, the image is subjected to fuzzy enhancement processing by adopting the following transformation:
uij=Tr(uij)=T1(Tr-1(uij)) (3)
wherein r is 1,2, ….
When u isij>At 0.5, u is increasedijA value of (d); when u isijWhen u is less than or equal to 0.5, u is reducedijThe value of (c). For u is pairedijInverse transformation is performed, and after blur enhancement, the gray value of the pixel (i, j) in the image X ', X' is obtained:
xij=T-1(uij) (5)
wherein, T-1(. cndot.) is the inverse operation of T (. cndot.) in equation (2).
The Ostu method is based on a gray level histogram of an image, and selects a criterion according to the maximum between-class variance of a target and a background. The basic idea is as follows: let L gray levels in total for the original gray image, the number of pixel points in a certain gray level is niAnd the total pixel of the image is N, the probability of each gray level occurrence can be obtained:
in image segmentation, the gray levels are divided into two classes according to the gray level of the image by using a threshold value t, namely C0Class (gray scale of 0,1,2, …, t) and C1Class (gray level t +1, t +2, …, L-1), the range of t is determined by the normalization process, and the initial value of t is the corresponding minimum value in the case where a gray level exists (the probability of occurrence of a gray level is not equal to 0). C0And C1The proportions appearing are respectively:
thus, C0Mean sum C1The mean values are respectively:
the average value of the gray levels of the whole image is:
therefore, the between-class variance is:
σB2=ω0(u0-uT)2+ω1(u1-uT)2 (12)
let t take a value between [0, L-1 ], and the threshold value that maximizes the distance between two parts of the image is the optimal threshold value of the Otsu method, and its expression:
first, improved blur enhancement
Let an image be X with size of M N, gray level of L, and maximum gray level of L-1, XijRepresenting the gray value of the (i, j) th pixel of the image, the new membership function can be defined as:
the following enhancement processing is performed on the image using repeated recursive calls:
uij=Tr(uij)=Tr(Tr-1(uij)) (15)
wherein r is 1,2, …, ∞.
Through multiple regression calling, operator Tr(uij) The larger membership value is enhanced and the smaller membership value is suppressed.
And (6) normalization processing. Adopting 'min' or 'max' operator to extract edge, and extracting 'edge' data Tr(uij) Performing truncation processing:
by the truncation process of equation (17), the image data can be converted from the blur domain to the spatial domain of the image, i.e., the grayscale domain of the image.
In order to verify the effectiveness of the improved fuzzy enhancement on image segmentation, a Lena image is selected and enhanced by respectively adopting a Pal-King method in the traditional fuzzy enhancement and an improved fuzzy enhancement method of the invention. The simulation experiment results are shown in fig. 2-4. The image enhancement effect of the method of the invention iterated 1 time in fig. 4 is better than that of the Pal-King method iterated 2 times in fig. 3. The improved fuzzy enhancement processing reserves the edge information of low gray values in the image, further reserves the integrity of the image information, and is beneficial to the next image segmentation.
Entropy of two, Renyi
Entropy is the basic method for describing uncertainty factors in information theory, and the boundary distribution of images is the most uncertain. Thus, the entropy at the boundary between the object and the background in the image is the largest (the amount of information is the largest), which reflects the overall outline of the image. The basic concept of Renyi entropy is given below: the probabilities of the object O and the object B are respectively set as:
and has PO(t)+PB(t) 1. The Renyi entropies corresponding to the image target domain and the background domain may thus be defined as:
the Renyi entropy of the image population is defined as:
where α >0, α is a parameter set to 0.7.
According to the threshold selection principle of maximum entropy image segmentation, a certain threshold t can make equation (22) obtain the maximum value, and then it is the optimal segmentation threshold, that is:
third, improved Otsu model
In general, the gray scales in different objects are relatively uniform, the gray scale variation of pixels distributed at the boundary between the objects and in the vicinity thereof is generally large, and the mean square difference value can represent the degree of the dispersion of the gray scales, that is, the uniformity of the gray scale distribution. Therefore, the gray scale change of the boundary can be approximately reflected by the mean square difference value of the image.
Given image C0、C1Mean square error of gray scale σ0、σ1Respectively expressed as:
the average gray level of the whole image after processing is expressed as:
the between-class variance is expressed as:
σB12=w0(σ0-σ)2+w1(σ1-σ)2 (27)
substituting the threshold t calculated by the Renyi entropy method into the formulas (24) and (25), calculating the variance of the threshold t as sigma22And σ32The image can be segmented into two objects:
wherein, L1 is 0, and L2 is L-1.
The weight corresponding to the threshold calculated by the maximum between-class variance method is represented as:
the weight corresponding to the threshold value of the Renyi entropy calculation is 1-S1。
The method of the invention combines Renyi entropy and an improved Otsu model, and provides an image threshold segmentation algorithm (FSO-ITS) based on a fuzzy set and Otsu, as shown in FIG. 1, and the specific steps are described as follows:
step 1: inputting an original image;
step 2: applying a new membership function to carry out fuzzy enhancement processing on the original image;
and step 3: carrying out normalization processing on the enhanced image;
and 4, step 4: respectively solving threshold values th1 and th2 of Renyi entropy and improved Otsu;
and 5: separately determine the between-class variance σ of th12And σ3And th2 inter-class variance σ0And σ1;
Step 6: taking the ratio of the between-class variance of th2 and the total between-class variance as a weight S;
and 7: and calculating a threshold value th when the sum of the Renyi entropy and the inter-class variance of the image reaches the maximum by using the weight, and finally segmenting the image.
The steps comprise the following formula:
fourth, experimental results and analysis
An experiment platform: pentium4 CPU3.0GHz's dual-core PC, the memory is 2GB, operating system is Windows7, the operational environment is Matlab7.0.
The conventional Otsu algorithm (Otsu N.A. threshold selection method from level gradients, J. IEEE Transactions on Systems, Man, and Cybernetics,1979,9(1):62-66.), Renyi entropy algorithm (Jizba P, Arimitsu T.Observability of Renyi's entry, J. Physical Review E,2004,69(2):026128.) and the FSO-ITS algorithm of the present invention were selected for experimental comparison and analysis.
To analyze and verify the actual effect of the proposed improved algorithm, a standard 256 × 256 pixel image Cameraman was taken experimentally, as shown in fig. 5. The original image is first subjected to blur enhancement processing like fig. 5, and the result is shown in fig. 6. Then, the processed image is segmented by using the conventional Otsu algorithm and the FSO-ITS algorithm, respectively, and the segmentation results are shown in fig. 7 and fig. 8, respectively. Fig. 9 is a histogram of an original image.
It can be seen from fig. 7 and 8 that the image obtained by the FSO-ITS algorithm segmentation has better denoising effect and clearer edge compared with the traditional Otsu algorithm. To further verify the effectiveness of the FSO-ITS algorithm, another standard image Goldhill with 512 pixels was selected and the experiment was continued, as shown in fig. 10. Fig. 11 shows the result of the blur enhancement, the segmentation effect is shown in fig. 12 and fig. 13, respectively, and fig. 14 is a histogram of the original image.
Analysis shows that the image segmented by the FSO-ITS algorithm ideally separates a target area and a background area of an original image and can fully reflect the edge contour of the image.
And then objectively analyzing the superiority of the method by using evaluation criteria such as an image segmentation threshold, a peak signal-to-noise ratio (PSNR) and information entropy. The peak signal-to-noise ratio is calculated statistically and averagely based on the gray value of the image pixel, and is a commonly used index for measuring signal distortion. Generally, the larger the PSNR, the better the image quality. The formula for PSNR given below is as follows:
where MSE is the mean square error between the pre-encoded and post-decoded pictures. The results of the peak signal-to-noise ratio experiments for the 3 algorithms are presented in table one below.
TABLE comparison of experimental results for peak signal-to-noise ratio for 3 algorithms
As can be seen from the table I, the PSNR of the FSO-ITS algorithm provided by the invention is the maximum, which means that the distortion of the algorithm is the minimum, and the original information of the image is most effectively preserved. The experimental results were analyzed for information entropy as follows. Entropy of image information is a statistical form of a feature. The method reflects the information content of the image, and the larger the information entropy value of the segmented image is, the larger the information content of the image obtained from a source image is, the richer the details of the segmented image are, and the better the total effect of the segmentation is. The formula of the information entropy h (x) is expressed as follows:
information entropy experimental result comparison of two 3 algorithms in table
As can be seen from the second table, the information entropy of the FSO-ITS algorithm provided by the invention is the largest, which means that the algorithm obtains the largest amount of information from the source image, the edge of the segmented image is more complete, and the image segmentation precision is effectively improved.
As can be seen from the experimental results of the table I and the table II, compared with the traditional Otsu algorithm, the FSO-ITS segmentation method has the advantages of better segmentation effect, continuous and complete edge and better detail processing; compared with the traditional Otsu algorithm and the Renyi entropy algorithm REA, the peak signal-to-noise ratio and the information entropy of the FSO-ITS are maximum, the image distortion is minimum, and the segmentation precision is highest.
The present invention is not limited to the described embodiments, for example, other forms of fuzzy membership functions or specific parameter settings are used, and the technical solution formed by fine tuning the above embodiments still falls within the protection scope of the present invention.