Image segmentation method, electronic device, and computer-readable storage medium
By using the iterative update method of the initial level set function in image segmentation, combined with the mean filter and the softsign activation function, the problem of low accuracy in grayscale uneven image segmentation is solved, and efficient segmentation effects and noise robustness are achieved.
Patent Information
- Application Number
- PCT/CN2023/089370
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-15
- Filing Date
- 2023-04-20
- Publication Date
- 2024-09-19
AI Technical Summary
Existing active contour models are not effective in segmenting images with uneven grayscale and cannot effectively distinguish false targets, resulting in low segmentation accuracy.
The initial level set function is used for iterative update, the segmentation curve is smoothed by the mean filter, and the softsign activation function is used to keep the level set function negative in the contour and inside and positive outside, replacing the length term and distance rule term in the traditional model.
It achieves ideal segmentation effects on uneven grayscale images, improves segmentation speed and accuracy, and shows robustness to noise.
Smart Images

Figure CN2023089370_19092024_PF_FP_ABST
Abstract
Description
Image segmentation method, electronic device, and computer-readable storage medium Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an image segmentation method, electronic equipment, and computer-readable storage medium. Background Art
[0002] Image segmentation is an important research topic in the field of image processing. It divides an image into several non-overlapping regions and extracts targets of interest (such as foreground and background) from them, laying the foundation for subsequent image target recognition and feature analysis.
[0003] Active contour models are the most representative image segmentation methods of recent decades and a current research hotspot. The basic idea behind active contour models is to set an initial contour line on an image and use an energy function based on the level set method to drive the contour line's evolution, causing it to approach the object boundary and achieve segmentation. This type of algorithm can achieve sub-pixel accuracy of the object boundary, providing a smooth, closed contour as the segmentation result.
[0004] The current mainstream active contour model has the following technical problems: it is not effective in segmenting local areas with uneven grayscale and cannot distinguish some false objects in the image. Therefore, there is an urgent need for a new image segmentation method to solve these problems.
[0005] Summary of the Invention
[0006] Therefore, the technical problem to be solved by the present invention is to provide an image segmentation method that can effectively segment grayscale uneven images and has high segmentation accuracy.
[0007] To solve the above technical problems, the present invention provides an image segmentation method, which includes the following steps:
[0008] S1. Setting an initial contour line in the target image and expressing the initial contour line using an initial level set function;
[0009] S2. Update and iterate the initial level set function; the level set function at the nth iteration is:
[0010] in, is a mean filter with a window size of k×k; softsign is the softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt is the time step;
[0011] S3. Use the level set function obtained in the last iteration as the segmentation curve of the target image.
[0012] In one embodiment of the present invention, the gradient descent equation at the n-1th iteration is:
[0013] U(φ(x, n-1))=-αS′(φ(x, n-1))softsign((d1(x, n-1)-d2(x, n-1)) / β), where α is a constant; β is the standard deviation of the target image grayscale; function S′(z) is the function The derivative function of is the data driven item, y is the vector pixel point in the target image, θ y is a square neighborhood with y as the center and a side length of 4σ+1, is the Gaussian kernel function, σ is the standard deviation of the Gaussian kernel function, and a is the The normalization constant of ; I(x) is the true gray value of the target image; To calculate the shadow value of the fitted image, is a mean filter with a window size of 2w+1, w is a constant, and * is a convolution operation; is the edge reflection structure information value at the n-1th iteration; when i=1, is the region θ y The edge reflection structure information value in ∩Ω1, When i=2, is the region θ y The edge reflection structure information value in ∩Ω2, Ω1 is the outer area of the contour line, and Ω2 is the contour line and the inner area of the contour line.
[0014] In one embodiment of the present invention, the standard deviation of the target image grayscale is:
[0015] Where Ω is the image domain of the target image; Q is the total number of pixels in the target image; is the average gray value of the target image.
[0016] In one embodiment of the present invention, the initial level set function is:
[0017] In one embodiment of the present invention, step S3 includes:
[0018] When |φ(x, n)-φ(x, n-1)|<ε, the iteration is stopped, and the level set function obtained from the last iteration is used as the segmentation curve of the target image; where ε is a constant.
[0019] In one embodiment of the present invention, the value range of ε is [0.001, 0.0001].
[0020] In one embodiment of the present invention, the value range of Δt is [0.5, 2].
[0021] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above methods when executing the program.
[0022] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above methods when executed by a processor.
[0023] The present invention also provides an image segmentation system, which includes the following modules:
[0024] An initial level set module, configured to set an initial contour line in a target image and represent the initial contour line using an initial level set function;
[0025] The iteration module is used to update and iterate the initial level set function; the level set function at the nth iteration is:
[0026] in, is a mean filter with a window size of k×k; softsign is the softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt is the time step;
[0027] The segmentation curve determination module is used to use the level set function obtained in the last iteration as the segmentation curve of the target image.
[0028] The above technical solution of the present invention has the following advantages over the prior art:
[0029] The image segmentation method of the present invention sets an initial level set function and then uses an optimized level set function to update the discrete level set function at each iteration. A mean filter replaces the length term in the traditional active contour model to smooth the segmentation curve. An activation function replaces the distance rule term in the traditional active contour model to ensure that the level set function maintains the rule that negative values on and within contours and positive values outside contours during the iteration process. This achieves ideal segmentation results for images with uneven grayscale, while offering advantages in both segmentation speed and accuracy.
[0030] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below based on specific embodiments of the present invention in conjunction with the accompanying drawings, wherein
[0032] FIG1 is a flow chart of an image segmentation method according to an embodiment of the present invention;
[0033] FIG2 is a schematic diagram of an image segmentation method according to an embodiment of the present invention;
[0034] 3 is a schematic diagram of segmenting an image with uneven grayscale using an image segmentation method according to an embodiment of the present invention;
[0035] FIG4 is a schematic diagram showing the robustness of the image segmentation method to noise according to an embodiment of the present invention;
[0036] FIG5 is a schematic diagram showing a comparison of image segmentation using different models according to an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The present invention will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention.
[0038] Example 1
[0039] 1 , this embodiment discloses an image segmentation method, which includes the following steps:
[0040] Step S1, setting an initial contour line in the target image, and using an initial level set function to represent the initial contour line;
[0041] Specifically, referring to Figure 2, for the target image I, its continuous image domain is Ω, x and y are vector pixels in the image domain Ω, and an initial contour line C0 is set. The image domain Ω is divided into two sub-regions Ω1 and Ω2, where Ω1 represents the outer region of the initial contour line and Ω2 represents the inner region of the initial contour line and the initial contour line. For any point y in the image domain Ω, there is a square neighborhood θ with y as the center point and a side length of 4σ+1. y ,in, is the Gaussian kernel function, σ is the standard deviation of the Gaussian kernel function, and a is the When point y is close to C0, θ y It intersects with both sub-regions Ω1 and Ω2, i.e., θ y ∩Ω1 and θ y ∩Ω2.
[0042] Furthermore, based on the level set method, the initial level set function φ(x, 0) is used to represent the initial contour line C0, and it is stipulated that the value of the initial level set function φ(x, 0) is -1 on the initial contour line C0 and inside the initial contour line C0, and the value of the initial level set function φ(x, 0) is 1 outside the initial contour line C0. The level set function φ(x, n) obtained by the nth (n is greater than or equal to 1) iteration is used to represent the curve C n , as the final segmentation result.
[0043] Specifically, the initial level set function is expressed as:
[0044] Step S2: update and iterate the initial level set function; the level set function at the nth iteration is:
[0045] in, is a mean filter with a window size of k×k, through the mean filter to replace the length term in the traditional active contour model, and is used to smooth the segmentation curve; softsign is the softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt is the time step; optionally, the value range of Δt is [0.5, 2]. In this embodiment, Δt = 1.
[0046] Specifically, the activation function softsign is defined as: The activation function softsign is used to replace the distance rule term in the traditional active contour model, so that the level set function always maintains the rule that the values on and inside the contour line are negative, while the values outside the contour line are positive during the iteration process.
[0047] Specifically, the gradient descent equation at the n-1th iteration is:
[0048] U(φ(x,n-1))=-αS′(φ(x,n-1))softsign((d1(x,n-1)-d2(x,n-1)) / β),
[0049] Among them, α is a constant; β is the standard deviation of the target image grayscale; function S′(z) is the function The derivative function of It is a data-driven term that reflects the difference between the target and the background. I(x) is the true grayscale value of the target image; To calculate the shadow value of the fitted image, is a mean filter with a window size of 2w+1, w is a constant, and * is a convolution operation; is the edge reflection structure information value at the n-1th iteration; when i=1, is the region θ y The edge reflection structure information value in ∩Ω1, When i=2, is the region θ y The edge reflection structure information value in ∩Ω2, Ω1 is the outer area of the contour line, and Ω2 is the initial contour line and the inner area of the contour line.
[0050] Furthermore, the standard deviation of the target image grayscale is:
[0051] Where Ω is the image domain of the target image; Q is the total number of pixels in the target image; is the average gray value of the target image.
[0052] Step S3: Use the level set function obtained in the last iteration as the segmentation curve of the target image.
[0053] Specifically, when |φ(x, n)-φ(x, n-1)|<ε, the iteration is stopped, and the level set function obtained in the last iteration is used as the segmentation curve of the target image; where ε is a constant, and optionally, the value range of ε is [0.001, 0.0001]. In this embodiment, ε is 0.001.
[0054] The image shadow value proposed in this embodiment It is a comprehensive measure of the intensity of the entire image. Its calculation result is one-time and does not need to be updated through iteration. It reflects the areas with obvious changes in brightness and darkness in the image, thereby guiding the iteration of the level set function and making the contour evolve towards the target boundary.
[0055] In the optimization length term calculation method of this embodiment, This method effectively filters the level set function after each iteration. Compared to traditional methods that also require iterative updates of the length term, this method achieves faster computational speed. Furthermore, the activation function softsign is used to implement the distance rule term. Besides the level set function φ(x, n-1), the formula only contains a single constant, η, eliminating the need for parameter adjustment, thus improving the robustness of the method.
[0056] In order to prove the effectiveness of the present invention, the performance of the proposed method is verified by computer experiments, and a comparative experiment is conducted with two multiplicative bias field models.
[0057] A. Experimental conditions:
[0058] All experiments were performed in MATLAB 2015b on a 2.6-GHz Intel Core i5 personal computer. All images used were from standard image libraries. Color images were converted to grayscale before segmentation. In all experiments, solid rectangular lines represent the initial contours, and dashed lines represent the final segmentation curves.
[0059] B. Experimental steps:
[0060] The parameters are set as follows: w = 35, k = 11, σ = 5, α = 3, η = 10, ε = 0.001, Δt = 1, and the maximum number of iterations N and the initial contour line are set.
[0061] C. The experimental results are as follows:
[0062] (1) Segmentation experiment
[0063] Five images with uneven grayscale were selected from the BSDS image library and segmented using the image segmentation method of the present invention. As shown in Figure 3, the first column shows the original image and initial outline, the second column shows the image shadow, the third column shows the d1(x)-d2(x) diagram at the nth iteration, and the fourth column shows the final segmentation result. Table 1 shows the number of iterations and segmentation time, which are the average results of 10 independent experiments.
[0064] Table 1 The number of iterations and segmentation time of the image segmentation method of the present invention for five images
[0065] (2) Noise robustness experiment
[0066] To evaluate the robustness of the image segmentation method of the present invention to noise, five grayscale images were selected from the BSDS image library. Gaussian noise with a mean of 0 and a variance of 0.03 was artificially added. The original images and the images with added noise were segmented using the image segmentation method of the present invention. As shown in Figure 4, the first column shows the original image and initial contour, the second column shows the segmentation results of the image segmentation method of the present invention for the original image, and the third column shows the segmentation results of the image segmentation method of the present invention for the images with added noise. The similar segmentation results between the noise-free and noise-injected images demonstrate that the image segmentation method of the present invention is robust to noise.
[0067] (3) Comparative experiment
[0068] Seven complex color images were selected from the BSDS image library and segmented using the PBCACM (pre-fitting bias correction active contour model), JDACM (Jeffreys divergence active contour model), and the image segmentation method of the present invention. As shown in Figure 5, the first column shows the original image and initial contours, the second column shows the segmentation results of the PBCACM model, the third column shows the segmentation results of the JDACM model, and the fourth column shows the segmentation results of the image segmentation method of the present invention.
[0069] Table 2 Segmentation time of three models (seconds)
[0070] Table 3 DSC and IOU (DSC / IOU) of three models
[0071] Table 2 shows the segmentation time of the three models. From the data in the table, it can be seen that the ERSI model is faster than the other models. The segmentation accuracy of each model is quantitatively compared using two reference standards: DSC (Dice Similarity Coefficient) and IOU (Intersection of Union). DSC is defined as The definition of IOU is Here, S1 is the experimentally obtained target region, and S2 is the standard target region provided by the BSDS image library. The closer the DSC and IOU values are to 1, the better the segmentation effect. Table 3 compares the DSC and IOU values of the three models. As can be seen from the data in the table, the image segmentation method of the present invention also has advantages in segmentation accuracy.
[0072] Example 2
[0073] This embodiment discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the method described in the first embodiment are implemented.
[0074] Example 3
[0075] This embodiment discloses a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of the method described in the first embodiment are implemented.
[0076] Example 4
[0077] This embodiment discloses an image segmentation system, which includes the following modules:
[0078] An initial level set module, configured to set an initial contour line in a target image and represent the initial contour line using an initial level set function;
[0079] The iteration module is used to update and iterate the initial level set function; the level set function at the nth iteration is:
[0080] in, is a mean filter with a window size of k×k; softsign is the softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt=1;
[0081] The segmentation curve determination module is used to use the level set function obtained in the last iteration as the segmentation curve of the target image.
[0082] The image segmentation system in the embodiment of the present invention is used to implement the aforementioned image segmentation method. Therefore, the specific implementation method of the system can be seen in the embodiment part of the image segmentation method in the previous text. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part and will not be elaborated here.
[0083] In addition, since the image segmentation system of this embodiment is used to implement the aforementioned image segmentation method, its function corresponds to that of the aforementioned method and will not be described in detail here.
[0084] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0085] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.
[0086] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0087] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0088] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.
Claims
1. An image segmentation method, characterized in that: The following steps are involved: S1, setting an initial contour line in the target image, and using an initial level set function to represent the initial contour line; S2, updating and iterating the initial level set function; the level set function at the nth iteration is: in, is a mean filter with a window size of k×k; softsign is a softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt is the time step; S3. Use the level set function obtained from the last iteration as the segmentation curve of the target image.
2. The image segmentation method according to claim 1, characterized in that: The gradient descent equation at the n-1th iteration is: U(φ(x, n-1))=-αS′(φ(x, n-1))softsign((d1(x, n-1)-d2(x, n-1)) / β), Among them, α is a constant; β is the standard deviation of the target image grayscale; function S′(z) is the function The derivative function of for Data driven term, y is the vector pixel point in the target image, θ y is a square neighborhood with y as the center and a side length of 4σ+1, is the Gaussian kernel function, σ is the standard deviation of the Gaussian kernel function, and a is the The normalization constant of ; I(x) is the true gray value of the target image; is the image shadow value fitted by calculation, is a mean filter with a window size of 2w+1, w is a constant, and * is a convolution operation; is the edge reflection structure information value at the n-1th iteration; when i=1, is the region θ y The edge reflection structure information value in ∩Ω1, When i=2, is the region θ y The edge reflection structure information value in ∩Ω2, Ω1 is the outer area of the contour line, and Ω2 is the contour line and the inner area of the contour line.
3. The image segmentation method according to claim 2, characterized in that: The standard deviation of the target image grayscale is: Where, Ω is the image domain of the target image; Q is the total number of pixels in the target image; is the average gray value of the target image.
4. The image segmentation method according to claim 1, characterized in that: The initial level set function is:
5. The image segmentation method according to claim 1, characterized in that: Step S3 includes: When |φ(x, n)-φ(x, n-1)|<ε, the iteration is stopped, and the level set function obtained from the last iteration is used as the segmentation curve of the target image; where ε is a constant.
6. The image segmentation method according to claim 5, characterized in that: The value range of ε is [0.001,0.0001].
7. The image segmentation method according to claim 1, characterized in that: The value range of Δt is [0.5,2].
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An image segmentation system, characterized in that Includes the following modules: An initial level set module, used to set an initial contour line in a target image and to represent the initial contour line using an initial level set function; The iteration module is used to iterate the initial level set function; the level set function at the nth iteration is: in, is a mean filter with a window size of k×k; softsign is a softsign activation function; η is a constant; φ(x, n) is the level set function at the nth iteration; x is a vector pixel point in the target image; φ(x, n-1) is the level set function at the n-1th iteration; U(φ(x, n-1)) is the gradient descent equation at the n-1th iteration; Δt is the time step; The segmentation curve determination module is used to use the level set function obtained in the last iteration as the segmentation curve of the target image.
Citation Information
Patent Citations
ACM (Active Contour Model) image rapid segmentation method based on gray scale morphological energy method
CN106570867A
Active contour model image segmentation method and system based on LoG operator
CN115131389A
Image segmentation method, electronic equipment and computer readable storage medium
CN115984312A
Segmentation device and method
US20090226057A1
Cited By
Building segmentation result intelligent vectorization method and apparatus, and electronic device
CN119672097A
