A method and device for automatic segmentation of image texture and background
Through an automatic image texture background segmentation method, using Gaussian filtering, LAB color space, mean clustering and Laplace matrix technologies, the problem of complex and multi-scale texture background image segmentation is solved, and efficient background segmentation and precise texture feature expression are achieved.
Patent Information
- Application Number
- CN202111181173.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-11
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-10-11
AI Technical Summary
The prior art is difficult to effectively segment images of complex and multi-scale textured backgrounds, resulting in difficult separation of background textures and foreground structures.
A method of automatic image texture background segmentation is proposed, through Gaussian filtering preprocessing, conversion to LAB color space, mean clustering preclustering, constructing Laplace matrix and feature vector matrix, weighted distance measurement formula to calculate the similarity, and performing mean clustering again to obtain the texture background area of the image.
It realizes rapid and automatic segmentation of background areas for images with complex and multi-scale texture backgrounds, improves segmentation accuracy and efficiency, and can effectively balance the similarity and differences between background texture and foreground structure.
Smart Images

Figure CN114092486B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of image processing, and in particular to a method and a device for automatic image texture and background segmentation. Background Art
[0002] Image background segmentation is beneficial for analyzing and detecting meaningful foreground objects and is the most commonly used processing method in the field of computer vision. However, many images in natural and real scenes have complex texture background patterns, and the background texture patterns and foreground structures may be very similar, such as messy mosaics, multi-scale rock textures, irregular artificial texture elements, etc. Due to the lack of deep representation of the overall background texture features, existing segmentation algorithms often cannot obtain complete texture background separation.
[0003] In recent decades, algorithms based on mean clustering, hierarchical clustering, and feature spectrum clustering have been widely used in the field of image segmentation. Among them, the mean clustering algorithm is one of the most popular classification algorithms in various image processing tasks due to its unsupervised nature, simplicity, and ease of programming. Although mean clustering has been successfully applied to various image segmentation tasks, it still has some shortcomings in image segmentation, such as the timeliness of high-dimensional data, stability of complex texture images, and adaptability. In order to reduce the computational complexity, a simple and effective improvement using superpixel technology has been proposed, which can significantly reduce the running time, but the accuracy has not been improved due to the interference of multi-scale texture patterns belonging to the same segmentation. The main reason why mean clustering and its variations fail in complex texture background segmentation is the lack of significant feature representation for similar textures. Therefore, some improved feature clustering methods are proposed for image segmentation based on spectral theory. These clustering methods are very effective in processing sparse data clustering by constructing data similarity as a new feature representation, and due to the use of dimensionality reduction algorithms, the complexity of feature clustering is also better than that of traditional clustering algorithms. In view of the excellent performance of spectral technology, more feature clustering extensions have been proposed in terms of acceleration, enhanced stability, and adaptability, and good results have been achieved in the field of image segmentation. Undoubtedly, the advantages of feature clustering in data classification are outstanding, but there are still challenges in adaptability, selection of appropriate feature representation, and data dimensionality reduction, especially for complex large-scale texture images. Summary of the invention
[0004] In order to solve the technical problems existing in the background technology, the present invention proposes an automatic image texture background segmentation method and device, which can quickly realize automatic segmentation of the background area of an image with a complex and multi-scale texture background.
[0005] The present invention provides an automatic image texture background segmentation method, comprising:
[0006] S1: Get the original image to be processed;
[0007] S2: Perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image;
[0008] S3: convert the denoised image from RGB color space to LAB color space to obtain a texture image;
[0009] S4: pre-clustering the texture image based on the mean clustering algorithm, establishing the distance correlation matrix of the cluster centers, and determining the number of adaptive clusters;
[0010] S5: Processing the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, constructing a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculating its eigenvector, and constructing an eigenvector matrix;
[0011] S6: Construct a weighted distance measurement formula to calculate the similarity between feature vectors;
[0012] S7: Taking the feature vector matrix as data input and the adaptive clustering number as the number of categories, mean clustering is performed again according to the similarity to obtain the segmentation mask corresponding to the original image;
[0013] S8: According to the grayscale edge gradient image and the segmentation mask, the texture background area is obtained by comparing with the original image.
[0014] Preferably, the step S4 specifically includes:
[0015] S401: Preset the number of clusters k=9, perform pre-clustering on the texture image according to the mean clustering algorithm, and obtain 9 cluster centers c i (i=1,2,...,9);
[0016] S402: Calculate the Mahalanobis distance between cluster centers:
[0017] (i,j=1,2,...,9), where Cov -1 Indicates the center point c i , c j The coordinate vector covariance matrix of ;
[0018] S403: Construct a distance correlation matrix A=(m ij ) 9×9 , and calculate all eigenvalues λ of A i (i=1,2,...,9);
[0019] S404: Perform an affine transformation on all eigenvalues of A to the interval [0, 10], round them to the nearest integer, and find out the number K of different eigenvalues, that is, the number of adaptive clusters.
[0020] Preferably, the step S5 specifically includes:
[0021] S501: Calculate the absolute gradient of the original image, and perform addition operation on the texture image to obtain an absolute value gradient image;
[0022] S502: Calculate the grayscale edge gradient image of the original image;
[0023] S503: Perform N super-pixel operations on the original image to obtain a super-pixel mask;
[0024] S504: Take the average value of the superpixel mask and merge the absolute value gradient image and the grayscale edge gradient image to construct the image feature matrix X N×4 =(x1,x2,...,x N ) T , where N represents the number of superpixels in the original image;
[0025] S505: Using the row information of the image feature matrix as a single sample point, construct the degree matrix D and the adjacency matrix W, where: D = diag (d i ),i=1,2,...,N, in x j For the k nearest neighbor method, x i The nearest neighbor point of the center search, p(x i ,x j ) is x i and x j Shortest path, σ is X N×4 The mean square error of
[0026] S506: Calculate the Laplace matrix L=DW, calculate all eigenvectors ξ of the Laplace matrix i (i=1,2,...,N), construct the eigenvector matrix F N =(ξ1,ξ2,...,ξ N ).
[0027] Preferably, the step S6 specifically includes:
[0028] Construct the weighted distance metric formula d w =τd O +(1-τ)d M ,in, Cov -1 is the vector ξ i ,ξ j Covariance matrix, τ = 0.7; the d w Represents ξ i ,ξ jThe similarity.
[0029] The present invention also provides an image texture background automatic segmentation device, comprising:
[0030] An image acquisition module, used to acquire the original image to be processed;
[0031] A preprocessing module is used to perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image;
[0032] An image conversion module is used to convert the denoised image from the RGB color space to the LAB color space to obtain a texture image;
[0033] A pre-clustering module is used to pre-cluster the texture image based on the mean clustering algorithm, establish a distance correlation matrix of the cluster centers, and determine the number of adaptive clusters;
[0034] An image processing module is used to process the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, construct a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculate its eigenvector, and construct an eigenvector matrix;
[0035] A similarity calculation module is used to construct a weighted distance measurement formula to calculate the similarity between feature vectors;
[0036] The clustering module is used to take the feature vector matrix as data input, the adaptive cluster number as the number of categories, perform mean clustering again according to the similarity, and obtain the segmentation mask corresponding to the original image;
[0037] The contrast module is used to compare the grayscale edge gradient image and the segmentation mask with the original image to obtain the texture background area of the image.
[0038] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned image texture and background automatic segmentation method are implemented.
[0039] In the present invention, a texture image is obtained by processing the original image. First, a mean algorithm is used to pre-cluster the texture graphics to obtain an adaptive clustering number. Then, an absolute value gradient image and a grayscale edge gradient image are used to construct a new feature representation. The Laplacian matrix is calculated and its eigenvector is used as mean clustering data input. A weighted distance formula is proposed to calculate the similarity to measure similar background textures. Finally, based on the adaptive clustering number, the eigenvector and the similarity, mean clustering is performed again to obtain a complete image texture background.
[0040] In the present invention, the original image is subjected to denoising preprocessing to effectively protect the image structure; the image is converted from the RGB color space to the LAB space to make it more in line with the perception needs; the texture background area can be separated from the foreground structure as much as possible through mean preclustering; the image is processed using the superpixel method to greatly reduce the computational complexity; the Mahalanobis distance is used to measure the distance of the preclustering center and to construct a distance correlation matrix, which can effectively balance the gap between small-scale and large-scale textures and better unify multi-scale textures with similarity;
[0041] In the present invention, by calculating the number of mutually different eigenvalues of the association matrix constructed by the pre-clustering center as the number of adaptive clustering, the optimal number of automatic segmentation of the image area can be quickly and effectively obtained; the number of automatic segmentation is used as the number of categories of the new mean clustering, an automatic segmentation solution can be provided for image segmentation; a weighted distance metric composed of Euclidean and Mahalanobis distances is constructed, which can effectively balance the differences between complex textures.
[0042] In the present invention, the absolute gradient is used to enhance the structural information of the original image, which is beneficial to the separation of structural information; the enhanced color absolute value gradient image and grayscale edge image are used as image feature input to effectively balance the similarities and differences between background texture and foreground structure.
[0043] In the present invention, the eigenvector of the Laplacian matrix is used as the input data of image segmentation, which increases the data input scale and can better express the deep features of the image; the background image is clustered again using the automatic segmentation number and the eigenvector of the Laplacian matrix, which can quickly and adaptively segment the complete image texture background. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 The present invention provides a flowchart of an automatic image texture and background segmentation method. DETAILED DESCRIPTION
[0045] like Figure 1 As shown, Figure 1 The present invention is a flowchart of a method for automatic image texture and background segmentation according to an embodiment of the present invention.
[0046] Reference Figure 1 , an automatic image texture background segmentation method proposed in an embodiment of the present invention includes:
[0047] S1: Get the original image to be processed;
[0048] S2: Perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image;
[0049] In this embodiment, the image is pre-processed for noise reduction, thereby effectively protecting the image structure.
[0050] S3: convert the denoised image from RGB color space to LAB color space to obtain a texture image;
[0051] In this embodiment, the image is converted from the RGB color space to the LAB space to make it more in line with perception needs.
[0052] S4: pre-clustering the texture image based on the mean clustering algorithm, establishing the distance correlation matrix of the cluster centers, and determining the number of adaptive clusters;
[0053] In this embodiment, step S4 specifically includes:
[0054] S401: Preset the number of clusters k=9, perform pre-clustering on the texture image according to the mean clustering algorithm, and obtain 9 cluster centers c i (i=1,2,...,9);
[0055] It should be noted that the embodiment of the present invention needs to use a larger number of clusters to perform rough mean pre-clustering, so as to separate the texture background area from the foreground structure as much as possible. In this embodiment, the preset optimal number of clusters is 9.
[0056] S402: Calculate the Mahalanobis distance between cluster centers:
[0057] (i,j=1,2,...,9), where Cov -1 Indicates the center point c i , c j The coordinate vector covariance matrix of ;
[0058] S403: Construct a distance correlation matrix A=(m ij ) 9×9 , and calculate all eigenvalues λ of A i (i=1,2,...,9);
[0059] S404: Perform an affine transformation on all eigenvalues of A to the interval [0, 10], round them to the nearest integer, and find out the number K of different eigenvalues, that is, the number of adaptive clusters.
[0060] In this embodiment, the Mahalanobis distance is used to measure the distance of the pre-clustering centers and construct a distance correlation matrix, which can effectively balance the gap between small-scale and large-scale textures and better unify multi-scale textures with similarities. The number of different eigenvalues of the distance correlation matrix constructed by the pre-clustering centers is calculated as the number of adaptive clusters, which is the number of categories of the new mean clustering, that is, the number of image region segmentations, and the optimal number of automatic image region segmentations can be quickly and effectively obtained.
[0061] S5: Processing the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, constructing a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculating its eigenvector, and constructing an eigenvector matrix;
[0062] In this embodiment, step S5 specifically includes:
[0063] S501: Calculate the absolute gradient of the original image, and perform addition operation on the texture image to obtain an absolute value gradient image;
[0064] S502: Calculate the grayscale edge gradient image of the original image;
[0065] S503: Perform N super-pixel operations on the original image to obtain a super-pixel mask;
[0066] In this embodiment, the superpixel method is used to process the image, which greatly reduces the computational complexity.
[0067] S504: Take the average value of the superpixel mask and merge the absolute value gradient image and the grayscale edge gradient image to construct the image feature matrix X N×4 =(x1,x2,...,x N ) T , where N represents the number of superpixels in the original image;
[0068] S505: Using the row information of the image feature matrix as a single sample point, construct the degree matrix D and the adjacency matrix W, where: D = diag (d i ),i=1,2,...,N, in x j For the k nearest neighbor method, x i The nearest neighbor point of the center search, p(x i ,x j ) is x i and x j Shortest path, σ is X N×4 The mean square error of
[0069] S506: Calculate the Laplace matrix L=DW, calculate all eigenvectors ξ of the Laplace matrix i (i=1,2,...,N), construct the eigenvector matrix F N =(ξ1,ξ2,...,ξ N ).
[0070] In this embodiment, the absolute gradient is used to enhance the structural information of the original image, which is beneficial to the separation of structural information; the enhanced color absolute value gradient image and grayscale edge image are used as image feature inputs to effectively balance the similarities and differences between the background texture and the foreground structure; by calculating the Laplacian matrix and using its eigenvector as the mean clustering data input, the segmentation mask corresponding to the original image can be quickly obtained, and then the image texture background area can be quickly obtained based on the mask.
[0071] S6: Construct a weighted distance measurement formula to calculate the similarity between feature vectors;
[0072] In this embodiment, step S6 specifically includes:
[0073] Construct the weighted distance metric formula d w =τd O +(1-τ)d M ,in, Cov -1 is the vector ξ i ,ξ j Covariance matrix, τ = 0.7; the d w Represents ξ i ,ξ j The similarity.
[0074] S7: Taking the feature vector matrix as data input and the adaptive clustering number as the number of categories, mean clustering is performed again according to the similarity to obtain the segmentation mask corresponding to the original image;
[0075] S8: According to the grayscale edge gradient image and the segmentation mask, the texture background area is obtained by comparing with the original image.
[0076] Specifically, in this embodiment, the grayscale edge gradient image and the segmentation mask are referenced to find the region with relatively fewer structural details and the largest area of the same type in the original image, and obtain the image texture background region.
[0077] The embodiment of the present invention also provides an image texture background automatic segmentation device, comprising:
[0078] An image acquisition module, used to acquire the original image to be processed;
[0079] A preprocessing module is used to perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image;
[0080] An image conversion module is used to convert the denoised image from the RGB color space to the LAB color space to obtain a texture image;
[0081] A pre-clustering module is used to pre-cluster the texture image based on the mean clustering algorithm, establish a distance correlation matrix of the cluster centers, and determine the number of adaptive clusters;
[0082] Specifically, the pre-clustering module of the embodiment of the present invention performs pre-clustering through steps S401-S404 in the above-mentioned image texture and background automatic segmentation method embodiment, establishes a distance correlation matrix of cluster centers, and determines the number of adaptive clusters.
[0083] An image processing module is used to process the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, construct a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculate its eigenvector, and construct an eigenvector matrix;
[0084] Specifically, the image processing module of the embodiment of the present invention processes steps S501-S506 in the above-mentioned image texture background automatic segmentation method embodiment to obtain an absolute value gradient image and a grayscale edge gradient image, constructs a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculates its eigenvector, and constructs an eigenvector matrix;
[0085] A similarity calculation module is used to construct a weighted distance measurement formula to calculate the similarity between feature vectors;
[0086] Specifically, the similarity calculation module in the embodiment of the present invention calculates the similarity between feature vectors using the specific formula and method in step S6 in the above-mentioned image texture and background automatic segmentation method embodiment.
[0087] The clustering module is used to take the feature vector matrix as data input, the adaptive cluster number as the number of categories, perform mean clustering again according to the similarity, and obtain the segmentation mask corresponding to the original image;
[0088] The contrast module is used to compare the grayscale edge gradient image and the segmentation mask with the original image to obtain the texture background area of the image.
[0089] Specifically, referring to the grayscale edge gradient image and the segmentation mask, the region with relatively few structural details and the largest area of the same type in the original image is found to obtain the image texture background region.
[0090] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for automatic image texture and background segmentation described in the above embodiment are implemented.
[0091] In the present invention, a texture image is obtained by processing an original image. First, a mean algorithm is used to pre-cluster the texture graphics to obtain an adaptive clustering number. Then, an absolute value gradient image and a grayscale edge gradient image are used to construct a new feature representation. The Laplacian matrix is calculated and its eigenvector is used as mean clustering data input. A weighted distance formula is proposed to calculate the similarity to measure similar background textures. Finally, based on the adaptive clustering number, the eigenvector and the similarity, mean clustering is performed again to obtain a complete image texture background. The present invention realizes automatic segmentation of background areas of images with complex and multi-scale texture backgrounds.
[0092] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for automatic image texture and background segmentation, characterized in that: include: S1: Get the original image to be processed; S2: Perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image; S3: convert the denoised image from RGB color space to LAB color space to obtain a texture image; S4: pre-clustering the texture image based on the mean clustering algorithm, establishing the distance correlation matrix of the cluster centers, and determining the number of adaptive clusters; S5: Processing the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, constructing a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculating its eigenvector, and constructing an eigenvector matrix; S6: Construct a weighted distance measurement formula to calculate the similarity between feature vectors; S7: Taking the feature vector matrix as data input and the adaptive clustering number as the number of categories, mean clustering is performed again according to the similarity to obtain the segmentation mask corresponding to the original image; S8: Compare the grayscale edge gradient image and the segmentation mask with the original image to obtain the texture background area; The step S5 specifically includes: S501: Calculate the absolute gradient of the original image, and perform addition operation on the texture image to obtain an absolute value gradient image; S502: Calculate the grayscale edge gradient image of the original image; S503: Perform N super-pixel operations on the original image to obtain a super-pixel mask; S504: Take the average value of the superpixel mask and merge the absolute value gradient image and the grayscale edge gradient image to construct the image feature matrix X N×4 =(x1,x2,...,x N ) T , where N represents the number of superpixels in the original image; S505: Using the row information of the image feature matrix as a single sample point, construct the degree matrix D and the adjacency matrix W, where: D = diag (d i ),i=1,2,...,N, in x j For the k nearest neighbor method, x i The nearest neighbor point of the center search, p(x i ,x j ) is x i and x j Shortest path, σ is X N×4 The mean square error of S506: Calculate the Laplace matrix L=DW, calculate all eigenvectors ξ of the Laplace matrix i (i=1,2,...,N), construct the eigenvector matrix F N =(ξ1,ξ2,...,ξ N ).
2. The method for automatic image texture and background segmentation according to claim 1, characterized in that: The step S4 specifically includes: S401: Preset the number of clusters k=9, perform pre-clustering on the texture image according to the mean clustering algorithm, and obtain 9 cluster centers c i (i=1,2,...,9); S402: Calculate the Mahalanobis distance between cluster centers: Among them, Cov -1 Indicates the center point c i , c j The coordinate vector covariance matrix of ; S403: Construct a distance correlation matrix A=(m ij ) 9×9 , and calculate all eigenvalues λ of A i (i=1,2,...,9); S404: Perform an affine transformation on all eigenvalues of A to the interval [0, 10], round them to the nearest integer, and find out the number K of different eigenvalues, that is, the number of adaptive clusters.
3. The method for automatic image texture and background segmentation according to claim 1, characterized in that: The step S6 specifically includes: Construct the weighted distance metric formula d w =τd O +(1-τ)d M ,in, Cov -1 is the vector ξ i ,ξ j covariance matrix, τ = 0.7 is the weight; the d w Represents ξ i ,ξ j The similarity.
4. An image texture background automatic segmentation device based on the image texture background automatic segmentation method according to any one of claims 1 to 3, characterized in that: include An image acquisition module, used to acquire the original image to be processed; A preprocessing module is used to perform Gaussian filtering preprocessing on the original image to remove scene noise and obtain a denoised image; An image conversion module is used to convert the denoised image from the RGB color space to the LAB color space to obtain a texture image; A pre-clustering module is used to pre-cluster the texture image based on the mean clustering algorithm, establish a distance correlation matrix of the cluster centers, and determine the number of adaptive clusters; An image processing module is used to process the original image and the texture image to obtain an absolute value gradient image and a grayscale edge gradient image, construct a Laplacian matrix based on the absolute value gradient image and the grayscale edge gradient image, calculate its eigenvector, and construct an eigenvector matrix; A similarity calculation module is used to construct a weighted distance measurement formula to calculate the similarity between feature vectors; The clustering module is used to take the feature vector matrix as data input, the adaptive cluster number as the number of categories, perform mean clustering again according to the similarity, and obtain the segmentation mask corresponding to the original image; The contrast module is used to compare the grayscale edge gradient image and the segmentation mask with the original image to obtain the texture background area of the image.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for automatic image texture and background segmentation according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Method for constructing similarity matrix in ultrasound image Ncut segmentation process
CN103871066A
Texture image segmentation method combined with sparse neighbor propagation and rapid spectral clustering
CN104732545A