Method and System for Extracting Skeleton of Binary Image with Anti-Noise

By calculating and optimizing the displacement vector of each foreground pixel and moving pixel points along the optimization direction, the problem of insufficient robustness of the skeletonized algorithm in the prior art is solved, and a smoother and noise-resistant skeleton extraction effect is achieved.

CN114494704BActive Publication Date: 2025-06-10CHONGQING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210140719.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-16
Publication Date
2025-06-10
Estimated Expiration
2042-02-16

AI Technical Summary

Technical Problem

The skeletonization algorithm based on fixed 4 neighborhoods and 8 neighborhoods in the prior art is not robust enough when processing noise, especially when the noise is close to the boundary, the loss of local information leads to serious degradation of the skeleton quality.

Method used

By calculating the sum of vectors of each foreground pixel in its search domain, the initial displacement vector is obtained, and principal component analysis is optimized. The pixel points are moved along the optimized displacement vector until the termination condition is met, and post-processing and refinement is performed to extract the anti-noise skeleton.

Benefits of technology

This method collects more local information, the extracted skeleton is smoother, has strong robustness to noise, and significantly improves the robustness of the skeletonization algorithm.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114494704B_ABST
    Figure CN114494704B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of image skeletonization, and specifically discloses a method and system for extracting a skeleton with anti-noise for a binary image. The method uses the foreground pixels of the binary image to calculate the sum of vectors of each foreground pixel in its search domain to obtain its initial displacement vector, performs principal component analysis to optimize the initial displacement vector, moves each pixel point along the optimized displacement vector, and redraws the image according to the set of moved points. The steps are repeated until the termination condition is met and then stopped to obtain the original skeleton. The original skeleton is refined by deleting unnecessary pixel points that do not change the connectivity of the graph to obtain the final skeleton. By adopting the technical solution of the present invention, more local information is collected, the extracted skeleton is smoother, and it has strong robustness to noise.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image skeletonization, and relates to a method and system for extracting a noise-resistant skeleton of a binary image. Background Art

[0002] Skeletonization is the process of reducing the foreground region on a binary image to a skeleton residue, which largely preserves the connectivity of the original region, thus providing a practical and compact representation of the image object. The extracted skeleton can be used as a useful shape description tool and is also a well-known preprocessing method for image analysis and shape recognition.

[0003] There are many algorithms in the prior art for obtaining skeletons in a two-dimensional space, and they can be classified as follows:

[0004] Skeletonization methods based on thinning: The shape is peeled off in an intuitive way to obtain a set of connected points with a single-pixel width, maintaining the topology of the shape. That is, thinning is an operation aimed at deleting non-terminal simple points in a parallel or sequential manner. The main advantage of these algorithms is that they preserve the shape topology.

[0005] Skeletonization methods based on distance maps: The goal is to identify key points on the distance map, where each pixel is labeled with the value of the distance to the closest background pixel. Different distance maps approximate or precisely calculate the Euclidean distance. For example, chamfer (approximating the Euclidean distance through a local mask), squared Euclidean distance, signed Euclidean distance, and honeycomb (based on a hexagonal grid).

[0006] However, the algorithms in the prior art based on fixed 4-neighborhood and 8-neighborhood can only consider quite local information. Especially when noise is close to the boundary, the loss of local information will lead to a serious degradation of the quality of the generated skeleton and insufficient robustness of the algorithm. Summary of the Invention

[0007] The purpose of the present invention is to provide a method and system for extracting a noise-resistant skeleton of a binary image to solve the problem of insufficient robustness of the algorithm.

[0008] To achieve the above object, the basic solution of the present invention is: A method for extracting a noise-resistant skeleton of a binary image, comprising the following steps:

[0009] S1, obtaining the foreground pixels of the binary image, calculating the sum of vectors of each foreground pixel in its search domain, and obtaining its initial displacement vector;

[0010] S2, performing principal component analysis to optimize the initial displacement vector;

[0011] S3, moving each pixel point along the optimized displacement vector and redrawing the image according to the set of moved points;

[0012] S4. Repeat steps S1 - S3 until the termination condition is met and then stop to obtain the original skeleton.

[0013] S5. Refine the original skeleton by deleting the unnecessary pixels that do not change the graph connectivity to obtain the final skeleton.

[0014] The working principle and beneficial effects of this basic solution are as follows: This solution calculates the sum of vectors of each foreground pixel in its search domain to obtain its initial motion direction, and then optimizes the previously calculated vectors. Move each pixel point along the optimized displacement vector and redraw the image according to the set of moved points. Until the termination condition is met, post - process to obtain the final skeleton. Such a nearest - neighbor - based anti - noise skeletonization algorithm collects more local information, making the extracted skeleton not only smoother but also highly robust to noise.

[0015] Furthermore, the method to obtain the initial displacement vector is as follows:

[0016] Let the binary image S be represented by a matrix P of size m×n;

[0017] Given a set of foreground pixels, the initial displacement vector u is obtained by calculating the sum of vectors around each sample pixel. i as:

[0018]

[0019] where i is the identification of the sample pixel to be calculated, j is the identification of the sample pixel within the neighborhood of i, x i is the coordinate of the sample pixel to be calculated, x j is the coordinate of the sample pixel within the neighborhood, k i is the number of pixel points contained in the adaptive neighborhood of i; N i,k is the set of k - nearest neighbors of the sample pixel x i .

[0020] The calculation is simple and easy to operate.

[0021] Furthermore, the method to optimize the initial displacement vector is as follows:

[0022] Perform principal component analysis on each foreground pixel on its N i,k to obtain a symmetric 2×2 positive semi - definite matrix M:

[0023]

[0024] where is the outer product vector operator, and use the positive semi - definite matrix M to solve its eigenvalues and eigenvectors;

[0025] To clearly distinguish which pixels should move and which should not, a Gaussian weight is added to adjust the final displacement vector, and the optimized displacement vector is obtained as follows:

[0026]

[0027] Among them, represents the jump function; the detail factor γ represents the degree of detail of the extracted skeleton. The higher the γ value, the more details the skeleton has; the symbol a is the scale factor, represents the main direction of the sample pixel x i ; e is the natural base of the logarithm.

[0028] Using the optimized displacement vector, the pixels that need to move and those that do not need to move are determined, avoiding mis-movement and facilitating use.

[0029] Furthermore, the eigenvalues of the positive semi-definite matrix M are respectively related to the unit eigenvectors of the positive semi-definite matrix M, and is calculated to measure the linearity of the neighborhood;

[0030] If then the main direction of the sample pixel x i is Or when holds, and will become opposite directions;

[0031] The average value σ of all linear measurements i is expressed as representing the linearity of the skeleton; as the extraction progresses, will tend to 1; when remains unchanged three times in a row, the termination condition is satisfied and the extraction stops.

[0032] Set the Gaussian weight to adjust the final displacement vector, which is conducive to use.

[0033] Furthermore, in order to be able to extract the skeletons of images at different scales, it is necessary to adaptively update the number of nearest neighbors, that is, k, which is calculated as follows:

[0034]

[0035] In the formula, A bb is the area of the bounding box of the target in the original image, and c is the scale factor.

[0036] Based on k-nearest neighbors for skeleton extraction, accurate and smooth images can be extracted at different scales, which is convenient for use.

[0037] Furthermore, the method for refining the original skeleton is as follows:

[0038] Based on u i and First, perform an end point search. The component length of the end point u ii must be greater than 1 in at least one of the x and y directions;

[0039] The value is higher at points closer to the central axis of the skeleton;

[0040] Select or and of the pixels as the end points;

[0041] Based on the above settings, filter out the central axis end points;

[0042] For the resulting set of end points, for each connected component, calculate its centroid and consider this centroid as the actual end point;

[0043] For foreground pixels, the closer to the boundary, the larger |u i |. First, sort the pixels in descending order according to the value of |u i |, and then delete them one by one, ensuring that the outermost pixels are always deleted first.

[0044] Refine the skeleton while ensuring the quality of the skeleton for easy use.

[0045] Furthermore, the method for reducing the computational amount during the refinement process is as follows:

[0046] When the calculated u i is equal to 0, that is, the neighborhood of the sample pixel is a completely symmetric region, set its Δx i to (0,0).

[0047] Reduce the computational amount, speed up the calculation, and facilitate use.

[0048] Furthermore, the method for reducing the computational amount during the refinement process is as follows:

[0049] Based on the Gaussian circle problem:

[0050]

[0051] where r is the radius of the circle and N(r) is the number of pixel points contained in the neighborhood at this radius; when the radius reaches a certain threshold, save the relative positions of possible neighbor points in advance in the next iteration of the array. In the next iteration, directly calculate the absolute positions of the points according to the relative positions in the array.

[0052] Implement the acceleration strategy in the final program to complete the calculation acceleration for easy use.

[0053] The present invention also provides a system for anti-noise extraction of the skeleton of a binary image, including an image acquisition module and a processing module. The image acquisition module is used to acquire a binary image, and the output end of the image acquisition module is connected to the processing module. The processing module executes the method of the present invention to perform skeleton extraction.

[0054] This system uses the image acquisition module to acquire the required image and completes the skeleton extraction through the processing module, with simple operation and convenient use. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 is a schematic flowchart of the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0056] Figure 2 is a schematic diagram of the coordinates of a sample and its neighborhood in the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0057] Figure 3 is a schematic structural diagram of the original skeleton in the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0058] Figure 4 is a schematic structural diagram of the non-uniformly thinned skeleton in the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0059] Figure 5 is a schematic structural diagram of the refined skeleton in the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0060] Figure 6 is a schematic structural diagram of the boundary pixels in a preferred embodiment of the method for anti-noise extraction of the skeleton of a binary image according to the present invention;

[0061] Figure 7 is a schematic structural diagram of the boundary pixels in a preferred embodiment of the method for anti-noise extraction of the skeleton of a binary image according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0062] The embodiments of the present invention will be described in detail below. The examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements with the same or similar functions from beginning to end. The embodiments described below with reference to the drawings are exemplary and are only used to explain the present invention and should not be construed as limiting the present invention.

[0063] In the description of the present invention, it should be understood that the orientation or positional relationships indicated by the terms "longitudinal", "lateral", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. are based on the orientation or positional relationships shown in the drawings. These are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it should not be construed as a limitation to the present invention.

[0064] In the description of the present invention, unless otherwise specified and defined, it should be noted that the terms "installation", "connection", and "coupling" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the communication inside two elements. It can be directly connected or indirectly connected through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms can be understood according to specific circumstances.

[0065] The present invention discloses a method for anti-noise extraction of the skeleton of a binary image, which is used to solve the problem of insufficient robustness of the algorithms based on fixed 4-neighborhood and 8-neighborhood in the prior art. As Figure 1 shown, the method for anti-noise extraction of the skeleton of a binary image according to the present invention includes the following steps:

[0066] S1, obtaining the foreground pixels of the binary image, calculating the sum of vectors of each foreground pixel in its search domain, and obtaining its initial displacement vector;

[0067] S2, performing principal component analysis to optimize the initial displacement vector;

[0068] S3, moving each pixel point along the optimized displacement vector and redrawing the image according to the set of moving points;

[0069] S4, repeating steps S1 - S3 until the termination condition is met and then stopping to obtain the original skeleton;

[0070] S5, thinning the original skeleton and deleting the unnecessary pixel points that do not change the connectivity of the graph to obtain the final skeleton.

[0071] In a preferred embodiment of the present invention, the method for obtaining the initial displacement vector is as follows:

[0072] Let the binary image S be represented by a matrix P of size m×n;

[0073] Given a set of foreground pixels, the initial displacement vector u i is obtained by calculating the sum of the vectors around each sample pixel:

[0074]

[0075] where, i is the identification of the sample pixel to be calculated, j is the identification of the sample pixel within the neighborhood of i, x i is the coordinate of the sample pixel to be calculated, x j is the coordinate of the sample pixel within the neighborhood, k i is the number of pixel points contained in the adaptive neighborhood of i; N i,k is the set of k nearest neighbors of the sample pixel x i . The displacement vector u i determines the main direction of movement. However, when facing a pixel with special local information, such as Figure 2 the sample pixel on the right shown in, this pixel is in an extreme position and should not be moved, but its u i is calculated as (0, -1) after rasterization. Therefore, before moving, principal component analysis (PCA) needs to be performed on each foreground pixel on its N i,k .

[0076] In a preferred embodiment of the present invention, the method for optimizing the initial displacement vector is as follows:

[0077] Perform principal component analysis on each foreground pixel on its N i,k to obtain a symmetric 2×2 positive semi-definite matrix M:

[0078]

[0079] where is the outer product vector operator, and solve its eigenvalues and eigenvectors using the positive semi-definite matrix M;

[0080] In order to clearly distinguish which pixels should move and which pixels should not move, a Gaussian weight is added to adjust the final displacement vector to obtain the optimized displacement vector as follows:

[0081]

[0082] where, represents the jump function; the detail factor γ represents the degree of detail of the extracted skeleton. The higher the γ value, the more details of the skeleton; the symbol a is the scale factor, and the default value is 10; represents the main direction of the sample pixel x i ; e is the natural base. For example, based on 8 sample pixels (as Figure 6 shown), construct a jump function, σ i itself contains the ratio information between the eigenvectors that is insensitive to the object direction. The specific description is as follows: i

[0083]

[0084] ​The offset 0.7723 in J is the σ of the boundary pixels of the first rectangle and the second rectangle, that is, the mean of 0.7875 and 0.7571. Through this improvement, the boundary can move normally, and the improvement result is as Figure 7 shown.

[0085] In a preferred embodiment of the present invention, the eigenvalues of the positive semi - definite matrix M are respectively related to the unit eigenvectors of the positive semi - definite matrix M and calculate to measure the linearity of the neighborhood;

[0086] If then the main direction of the sample pixel x i is Or when at this time, and will become the opposite direction; when is very small, the sample pixel x i should move further, while when is very large, the sample pixel x i should move less or even remain stationary;

[0087] The average value σ of all linear measurements i is expressed as indicating the linear degree of the skeleton; as the extraction progresses, will tend to 1; when remains unchanged three times in a row, the termination condition is satisfied and the extraction stops. At the end of each iteration, due to the movement, there will be many duplicate points, and these points can be removed by simply redrawing according to the position.

[0088] In a preferred embodiment of the present invention, in order to be able to extract the skeletons of images at different scales, it is necessary to adaptively update the number of nearest neighbors, that is, k, and the calculation is as follows:

[0089]

[0090] In the formula, A bb is the area of the bounding box of the target in the original image, and c is a scaling factor with a default value of 10. Using this update scheme, accurate and smooth images can be extracted at different scales.

[0091] After the above extraction, a relatively thick but topologically well-preserved original skeleton is obtained, and the original skeleton needs to be further thinned. The basic idea is that if a pixel can be deleted without changing the connectivity of the graph, then this pixel can actually be deleted. However, the end points should be reserved in advance because if removed along the end points, although the connectivity of the graph can be maintained, the entire skeleton will disappear. Therefore, in a preferred embodiment of the present invention, the method for thinning the original skeleton is as follows:

[0092] Based on u i and First, perform an end point search. The component length of the end point u ii must be greater than 1 in at least one of the x and y directions;

[0093] The value of and u i will be higher at points closer to the central axis of the skeleton because the more symmetric and elongated the distribution of the neighbors,

[0094] Select or and pixels as end points;

[0095] Filter out the central axis end points based on these two facts;

[0096] The resulting set of end points may be a set of connected domains. For each connected domain, calculate its centroid and regard this centroid as the actual end point; then dilute it: Since the original skeleton is not strictly smooth, as Figure 3 shown. If pixels are simply deleted from one direction or multiple directions, a non-uniformly thinned skeleton will eventually be obtained, as Figure 4 shown.

[0097] According to the property of the length of u i , that is, |u i |, for foreground pixels, the closer it is to the boundary, the larger its |u i |;

[0098] Therefore, first sort the pixels in descending order according to the value of |u i |, and then delete them in turn, ensuring that the outermost pixels are always deleted first, and the result is as Figure 5 shown.

[0099] The preferred method for reducing the computational amount during the thinning process is as follows:

[0100] When the calculated u i is equal to 0, that is, the neighborhood of the sample pixel is a completely symmetric region, set its Δx i to (0,0).

[0101] Another preferred method for reducing the computational amount during the refinement process is as follows:

[0102] Based on the Gauss circle problem:

[0103]

[0104] Where r is the radius of the circle, and N(r) is the number of pixel points contained in the neighborhood under this radius; when the radius reaches a certain threshold, new neighbors may appear. For example, when the radius is between 2 and 2.3, no new neighbors will appear. Only when the radius reaches 2.3 will it cause a possible change in the number of neighbors. This reveals an acceleration strategy in which there is no need to increase the radius little by little to search for neighbors. The relative positions of possible neighbor points are saved in advance in the next iteration of the array. In the next iteration, the absolute positions of the points are directly calculated according to the relative positions in the array. As the radius r increases, the number of potential neighbor points contained becomes more and more, and their coordinates are relatively fixed. For example, there are no new additions when r is within (0, 1), and four new neighbor points with relative positions (0, 1), (1, 0), (0, -1), and (-1, 0) are added when r = 1. Implementing this acceleration strategy in the final program can bring a 4-fold acceleration.

[0105] The present invention also provides a system for extracting a noise-resistant skeleton of a binary image, including an image acquisition module and a processing module. The image acquisition module is used to acquire a binary image. The output end of the image acquisition module is electrically connected to the processing module. The processing module executes the method of the present invention to perform skeleton extraction. This solution is based on the nearest neighbor noise-resistant skeletonization algorithm, collects more local information than the 4-neighborhood or 8-neighborhood, and the extracted skeleton is not only smoother but also has strong robustness to noise.

[0106] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.

[0107] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and purposes of the present invention. The scope of the present invention is defined by the claims and their equivalents.

Claims

1. A method for anti-noise extraction of the skeleton of a binary image, characterized in that, it includes the following steps: S1. Obtain the foreground pixels of the binary image, calculate the vector sum of each foreground pixel in its search domain, and obtain its initial displacement vector; S2. Perform principal component analysis to optimize the initial displacement vector; S3. Move each pixel point along the optimized displacement vector, and redraw the image according to the set of moved points; S4. Repeat steps S1 - S3 until the termination condition is met and then stop to obtain the original skeleton; S5. Refine the original skeleton, delete the unnecessary pixel points that do not change the graph connectivity, and obtain the final skeleton; The method for obtaining the initial displacement vector is as follows: Let the binary image S be represented by a matrix P of size m×n; Given a set of foreground pixels, an initial displacement vector u is obtained by calculating the sum of the vectors around each sample pixel. i as follows: Among them, i is the identifier of the sample pixel to be calculated, j is the identifier of the sample pixel in the neighborhood of i, x i is the coordinate of the sample pixel to be calculated, x j is the coordinate of the sample pixel in the neighborhood, k i is the number of pixel points contained in the adaptive neighborhood of i; N i,k is the set of k nearest neighbors of the sample pixel x i ; The method for optimizing the initial displacement vector is as follows: Perform principal component analysis on each foreground pixel in its N i,k to obtain a symmetric 2×2 positive semi-definite matrix M: Among them is the outer product vector operator, and the semi-positive definite matrix M is used to solve its eigenvalues and eigenvectors; To clearly distinguish which pixels should move and which pixels should not move, a Gaussian weight is added to adjust the final displacement vector, and the optimized displacement vector is obtained as follows: Among them, represents a jump function; the detail factor γ represents the degree of detail for extracting the skeleton. The higher the value of γ, the more details the skeleton has; the symbol a is a scaling factor, represents the main direction of the sample pixel x i ; e is the base of the natural logarithm; Eigenvalues of the positive semi - definite matrix M are respectively related to the unit eigenvectors of the positive semi - definite matrix M. Calculate to measure the linearity of the neighborhood; If then the main direction of the sample pixel x i is Or when then and will become the opposite direction; cos is the cosine function in mathematics; The average value σ of all linear measurements i is expressed as indicating the linear degree of the bone; as the extraction progresses, will tend to 1; when remains unchanged three times in a row, the termination condition is met and the extraction stops.

2. The method for anti-noise extraction of the skeleton of a binary image according to claim 1, characterized in that, in order to be able to extract the skeletons of images of different scales, it is necessary to adaptively update the number of nearest neighbors, that is, k, and the calculation is as follows: where A bb is the area of the bounding box of the target in the original image, and c is the scale factor.

3. The method for anti-noise extraction of the skeleton of a binary image according to claim 1, characterized in that, the method for refining the original skeleton is as follows: Based on u i and First, perform an end point search. The component length of the end point u ii must be greater than 1 in at least one of the x and y directions; The value will be higher at points closer to the central axis of the skeleton; Select and the pixels as endpoints; Based on the above settings, filter out the endpoints of the central axis; For the result endpoint set, for each connected domain, calculate its centroid and regard this centroid as the actual endpoint; For foreground pixels, the closer to the boundary, the larger |u i | is. First, sort the pixels in descending order according to the value of |u i |, and then delete them one by one, ensuring that the outermost pixels are always deleted first.

4. The method for anti-noise extraction of the skeleton of a binary image according to claim 1, characterized in that, the method for reducing the calculation amount during the refinement process is as follows: When the calculated u i equals 0, that is, when the neighborhood of the sample pixel is a completely symmetric region, set its Δx i to (0, 0).

5. The method for anti-noise extraction of the skeleton of a binary image according to claim 1, characterized in that, the method for reducing the calculation amount during the refinement process is as follows: Based on the Gaussian circle problem: where r is the radius of the circle, and N(r) is the number of pixel points contained in the neighborhood at this radius; when the radius reaches a certain threshold, save the relative positions of possible neighbor points in advance in the next iteration of the array, and in the next iteration, directly calculate the absolute positions of the points according to the relative positions in the array.

6. A system for anti-noise extraction of the skeleton of a binary image, characterized in that, it includes an image acquisition module and a processing module. The image acquisition module is used to acquire a binary image. The output end of the image acquisition module is connected to the processing module, and the processing module executes the method described in any one of claims 1 - 5 to perform skeleton extraction.

Citation Information

Patent Citations

  • Anti-noise Chinese character feature extraction method based on framework

    CN104156730A

  • Skeleton-based object component decomposition method

    CN107330901A