A method and device for extracting topological information of a main skeleton of an image
By using a pre-defined skeleton extraction algorithm and directional search to remove non-core branches, the problem of redundant branches and noise in skeletonization technology is solved, achieving efficient and robust extraction of image main skeleton topology information, thus improving the speed and accuracy of image processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2026-04-07
AI Technical Summary
Existing skeletonization techniques, when processing images with complex structures, extract skeleton maps containing a large number of redundant branches and noise, resulting in high computational complexity and affecting the accuracy and robustness of subsequent tasks.
An initial skeleton graph is extracted using a preset skeleton extraction algorithm. The type of skeleton points is determined, non-main branches are deleted, and the process is repeated iteratively until there are no intersections. A directional search is then performed to obtain the topological information of the main skeleton graph.
It reduces computational complexity, simplifies data volume, improves image processing speed and robustness, and enhances the accuracy and stability of subsequent tasks.
Smart Images

Figure CN119152218B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and apparatus for extracting the topological information of the main skeleton of an image. Background Technology
[0002] In image processing and computer vision, shape feature extraction is a crucial research area. Shape features not only aid in understanding objects in images but also provide strong support for subsequent classification, recognition, and analysis tasks. Skeletonization is one of the key techniques for shape feature extraction and has been widely applied in various scenarios. Specifically, skeletonization extracts the central axis of a shape from a binary image. This axis not only represents the main outline of the shape but also preserves key topological information of the original shape. This makes the skeleton play a vital role in image processing tasks, especially in shape analysis and feature extraction.
[0003] The core of skeletonization technology lies in simplifying the shape information of an image, reducing data redundancy, and preserving the topological structure of the shape. This technology can effectively improve the efficiency of image processing, especially in scenarios that require processing large amounts of image data, where skeletonization can significantly reduce computational complexity. Furthermore, the central axis generated by skeletonization has good invariance, resisting the effects of noise and shape deformation to a certain extent, providing a stable feature base for subsequent image analysis and recognition. For these reasons, skeletonization technology has been widely applied and extensively studied in fields such as medical image analysis, object recognition, and robot navigation. Summary of the Invention
[0004] To better extract the main skeleton of an image, this invention provides a method and apparatus for extracting the topological information of the main skeleton of an image.
[0005] In a first aspect, embodiments of the present invention provide a method for extracting the main skeleton topology information of an image, which may include:
[0006] Based on the acquired target image, a preset skeleton extraction algorithm is used to extract an initial skeleton image;
[0007] Based on the neighborhood of each skeleton point in the initial skeleton graph, the type of each skeleton point is determined; the types of skeleton points include intersection points, isolated points, endpoints, and interior points.
[0008] Based on all the intersections in the initial skeleton diagram, multiple skeleton branches are distinguished;
[0009] Identify non-main branches from the plurality of skeleton branches;
[0010] Delete the non-core branches in the initial skeleton diagram to obtain the updated skeleton diagram;
[0011] Based on the preset skeleton extraction algorithm, the updated skeleton map is re-extracted to obtain a new initial skeleton map, and it is determined whether there are intersections in the new initial skeleton map:
[0012] If so, then based on all the intersections in the new initial skeleton diagram, the non-main branches are re-determined to obtain a new updated skeleton diagram, and the skeleton extraction and discrimination steps described above are performed.
[0013] If not, then the new initial skeleton diagram will be used as the main skeleton diagram;
[0014] A directional search is performed on the main skeleton graph to obtain its topological information.
[0015] In one or more optional embodiments of this application, determining the type of each skeleton point based on the neighborhood of each skeleton point in the initial skeleton graph includes:
[0016] For each skeleton point in the initial skeleton graph, the 8-neighborhood algorithm is used to determine the values of the 8 neighbors of the skeleton point.
[0017] Based on the values of the eight neighbors of the skeleton point, the values of each neighbor of the skeleton point are updated according to a preset order by subtracting the values of the eight neighbors of the skeleton point.
[0018] The type of the skeleton point is determined based on the total number of positive values among the eight neighborhood values of the skeleton point.
[0019] In one or more optional embodiments of this application, updating the value of each neighborhood of the skeleton point by subtracting the values of the eight neighborhoods of the skeleton point in a preset order includes:
[0020] Sort the eight neighborhoods of the skeleton point according to the preset rotation direction;
[0021] For each neighborhood of the skeleton point, calculate the difference between the neighborhood and the next neighborhood;
[0022] The value of the neighborhood is updated to the difference between the neighborhood and the next neighborhood.
[0023] In one or more optional embodiments of this application, determining the type of the skeleton point based on the total number of positive values in the eight neighborhoods of the skeleton point includes:
[0024] If the total number of positive values among the 8 neighborhoods of the skeleton point is 0, then the skeleton point is an isolated point;
[0025] If the total number of positive values among the 8 neighborhoods of the skeleton point is 1, then the skeleton point is an endpoint;
[0026] If the total number of positive values among the 8 neighborhoods of the skeleton point is 2, then the skeleton point is an interior point;
[0027] If the total number of positive values in the eight neighborhoods of the skeleton point is greater than or equal to 3, then the skeleton point is an intersection point.
[0028] In one or more optional embodiments of this application, after determining the type of each skeleton point based on the neighborhood of each skeleton point in the initial skeleton graph, the method further includes:
[0029] Delete all isolated points in the initial skeleton graph.
[0030] In one or more optional embodiments of this application, distinguishing multiple skeleton branches based on all the intersections in the initial skeleton diagram includes:
[0031] Remove all intersections and their neighborhoods from the initial skeleton graph to obtain a segmented skeleton graph;
[0032] Detect multiple connected components in the segmented skeleton graph and treat each connected component as a skeleton branch.
[0033] In one or more optional embodiments of this application, determining non-trunk branches from the plurality of skeleton branches includes:
[0034] The average value of the branch skeleton points is calculated based on the total number of skeleton points in each skeleton branch.
[0035] The trunk threshold is determined based on the average value of the branch skeleton points;
[0036] Skeleton branches with a total number of skeleton points less than the trunk threshold are designated as non-trunk branches.
[0037] In a second aspect, embodiments of the present invention provide an apparatus for extracting the topological information of the main skeleton of an image, which may include:
[0038] The first extraction module is used to extract an initial skeleton map based on the acquired target image using a preset skeleton extraction algorithm.
[0039] The first discrimination module is used to determine the type of each skeleton point based on the neighborhood of each skeleton point in the initial skeleton graph; the types of skeleton points include intersection points, isolated points, endpoints, and interior points;
[0040] The second extraction module is used to distinguish multiple skeleton branches based on all the intersections in the initial skeleton diagram;
[0041] The third extraction module is used to identify non-main branches from the plurality of skeleton branches;
[0042] The first deletion module is used to delete the non-main branches in the initial skeleton diagram to obtain an updated skeleton diagram.
[0043] The first judgment module is used to re-execute the first extraction module and the first discrimination module based on the updated skeleton map to obtain the type of each skeleton point in the new initial skeleton map, and to determine whether there are intersection points in the new initial skeleton map. If yes, then based on the new initial skeleton map, the second extraction module, the third extraction module, and the first deletion module will re-obtain the new updated skeleton map, and the first judgment module will re-judge it. If no, the new initial skeleton map will be used as the main skeleton map.
[0044] The first search module is used to perform a directional search in the main skeleton graph to obtain the topological information of the main skeleton graph.
[0045] Thirdly, embodiments of the present invention provide a computer-readable storage medium having a computer program / instruction stored thereon, which, when executed by a processor, implements the method for extracting the main skeleton topology information of an image as described above.
[0046] Fourthly, embodiments of the present invention provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the method for extracting the main skeleton topology information of an image as described above.
[0047] Fifthly, embodiments of the present invention provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method for extracting the main skeleton topology information of an image as described above.
[0048] The beneficial effects of the above-described technical solutions provided in the embodiments of the present invention include at least the following:
[0049] This invention provides a method for extracting the topological information of the main skeleton of an image. The method extracts the skeleton of the target image based on a preset skeleton extraction algorithm to obtain an initial skeleton map. Then, based on the neighborhood of each skeleton point in the initial skeleton map, it identifies intersections. Based on these intersections, multiple skeleton branches are obtained. Further, non-core branches among these branches are identified and deleted from the initial skeleton map to obtain an updated skeleton map. Next, the updated skeleton map is re-extracted using the preset skeleton extraction algorithm to obtain a new initial skeleton map. It is then determined whether intersections still exist. If so, non-core branches are re-identified to obtain a new updated skeleton map; otherwise, the new initial skeleton map is used as the main skeleton map. Finally, the topological information is determined based on the main skeleton map. This method has low computational complexity. Compared to the complete skeleton map, the extracted main skeleton map retains the main topological structure of the image shape, effectively simplifying the data, reducing computational complexity, and thus improving data processing speed. It is more suitable for large-scale image data and real-time applications. Meanwhile, the main skeleton graph ignores the tiny branches and noise in the complete skeleton graph and focuses on capturing global shape information, making the extracted main skeleton graph more robust and better able to cope with data noise. It can exhibit higher accuracy and stability in subsequent classification, recognition and other tasks, and can effectively reduce the complexity of subsequent processing.
[0050] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.
[0051] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0052] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0053] Figure 1 This is a schematic diagram illustrating the steps of a method for extracting the main skeleton topology information of an image according to an embodiment of the present invention;
[0054] Figure 2 This is a schematic diagram illustrating an example of a target image provided in an embodiment of the present invention;
[0055] Figure 3 This is a schematic diagram of a second example of a target image provided in an embodiment of the present invention;
[0056] Figure 4 This is a schematic diagram of an example of an initial skeleton diagram provided in an embodiment of the present invention;
[0057] Figure 5 This is a second schematic diagram of an example of an initial skeleton diagram provided in an embodiment of the present invention;
[0058] Figure 6 This is a schematic diagram of one example of the skeletonization effect provided in an embodiment of the present invention;
[0059] Figure 7 This is a second schematic diagram illustrating the skeletonization effect provided in an embodiment of the present invention.
[0060] Figure 8 This is a schematic diagram of eight neighboring points of a skeleton point provided in an embodiment of the present invention;
[0061] Figure 9 A schematic diagram illustrating one type of skeleton point provided in an embodiment of the present invention;
[0062] Figure 10 A schematic diagram illustrating the types of skeleton points provided in embodiments of the present invention;
[0063] Figure 11 This is a second schematic diagram illustrating the types of skeleton points provided in an embodiment of the present invention;
[0064] Figure 12 A second schematic diagram illustrating the types of skeleton points provided in this embodiment of the invention;
[0065] Figure 13 This is a schematic diagram of one example of a segmented skeleton diagram provided in an embodiment of the present invention;
[0066] Figure 14 This is a second schematic diagram of a segmented skeleton diagram provided in an embodiment of the present invention;
[0067] Figure 15 A schematic diagram of one example of a skeleton branch provided in an embodiment of the present invention;
[0068] Figure 16 A second schematic diagram illustrating a skeleton branch example provided in an embodiment of the present invention;
[0069] Figure 17 This is a schematic diagram of an example of an updated skeleton diagram provided in an embodiment of the present invention;
[0070] Figure 18 This is a second schematic diagram of an example of an updated skeleton diagram provided in an embodiment of the present invention;
[0071] Figure 19 This is a schematic diagram illustrating an example of pixel deviation provided in an embodiment of the present invention;
[0072] Figure 20 A schematic diagram illustrating a detail of a pixel deviation example provided in an embodiment of the present invention;
[0073] Figure 21 This is a second schematic diagram illustrating a pixel deviation example provided in an embodiment of the present invention;
[0074] Figure 22 A second schematic diagram illustrating the details of a pixel deviation example provided in an embodiment of the present invention;
[0075] Figure 23 This is a schematic diagram of an example of the main skeleton diagram provided in an embodiment of the present invention;
[0076] Figure 24 This is a second schematic diagram of the main skeleton diagram provided in an embodiment of the present invention;
[0077] Figure 25 This is a schematic diagram of the neighborhood search path provided in an embodiment of the present invention;
[0078] Figure 26 This is a schematic diagram of an abnormal search scenario provided in an embodiment of the present invention;
[0079] Figure 27 This is a second schematic diagram illustrating an abnormal search scenario provided in an embodiment of the present invention;
[0080] Figure 28 This is a schematic diagram illustrating a directional diffusion search example provided in an embodiment of the present invention;
[0081] Figure 29 This is a schematic diagram of the device for extracting the topological information of the main skeleton of an image provided in an embodiment of this application. Detailed Implementation
[0082] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0083] The inventors discovered that in existing technologies, target images often possess complex structures. Existing skeletonization techniques extract all the skeletons from the target image, resulting in skeleton maps containing complex branches. While skeleton maps can completely represent the shape of the image, they also involve numerous processing strategies and complex discrimination logic, significantly increasing data volume and computational burden, especially in applications requiring real-time processing. Furthermore, skeleton maps are prone to noise and redundant information, leading to model confusion in subsequent classification and recognition tasks, reducing their generalization ability, accuracy, and robustness.
[0084] Based on this, the inventors conducted further research and development and developed this invention, which provides a method and apparatus for extracting the topological information of the main skeleton of an image.
[0085] Example 1
[0086] Embodiment 1 of the present invention provides a method for extracting the topological information of the main skeleton of an image, referring to... Figure 1 As shown, the method may include the following steps S101-S109:
[0087] S101: Based on the acquired target image, a preset skeleton extraction algorithm is used to extract the initial skeleton map.
[0088] S102: Based on the neighborhood of each skeleton point in the initial skeleton graph, determine the type of each skeleton point. The types of skeleton points include intersection points, isolated points, endpoints, and interior points.
[0089] S103: Based on all the intersections in the initial skeleton diagram, distinguish multiple skeleton branches.
[0090] S104: Identify non-trunk branches from multiple skeleton branches.
[0091] S105: Delete the non-core branches in the initial skeleton diagram to obtain the updated skeleton diagram.
[0092] S106: Based on the updated skeleton diagram, repeat the above steps S101-S102 to obtain a new initial skeleton diagram, and determine whether there are intersections in the new initial skeleton diagram: if yes, proceed to step S107; if no, proceed to step S108.
[0093] S107: Repeat steps S103-S106 based on the new initial skeleton diagram.
[0094] S108: Use the new initial skeleton diagram as the main skeleton diagram.
[0095] S109: Perform a directional search in the main skeleton graph to obtain the topological information of the main skeleton graph.
[0096] This invention provides a method for extracting the topological information of the main skeleton of an image. The method extracts the skeleton of the target image based on a preset skeleton extraction algorithm to obtain an initial skeleton map. Then, based on the neighborhood of each skeleton point in the initial skeleton map, it identifies intersections. Based on these intersections, multiple skeleton branches are obtained. Further, non-core branches among these branches are identified and deleted from the initial skeleton map to obtain an updated skeleton map. Next, the updated skeleton map is re-extracted using the preset skeleton extraction algorithm to obtain a new initial skeleton map. It is then determined whether intersections still exist. If so, non-core branches are re-identified to obtain a new updated skeleton map; otherwise, the new initial skeleton map is used as the main skeleton map. Finally, the topological information is determined based on the main skeleton map. This method has low computational complexity. Compared to the complete skeleton map, the extracted main skeleton map retains the main topological structure of the image shape, effectively simplifying the data, reducing computational complexity, and thus improving data processing speed. It is more suitable for large-scale image data and real-time applications. Meanwhile, the main skeleton graph ignores the tiny branches and noise in the complete skeleton graph and focuses on capturing global shape information, making the extracted main skeleton graph more robust and better able to cope with data noise. It can exhibit higher accuracy and stability in subsequent classification, recognition and other tasks, and can effectively reduce the complexity of subsequent processing.
[0097] In step S101 above, the target image is skeletonized using a preset skeleton extraction algorithm to obtain an initial skeleton map.
[0098] Those skilled in the art can select existing algorithms as preset skeleton extraction algorithms according to specific circumstances, such as the Zhang-Suen algorithm, the Hilditch algorithm, etc., and no specific limitation is required in the embodiments of this application.
[0099] In one specific embodiment, the Zhang-Suen algorithm is used as the preset skeleton extraction algorithm. An example is given to illustrate the skeletonization operation in step S101 above, where two target images are shown below. Figure 2 , Figure 3 As shown, both target images are processed binarized images. Figure 2 The initial skeleton map obtained by skeletonizing the target image shown is as follows: Figure 4 As shown, the extracted initial skeleton image is also a binarized image, with white pixels representing skeleton points. Similarly, Figure 3 The initial skeleton diagram corresponding to the target image shown is as follows: Figure 5 As shown. Furthermore, to more intuitively demonstrate the effect of skeletonization, all skeleton points from the initial skeleton image are superimposed onto the original target image. Figure 2 The skeletonization effect diagram corresponding to the target image shown is as follows: Figure 6 As shown, the blue dots represent all the extracted skeleton points. Similarly, Figure 3 The skeletonization effect diagram corresponding to the target image shown is as follows: Figure 7 As shown, the initial skeleton map effectively preserves the core structure of the target image's geometry, simplifying and abstracting the target image's shape, thus providing a foundation for subsequent main skeleton extraction.
[0100] In step S102 above, the type of each skeleton point is determined based on the neighborhood of each skeleton point in the initial skeleton map. Specifically, this includes the following steps S1021-S1023:
[0101] S1021: For each skeleton point in the initial skeleton graph, the 8-neighborhood algorithm is used to determine the values of the 8 neighbors of the skeleton point.
[0102] Specifically, this could involve obtaining the values of the eight neighborhoods of each skeleton point in the initial skeleton graph. For example, skeleton point P... i,j The 8 neighborhoods are as follows Figure 8 As shown, the middle P i,j Let i and j be the skeleton point, representing the coordinates of the skeleton point in the initial skeleton graph. The 8 neighborhoods of the skeleton point are P... i-1,j-1 P i-1,j P i-1,j+1 P i,j-1 P i,j+1 P i+1,j-1 P i+1,j and P i+1,j+1 .
[0103] S1022: Based on the values of the 8 neighbors of the skeleton point, subtract them in a preset order to update the value of each neighbor of the skeleton point. Specifically, this includes the following steps S10221-S10223:
[0104] S10221: Sort the 8 neighborhoods of the skeleton point according to the preset rotation direction.
[0105] Specifically, starting from any neighborhood, the eight neighborhoods of the skeleton point can be sorted according to a preset rotation direction. The preset rotation direction can be clockwise or counterclockwise.
[0106] In one specific embodiment, with Figure 8 The skeleton point P shown i,j Taking the 8-neighborhood as an example, starting from the top left neighbor P... i-1,j-1 First, sort the 8 neighbors of the skeleton point clockwise. The order of the 8 neighbors after sorting is P. i-1,j-1 P i-1,j P i-1,j+1 P i,j+1 P i+1,j+1 P i+1,j P i+1,j-1 Pi,j-1 .
[0107] S10222: For each neighborhood of a skeleton point, calculate the difference between the neighborhood and the next neighborhood.
[0108] S10223: Update the value of the neighborhood to the difference between the neighborhood and the next neighborhood.
[0109] In one specific embodiment, the expression for updating the skeleton points in step S1022 is shown in the following formula:
[0110] P' i-1,j-1 =P i-1,j -P i-1,j-1 Formula 1
[0111] P' i-1,j =P i-1,j+1 -P i-1,j Formula 2 ...
[0113] P' i+1,j-1 =P i,j-1 -P i+1,j-1 Formula 3
[0114] P' i,j-1 =P i-1,j-1 -P i,j-1 Formula 4
[0115] In the formula, P′ i-1,j-1 、P′ i-1,j 、P′ i+1,j-1 、P′ i,j-1 This represents the updated neighborhood.
[0116] S1023: Determine the type of the skeleton point based on the total number of positive values among the 8 neighborhood values of the skeleton point.
[0117] Specifically, skeleton points can be categorized into isolated points, endpoints, interior points, and intersections. An isolated point is a single skeleton point that is not connected to any other skeleton points; it is an isolated point in the initial skeleton graph. An endpoint is a skeleton point that is connected to only one skeleton point; it is a branch of a skeleton branch. An interior point is a skeleton point that is connected to two skeleton points. An intersection is a skeleton point that is connected to three or more skeleton points; it is a point where multiple skeleton branches intersect.
[0118] The values of the 8 neighborhoods of the skeleton point updated in step S1022 above can represent the connection between the skeleton point and other skeleton points. Therefore, the type of the skeleton point can be determined based on the total number of positive values in the 8 neighborhoods of the skeleton point. Specifically, the type of the skeleton point is determined as follows:
[0119] If the total number of positive values in the 8 neighborhoods of a skeleton point is 0, then the skeleton point is an isolated point. If the total number of positive values in the 8 neighborhoods of a skeleton point is 1, then the skeleton point is an endpoint. If the total number of positive values in the 8 neighborhoods of a skeleton point is 2, then the skeleton point is an interior point. If the total number of positive values in the 8 neighborhoods of a skeleton point is greater than or equal to 3, then the skeleton point is an intersection point.
[0120] In one specific embodiment, based on Figure 2 The target image shown, after being processed by steps S101-S102, has had its type of each skeleton point identified. A schematic diagram illustrating how the type of each skeleton point is marked with a different color in the target image is shown below. Figure 9 As shown, the red boxes mark the endpoints and intersections. Detailed diagrams are as follows: Figure 10 As shown, red dots represent endpoints, blue dots represent intersections, and green dots represent interior points. Similarly, based on... Figure 3 The target image shown is illustrated below with a diagram indicating the type of skeleton points. Figure 11 As shown in the detailed image... Figure 12 As shown.
[0121] In this embodiment of the application, since the purpose of this application is to extract the main skeleton of the target image, and isolated points usually do not contribute to the extraction of the main skeleton, it is necessary to delete the isolated points in the initial skeleton map after step S102.
[0122] In this embodiment, step S102 determines the type of each skeleton point, effectively identifying intersections in the initial skeleton diagram and clarifying the connection relationships between different parts of the initial skeleton diagram, which helps to distinguish different branches of the skeleton later. Simultaneously, isolated points in the initial skeleton diagram are deleted, simplifying redundant information and reducing the amount of subsequent data processing.
[0123] In step S103 above, multiple skeleton branches are divided from the initial skeleton diagram based on all intersections. Specifically, this includes the following steps S1031-S1032:
[0124] S1031: Remove all intersections and their neighborhoods from the initial skeleton graph to obtain a segmented skeleton graph.
[0125] Specifically, based on the initial skeleton graph, all intersections and the 8-neighborhood of each intersection are deleted, that is, the value of the pixel is set to 0 (black). At this time, the skeleton in the initial skeleton graph is no longer completely connected, but is divided into multiple skeleton branches.
[0126] In one specific embodiment, based on Figure 4 The initial skeleton diagram shown is followed by the segmented skeleton diagram. Figure 13 As shown, similarly, based on Figure 5 The initial skeleton diagram shown is followed by the segmented skeleton diagram. Figure 14 As shown, the pixels in the area that were originally intersections have all turned black, and the entire skeleton is no longer connected.
[0127] S1032: Detect multiple connected components in the segmented skeleton graph and treat each connected component as a skeleton branch.
[0128] Specifically, after the processing in step S1031 above, a segmented skeleton graph containing multiple skeleton branches is obtained. However, at this point, the skeleton points of each skeleton branch are discrete, which is not convenient for subsequent unified processing of each skeleton branch. Therefore, it is also necessary to detect the connected components in the segmented skeleton graph, obtain the connected components of all independent skeleton branches in the segmented skeleton graph, and obtain multiple skeleton branches {B1, B2, ..., B...} n}
[0129] Those skilled in the art can implement connected component detection based on the detailed description of the prior art, such as using the findContours function in the open-source image processing library OpenCV. No specific limitations are required in the embodiments of this application.
[0130] In one specific embodiment, based on Figure 13 The segmented skeleton diagram shown yields three skeleton branches as follows: Figure 15 As shown, similarly, based on Figure 14 The segmented skeleton diagram shown yields three skeleton branches as follows: Figure 16 As shown in the figure, three skeleton branches are displayed in the original target image using different colors.
[0131] In this embodiment of the application, step S103 distinguishes multiple skeleton branches from the initial skeleton diagram, clarifies the hierarchical relationship of the skeleton structure in the initial skeleton diagram, and lays the foundation for subsequent identification of non-main branches.
[0132] In step S104 above, non-trunk branches are identified from multiple skeleton branches. Specifically, this includes the following steps S1041-S1043:
[0133] S1041: Calculate the average value of the skeleton points of each skeleton branch based on the total number of skeleton points in each skeleton branch.
[0134] Specifically, the average value of the skeleton points of each skeleton branch can be calculated using the following formula 5, based on the total number of skeleton points in each skeleton branch:
[0135]
[0136] In the formula, S avg Let be the mean of the branch skeleton points, and n be the total number of skeleton branches. For skeleton branch B i The total number of skeleton points, B i This represents the i-th skeleton branch.
[0137] S1042: Determine the trunk threshold based on the mean of branch skeleton points.
[0138] Specifically, the trunk threshold can be obtained by multiplying a preset trunk multiple by the average value of the branch skeleton points. For example, if the preset trunk multiple is 0.6, the formula for calculating the trunk threshold is shown in Formula 6 below:
[0139] S th =0.6*S avg Formula 6
[0140] In the formula, S th Main threshold, S avg 0.6 is the average value of the branch skeleton points, and 0.6 is the preset trunk multiple.
[0141] S1043: Skeleton branches with a total number of skeleton points less than the trunk threshold are treated as non-trunk branches.
[0142] Specifically, this could involve selecting skeleton branches from all skeleton branches whose total number of skeleton points is less than the trunk threshold, and classifying these skeleton branches as non-trunk branches.
[0143] In step S105 above, non-core branches in the initial skeleton diagram are deleted to obtain the updated skeleton diagram.
[0144] Specifically, based on the non-main branches determined in step S104 above, the non-main branches in the initial skeleton diagram can be deleted, that is, the values of all pixels in the non-main branches can be set to 0 to obtain the updated skeleton diagram.
[0145] Please note that the initial skeleton diagram here is obtained through step S101. The processing in step S103 above is only for determining the skeleton branches and does not process the initial skeleton diagram.
[0146] In one specific embodiment, based on Figure 4 The initial skeleton diagram shown is followed by the updated skeleton diagram obtained after deleting non-core branches, as shown below. Figure 17 As shown, similarly, based on Figure 5 The initial skeleton diagram shown is followed by the updated skeleton diagram. Figure 18 As shown.
[0147] In this embodiment of the application, after completing step S105 and obtaining the updated skeleton map, the inventors found that, in order to prevent incomplete segmentation when determining the skeleton branches in step S103, the method removed the intersection points and the eight neighborhoods of the intersection points. Therefore, the updated skeleton map obtained will have pixel deviations at the original intersection points. Moreover, executing only one round of steps S101-S105 cannot guarantee that all non-main branches have been successfully deleted. Therefore, it is necessary to continue processing the updated skeleton map to ensure that there are no pixel deviations and that all non-main branches have been successfully deleted.
[0148] To assist those skilled in the art in understanding what pixel deviation is, the following example of an updated skeleton diagram provided in an embodiment of this application illustrates pixel deviation. Figure 17 The updated skeleton diagram shown illustrates an example of pixel deviation. Figure 19 As shown, the red box indicates the original location of the intersection point, and the detailed image within the red box is as follows. Figure 20 As shown, there are redundant pixels to the right of the original intersection point, indicating a pixel offset. Similarly, based on... Figure 18 The updated skeleton diagram shown illustrates an example of pixel deviation. Figure 21 As shown, the red box indicates the original location of the intersection point, and the detailed image within the red box is as follows. Figure 22 As shown, there are extra pixels below the original intersection point, indicating a pixel deviation.
[0149] In step S106 above, steps S101-S102 are re-executed based on the updated skeleton diagram to obtain a new initial skeleton diagram, and it is determined whether there are intersections in the new initial skeleton diagram: if yes, step S107 is executed; if no, step S108 is executed.
[0150] Specifically, it can be that step S101 is re-executed based on the updated skeleton map. The preset skeleton extraction algorithm in step S101 will remove the pixel deviation in the updated skeleton map and extract a new initial skeleton map. Then, step S102 is executed based on the new initial skeleton map to determine the type of each skeleton point and determine whether there are any intersection points. If yes, step S107 is executed; if no, step S108 is executed.
[0151] In step S107 above, steps S103-S106 are re-executed based on the new initial skeleton diagram.
[0152] Specifically, if there are still intersections in the new initial skeleton diagram, it means that there are still non-main branches that have not been deleted. Then, based on the new initial skeleton diagram, steps S103-S106 are re-executed to delete the newly found non-main branches.
[0153] In step S108 above, the new initial skeleton diagram is used as the main skeleton diagram.
[0154] Specifically, it could be that at this point, there are no intersections in the new initial skeleton diagram, which means there is only one skeleton branch. This skeleton branch is the main skeleton, and the new initial skeleton diagram is the main skeleton diagram.
[0155] In one specific embodiment, based on Figure 2 The target image shown yields the following main skeleton diagram: Figure 23 As shown, similarly, based on Figure 3 The target image shown yields the following main skeleton diagram: Figure 24 As shown, at this point, the pixel deviation has been successfully eliminated in the main skeleton diagram, and there is only one skeleton branch.
[0156] In step S109 above, a directional search is performed in the main skeleton graph to obtain the topological information of the main skeleton graph.
[0157] In this embodiment of the application, after obtaining the main skeleton map, when further analyzing the graphic morphology of the target image, it is necessary to establish the topological relationship between the endpoints of the skeleton points and the interior points and the endpoints to determine the topological information.
[0158] Specifically, it could be that an endpoint in the main skeleton diagram is selected as the starting seed point, and then... Figure 25 The neighborhood search path shown is used to search for the next skeleton point. The found next skeleton point is used as the new seed point, and the pixel value corresponding to the previous seed point is set to 0. The search continues until the next skeleton point cannot be found.
[0159] However, the inventors discovered that during the search process based on neighborhood search paths, the order in which the search paths are set may cause newly found seed points to fail to find subsequent seed points in the correct direction, such as... Figure 26 and Figure 27 The diagram illustrates an abnormal search scenario. In the image, boxes represent skeleton points, red represents the starting endpoint, green represents seed points found in the search order, blue represents breakpoints caused by not finding the desired point, and white represents unsearched skeleton points. The numbers in the red and green boxes indicate the search order of the seed points. Figure 26 For example, it can be seen that when the green box with the number 1 is used as the seed point, due to the order of the search path, the green box with the number 2 is used as the next seed point. Furthermore, when the green box with the number 2 is used as the seed point, the green box with the number 3 is used as the next seed point. However, at this time, there are no unsearched skeleton points in the neighborhood of the green box with the number 3, which leads to search anomalies.
[0160] In this embodiment of the application, a new search method is introduced to address the problem of search anomalies, enabling targeted expanded search to avoid search anomalies. Specifically, it includes:
[0161] Record the previous sub-point P during the search process. n-1 With the current seed point P n The neighborhood position relationship of the current seed point P n When performing a neighborhood search, remove the previous sub-point P. n-1 The neighborhood of the search term P is searched for the next sub-point. n-1 Point to the current seed point P n and the direction of diffusion, such as the seed point P above. n-1 If it is located at position i in the neighborhood, then for the current seed point P n It is necessary to analyze the current seed point P. n Search the skeleton points in the directional neighborhood {(i+7)mod(8),(i+6)mod(8),(i)mod(8),(i+1)mod(8),(i+2)mod(8)} to find the next seed point. A specific example is shown below. Figure 28 As shown, the current seed point P n Located at the previous sub-point P n-1 If the neighboring 4 bits of the current seed point are the same, then when searching for the next seed point, the current seed point only needs to search the current seed point P. n The skeleton points of the oriented neighborhood {2, 3, 4, 5, 6}. Where (i)mod(8) means taking the modulus of i with respect to 8.
[0162] If the current seed point P n If no unsearched skeleton point is found within the directional neighborhood, the seed point is reset to the previous seed point, and the search continues until all points have been searched, thus obtaining the connectivity matrix, i.e., the topological information.
[0163] Example 2
[0164] Based on the same inventive concept, embodiments of the present invention also provide a device for extracting the topological information of the main skeleton of an image, referring to... Figure 29 As shown, the device includes:
[0165] The first extraction module 101 is used to extract an initial skeleton map based on the acquired target image using a preset skeleton extraction algorithm.
[0166] The first discrimination module 102 is used to determine the type of each skeleton point based on the neighborhood of each skeleton point in the initial skeleton graph; the type of the skeleton point includes intersection points.
[0167] The second extraction module 103 is used to distinguish multiple skeleton branches based on all the intersections in the initial skeleton diagram;
[0168] The third extraction module 104 is used to identify non-main branches from the plurality of skeleton branches;
[0169] The first deletion module 105 is used to delete the non-main branches in the initial skeleton diagram to obtain an updated skeleton diagram.
[0170] The first judgment module 106 is used to re-execute the first extraction module and the first discrimination module based on the updated skeleton map to obtain the type of each skeleton point in the new initial skeleton map, and to determine whether there are intersection points in the new initial skeleton map: if yes, then based on the new initial skeleton map, the second extraction module, the third extraction module, and the first deletion module re-obtain the new updated skeleton map, and the first judgment module re-judges it; if no, the new initial skeleton map is used as the main skeleton map.
[0171] The first search module 107 is used to perform a directional search in the main skeleton graph to obtain the topological information of the main skeleton graph.
[0172] Example 3
[0173] Based on the same inventive concept, embodiments of the present invention also provide a computer-readable storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the method for extracting image main skeleton topology information as described in Embodiment 1 above.
[0174] Example 4
[0175] Based on the same inventive concept, embodiments of the present invention also provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the method for extracting image main skeleton topology information as described in Embodiment 1 above.
[0176] Example 5
[0177] Based on the same inventive concept, embodiments of the present invention also provide a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method for extracting image main skeleton topology information as described in Embodiment 1 above.
[0178] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0179] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0180] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0181] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0182] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims and their equivalents, this invention is also intended to include these modifications and variations.
Claims
1. A method for extracting the topological information of the main skeleton of an image, characterized in that, include: Based on the acquired target image, a preset skeleton extraction algorithm is used to extract an initial skeleton image; For each skeleton point in the initial skeleton graph, the 8-neighborhood algorithm is used to determine the values of the 8 neighbors of the skeleton point; based on the values of the 8 neighbors of the skeleton point, the difference is calculated in a preset order to update the value of each neighbor of the skeleton point; based on the total number of positive values among the 8 neighbors of the skeleton point, the type of the skeleton point is determined, and the type of the skeleton point includes intersection point, isolated point, endpoint, and interior point; Based on all the intersections in the initial skeleton diagram, multiple skeleton branches are distinguished; Identify non-main branches from the plurality of skeleton branches; Delete the non-core branches in the initial skeleton diagram to obtain the updated skeleton diagram; Based on the preset skeleton extraction algorithm, the updated skeleton map is re-extracted to obtain a new initial skeleton map, and it is determined whether there are intersections in the new initial skeleton map: If so, then based on all the intersections in the new initial skeleton diagram, the non-main branches are re-determined to obtain a new updated skeleton diagram, and the skeleton extraction and discrimination steps described above are performed. If not, then the new initial skeleton diagram will be used as the main skeleton diagram; A directional search is performed on the main skeleton graph to obtain its topological information.
2. The method according to claim 1, characterized in that, The step of subtracting the values of the eight neighbors of the skeleton point in a preset order and updating the value of each neighbor of the skeleton point includes: The eight neighborhoods of the skeleton point are sorted according to a preset rotation direction; For each neighborhood of the skeleton point, calculate the difference between the neighborhood and the next neighborhood; The value of the neighborhood is updated to the difference between the neighborhood and the next neighborhood.
3. The method according to claim 1, characterized in that, Determining the type of the skeleton point based on the total number of positive values in its eight neighborhoods includes: If the total number of positive values among the 8 neighborhoods of the skeleton point is 0, then the skeleton point is an isolated point; If the total number of positive values among the 8 neighborhoods of the skeleton point is 1, then the skeleton point is an endpoint; If the total number of positive values among the 8 neighborhoods of the skeleton point is 2, then the skeleton point is an interior point; If the total number of positive values in the eight neighborhoods of the skeleton point is greater than or equal to 3, then the skeleton point is an intersection point.
4. The method according to claim 3, characterized in that, After determining the type of each skeleton point based on its neighborhood in the initial skeleton graph, the method further includes: Delete all isolated points in the initial skeleton graph.
5. The method according to claim 1, characterized in that, The step of distinguishing multiple skeleton branches based on all the intersections in the initial skeleton diagram includes: Remove all intersections and their neighborhoods from the initial skeleton graph to obtain a segmented skeleton graph; Detect multiple connected components in the segmented skeleton graph and treat each connected component as a skeleton branch.
6. The method according to claim 1, characterized in that, The step of determining non-trunk branches from the plurality of skeleton branches includes: Based on the total number of skeleton points in each skeleton branch, the average value of the branch skeleton points is calculated using the following formula; ; In the formula, Let be the mean of the branch skeleton points, and n be the total number of skeleton branches. For skeleton branches The total number of skeleton points, This represents the i-th skeleton branch; The trunk threshold is determined based on the average value of the branch skeleton points; Skeleton branches with a total number of skeleton points less than the trunk threshold are designated as non-trunk branches.
7. An apparatus for extracting topological information of the main skeleton of an image, characterized in that, include: The first extraction module is used to extract an initial skeleton map based on the acquired target image using a preset skeleton extraction algorithm. The first discrimination module is used to determine the values of the eight neighbors of each skeleton point in the initial skeleton graph using an 8-neighborhood algorithm; update the value of each neighbor of the skeleton point by subtracting the values of the eight neighbors in a preset order; and determine the type of the skeleton point based on the total number of positive values among the eight neighbors of the skeleton point. The types of the skeleton point include intersection points, isolated points, endpoints, and interior points. The second extraction module is used to distinguish multiple skeleton branches based on all the intersections in the initial skeleton diagram; The third extraction module is used to identify non-main branches from the plurality of skeleton branches; The first deletion module is used to delete the non-main branches in the initial skeleton diagram to obtain an updated skeleton diagram. The first judgment module is used to re-execute the first extraction module and the first discrimination module based on the updated skeleton map to obtain the type of each skeleton point in the new initial skeleton map, and to determine whether there are intersection points in the new initial skeleton map. If yes, then based on the new initial skeleton map, the second extraction module, the third extraction module, and the first deletion module will re-obtain the new updated skeleton map, and the first judgment module will re-judge it. If no, the new initial skeleton map will be used as the main skeleton map. The first search module is used to perform a directional search in the main skeleton graph to obtain the topological information of the main skeleton graph.
8. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When executed by a processor, the computer program / instruction implements the method for extracting the topological information of the main skeleton of an image as described in any one of claims 1-6.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method for extracting the main skeleton topology information of an image as described in any one of claims 1-6.
Citation Information
Patent Citations
River network topology information extraction method and system
CN110688961A