A method for image segmentation based on nonlinear scale space
Through the nonlinear scale space method based on KAZE features, the nonlinear filtering kernel function and the maximum inter-class variance method are used to solve the problem of being unable to distinguish uniformity and edges in linear scale space, and improve the accuracy and detail retention of image segmentation.
Patent Information
- Application Number
- CN202111444114.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In the existing technology, linear scale space cannot effectively distinguish uniform areas and edge areas in images, resulting in the loss of high-frequency information and affecting the accuracy of image segmentation.
The nonlinear scale space method based on KAZE features is used to perform global threshold processing through nonlinear filtering and iterative algorithms, combined with the maximum inter-class variance method for image segmentation, and nonlinear filtering kernel functions such as bilateral filtering and nonlinear diffusion filtering are used to retain high frequency edge information and distinguish uniform areas.
It effectively increases the accuracy of image recognition, provides more detailed gray value comparison, improves the effect of image segmentation, and solves the problem of losing local details in linear scale space.
Smart Images

Figure CN114240988B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image segmentation, and in particular to an image segmentation method based on nonlinear scale space. Background Art
[0002] In reality, objects present different expressions depending on the distance from the observer. For example, the human eye perceives objects differently at different scales. When the distance is far, the main contour area is observed, and more detailed information is observed at a close distance. In the case of large-scale parameters, high-frequency information is seriously lost, and the main outline information is displayed. The details of the high-frequency band are called significant features in the image. High-frequency information is easy to find and identify in the visual field, and can be used for tasks such as feature extraction and target recognition. This is the effect brought about by different scales. The basic idea that multi-scale technology in computer vision wants to express is that the fuzzy contour shape of the image at a large scale is a sampling of the contour shape of the image at a small scale. The scale space can well simulate the situation of human eyes observing things, so it is well used in the field of computer vision. The methods of constructing scale space are mainly divided into two categories: linear scale space and nonlinear scale space. Scale space is constructed.
[0003] The main difference between linear and nonlinear scale space lies in the difference in filter kernel functions. The main kernel function in linear scale space is the Gaussian kernel function: its calculation is simple and efficient, and the Gaussian kernel function is the only scale-invariant kernel function. However, the main disadvantage of the Gaussian function is that it cannot effectively distinguish between uniform areas and edge areas, which are all the same filter scale, resulting in the loss of a large number of local details. Summary of the invention
[0004] In view of the shortcomings of the prior art, the present invention provides an image segmentation method based on nonlinear scale space, which has the advantage of being able to effectively segment images and solves the problem of being unable to effectively distinguish images.
[0005] In order to achieve the above-mentioned purpose of effectively segmenting an image, the present invention provides the following technical solution, an image segmentation method based on a nonlinear scale space, the steps are as follows:
[0006] S1: Construct nonlinear scale space based on KAZE features;
[0007] S2: Perform nonlinear filtering on the input image using the KAZE algorithm, then calculate the gradient histogram of the image to obtain the contrast parameter k, and use the additive molecular splitting algorithm to obtain all images in the nonlinear scale space based on a set of evolution times t;
[0008] S3: Smoothing the image obtained in S2, and performing global threshold processing using an iterative algorithm, and then using edge-improved global threshold processing to perform preliminary segmentation of the object and background in the image based on the improved threshold;
[0009] S4: Contrast the object and the background. When the contrast between the object and the background is not uniform in the image, the threshold is obtained by the maximum inter-class variance method according to the local features of the image and the image is segmented.
[0010] As an optimization, in S3, the iterative algorithm performs global threshold processing, and the steps are as follows:
[0011] S301: Count the grayscale histogram of the image and find the maximum grayscale value and the minimum grayscale value of the image, which are recorded as Z MAX and Z MIN , let the initial threshold T0 = (Z MAX +Z MIN ) / 2, the number of iterations K = 1;
[0012] S302: Based on the Kth iteration threshold T K Segment the image into foreground and background, and calculate the mean Z of all gray levels less than T0 A , and the mean Z of all gray levels greater than T0 B ;
[0013] S303: Calculate a new threshold value T K+1 =(Z A +Z B ) / 2;
[0014] S304: If T K and T K+1 The difference between them is less than the predefined parameter ΔT, then the obtained T K+1 That is, the final threshold of the iteration. Otherwise, the number of iterations K is increased by 1, and the process goes to S302 to continue the iterative calculation.
[0015] As an optimization, in S3, the edge is used to improve the global threshold processing, and the steps are as follows:
[0016] S311: Calculate the edge image of f(x, y) using a feature detection method; wherein f(x, y) represents the image after KAZE feature processing;
[0017] S312: Setting a threshold T t ;
[0018] S313: Use the threshold in S312 to perform threshold processing on the image in S311 to generate a binary image g T (x,y);
[0019] S314: Calculate the histogram only using the pixels in f(x, y) corresponding to the positions where the pixel values in g T (x, y) are 1.
[0020] Furthermore, in the said S4, the threshold is obtained by the Otsu method, specifically including:
[0021] Calculate the normalized histogram of the input image, using p i , i = 0, 1, 2, …, L - 1 to represent each component of the histogram, p i represents the probability that the gray level of the pixel is i, and L represents L different gray levels; calculate the cumulative sum P i (k), the cumulative mean m(k); calculate the global gray value m G , calculate the between-class variance σ 2 B (k);
[0022] Make the gray level k that maximizes the between-class variance σ 2 B (k) be the Otsu threshold k * , if the maximum value is not unique, then use the average value of each maximum value k to obtain k * ; calculate the separability measure η * at k * .
[0023] Furthermore, assume that there are MxN pixels in the input image, L different gray levels, and n i represents the number of pixels with gray level i; the total number of pixels MN in the image is MN = n0 + n1 + n2 + … + n L-1 ; each component of the histogram satisfies:
[0024]
[0025] The components p of the normalized histogram i = n i / MN.
[0026] Furthermore, in the said S4, the threshold k * , 0 < k * < L - 1 is obtained by the Otsu method, and the image processed by S3 is thresholded into two classes C1 and C2 using this threshold, where C1 consists of all pixels in the image with gray values in the range [0, k * , and C2 consists of all pixels with gray values in the range [k * +1, L - 1].
[0027] Furthermore, in the said S4, the calculation formula of the between-class variance is:
[0028]
[0029] Where σ 2 B is the inter-class variance, p1 is the probability that the pixel of histogram component P1 is assigned to class C1; p2 is the probability that the pixel of histogram component P2 is assigned to class C2; m1 is the average gray value of the pixels assigned to class C1; m2 is the average gray value of the pixels assigned to class C2; m g is the average gray value of the entire image.
[0030] Furthermore, in S4, the separated image expression is:
[0031]
[0032] Where f(x,y) represents the image after KAZE feature processing.
[0033] The beneficial effect of the present invention is that: since the nonlinear filter kernel function used when constructing the nonlinear scale space is mainly bilateral filtering and nonlinear diffusion filtering, the nonlinear filter function mainly solves the problem that the Gaussian filter used when constructing the linear scale space cannot effectively distinguish the judgment problem between uniformity and edges. Therefore, the nonlinear filter kernel function can retain more high-frequency edge information while filtering the uniform area, solving the problem that the uniform area and the edge area cannot be effectively distinguished in the linear scale space, and a large number of local details are lost under the same filter scale conditions, and can effectively increase the accuracy of image recognition, and also provide more detailed gray value comparison for image segmentation, which is beneficial to image segmentation. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a schematic diagram of the process of the present invention. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0036] The image segmentation method based on nonlinear scale space described in the present invention is as follows: Figure 1 As shown, the steps are as follows:
[0037] S1: Construct a nonlinear scale space based on KAZE features.
[0038] S2: The input image is nonlinearly filtered using the KAZE algorithm, and then the gradient histogram of the image is calculated to obtain the contrast parameter k. According to a set of evolution times t, the additive molecular splitting (AOS) algorithm is used to obtain all images in the nonlinear scale space.
[0039] S3: Smooth the image obtained in S2, perform global threshold processing using an iterative algorithm, and then use edge-improved global threshold processing to perform preliminary segmentation of objects and background in the image based on the improved threshold.
[0040] The iterative algorithm performs global threshold processing, and the steps are as follows:
[0041] S301: Count the grayscale histogram of the image and find the maximum grayscale value and the minimum grayscale value of the image, which are recorded as Z MAX and Z MIN , let the initial threshold T0 = (Z MAX +Z MIN ) / 2, the number of iterations K = 1;
[0042] S302: Based on the Kth iteration threshold T K Segment the image into foreground and background, and calculate the mean Z of all gray levels less than T0 A , and the mean Z of all gray levels greater than T0 B ;
[0043] S303: Calculate a new threshold value T K+1 =(Z A +Z B ) / 2;
[0044] S304: If T K and T K+1 The difference between them is less than the predefined parameter ΔT, then the obtained T K+1 That is, the final threshold of the iteration. Otherwise, the number of iterations K is increased by 1, and the process goes to S302 to continue the iterative calculation.
[0045] Using edge to improve global threshold processing, the steps are as follows:
[0046] S311: Calculate the edge image of f(x, y) using a feature detection method; wherein f(x, y) represents the image after KAZE feature processing;
[0047] S312: Setting a threshold T t ;
[0048] S313: Use the threshold in S312 to perform threshold processing on the image in S311 to generate a binary image g T (x,y);
[0049] S314: Use only the values in f(x,y) corresponding to g T Compute the histogram of the pixels at (x,y) where the pixel value is 1.
[0050] After smoothing and segmenting, the boundary between the object and the background will be distorted due to the blurring of the boundary. The more an image is smoothed, the greater the boundary error in the segmented result.
[0051] S4: Contrast the object and the background. When the contrast between the object and the background is not uniform in the image, the threshold is obtained by the maximum inter-class variance method (Otsu method) according to the local features of the image and the image is segmented.
[0052] The threshold is obtained by the maximum inter-class variance method, including:
[0053] Calculate the normalized histogram of the input image using p i , i=0,1,2,…,L-1 represents the components of the histogram, p i represents the probability that the gray level of the pixel is i, L represents L different gray levels; calculate the cumulative sum P of each component i (k), cumulative mean m(k); calculate the global gray value m G , calculate the between-class variance σ 2 B (k);
[0054] Let the between-class variance σ 2 B (k) The maximum gray level k is the Otsu threshold k * If the maximum value is not unique, the average value of each maximum value k is used to get k * ; in k * The separability measure η is calculated at * .
[0055] Assume that there are MxN pixels in the input image, L different gray levels, n i Represents the number of pixels with gray level i; the total number of pixels in the image is MN = n0 + n1 + n2 + ... + n L-1 ; The components of the histogram satisfy:
[0056]
[0057] Normalized histogram components p i =n i / MN.
[0058] The threshold k is obtained by the maximum inter-class variance method * ,0 <k *<L - 1, and threshold the image processed in S3 into two classes C1 and C2 using this threshold, where C1 consists of all pixels in the image with gray values in the range [0, k * , and C2 consists of all pixels with gray values in the range [k * + 1, L - 1].
[0059] The formula for the between - class variance is:
[0060]
[0061] In the formula is the between - class variance, p1 is the probability that the pixels of the histogram component P1 are assigned to class C1; p2 is the probability that the pixels of the histogram component P2 are assigned to class C2; m1 is the average gray value of the pixels assigned to class C1; m2 is the average gray value of the pixels assigned to class C2; m g is the average gray value of the entire image.
[0062] The image separation expression is:
[0063]
[0064] In the formula, f(x, y) represents the image processed with KAZE features.
[0065] Since when constructing the non - linear scale space, the non - linear filtering kernel functions used are mainly bilateral filtering and non - linear diffusion filtering, etc. The non - linear filtering function mainly solves the problem that the Gaussian filtering used when constructing the linear scale space cannot effectively distinguish the judgment of the uniform area and the edge. Therefore, while the non - linear filtering kernel function can retain more high - frequency edge information, it can also filter the uniform area, solving the problem that in the linear scale space, it is impossible to effectively distinguish the uniform area and the edge area, and a large amount of local details are lost under the same filtering scale condition. It can effectively increase the accuracy of image recognition and also provide a more detailed comparison of gray values for image segmentation, which is beneficial to image segmentation.
[0066] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution and inventive concept of the present invention, makes equivalent substitutions or changes, and all should be covered by the protection scope of the present invention.
Claims
1. An image segmentation method based on nonlinear scale space, It is characterized in that The steps of this method are as follows: S1: Construct nonlinear scale space based on KAZE features; S2: Perform nonlinear filtering on the input image using the KAZE algorithm, then calculate the gradient histogram of the image to obtain the contrast parameter k, and use the additive molecular splitting algorithm to obtain all images in the nonlinear scale space based on a set of evolution times t; S3: Smoothing the image obtained in S2, and performing global threshold processing using an iterative algorithm, and then using edge-improved global threshold processing to perform preliminary segmentation of the object and background in the image based on the improved threshold; The iterative algorithm is used for global threshold processing. The steps are as follows: S301: Count the grayscale histogram of the image and find the maximum grayscale value and the minimum grayscale value of the image, which are recorded as Z MAX and Z MIN , let the initial threshold T 0 =(Z MAX +Z MIN ) / 2, the number of iterations K = 1; S302: Based on the Kth iteration threshold T K Segment the image into foreground and background, and calculate the time less than T 0 The mean value Z of all gray levels A , and greater than T 0 The mean value Z of all gray levels B ; S303: Calculate a new threshold value T K+1 =(Z A +Z B ) / 2; S304: If T K and T K+1 The difference between them is less than the predefined parameter ΔT, then the obtained T K+1 This is the final threshold of the iteration, otherwise the number of iterations K increases by 1, and the process goes to S302 to continue the iterative calculation; Using edge to improve global threshold processing, the steps are as follows: S311: Calculate the edge image of f(x, y) using a feature detection method; wherein f(x, y) represents the image after KAZE feature processing; S312: Setting a threshold T t ; S313: Use the threshold in S312 to perform threshold processing on the image in S311 to generate a binary image g T (x,y); S314: Use only the values in f(x,y) corresponding to g T The histogram is calculated for the pixels at the position where the pixel value is 1 in (x, y); S4: Contrast the object and the background. When the contrast between the object and the background is not uniform in the image, the threshold is obtained by the maximum inter-class variance method according to the local features of the image and the image is segmented.
2. The image segmentation method based on nonlinear scale space according to claim 1, Features: In S4, the threshold is obtained by the maximum inter-class variance method, which specifically includes: Calculate the normalized histogram of the input image using p i , i=0,1,2,…,L-1 represents the components of the histogram, p i represents the probability that the gray level of the pixel is i, L represents L different gray levels; calculate the cumulative sum P of each component i (k), cumulative mean m(k); calculate the global gray value m G , calculate the between-class variance σ 2 B (k); Let the between-class variance σ 2 B (k) The maximum gray level k is the Otsu threshold k * If the maximum value is not unique, the average value of each maximum value k is used to get k * ; in k * The separability measure η is calculated at * .
3. The image segmentation method based on nonlinear scale space according to claim 2, Features: Assume that there are MxN pixels in the input image, L different gray levels, n i Represents the number of pixels with gray level i; The total number of pixels in the image is MN = n 0 +n 1 +n 2 +…+n L-1 ; The components of the histogram satisfy: Normalized histogram components p i =n i / MN.
4. The image segmentation method based on nonlinear scale space according to claim 3, Features: In the step S4, the threshold k is obtained by the Otsu method. * , 0 < k * < L - 1, and the image processed in the step S3 is thresholded into two classes C 1 and C 2 , where C 1 is composed of all pixels with gray values in the range [0, k * , and C2 is composed of all pixels with gray values in the range [k * +1, L - 1].
5. The image segmentation method based on nonlinear scale space according to claim 4, Features: In S4, the calculation formula of the between-class variance is: Where σ 2 B is the between-class variance, p 1 is the histogram component P 1 The pixels are classified into class C 1 The probability of 2 is the histogram component P 2 The pixels are classified into class C 2 The probability of 1 For assignment to class C 1 The average gray value of the pixels; m 2 For assignment to class C 2 The average gray value of the pixels; m g is the average gray value of the entire image.
6. The image segmentation method based on nonlinear scale space according to claim 5, Features: In S4, the separated image expression is: Where f(x,y) represents the image after KAZE feature processing.
