Skeleton extraction method based on run length coding
The binary image is refined through run encoding technology, which solves the problems of low computing efficiency and large storage requirements in traditional methods, and realizes efficient and fast skeleton extraction, which is suitable for large-scale image processing and maintains topological integrity.
Patent Information
- Application Number
- CN202510487591.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-08-01
AI Technical Summary
Traditional binary image refinement methods have low computational efficiency and excessive storage resource consumption in large-scale image processing, making it difficult to adapt to the needs of different application scenarios.
The skeleton extraction method based on run encoding is adopted, and the binary image is refined through run encoding technology, combining special processing of isolated points and rapid iterative update of boundary pixels, optimizes the storage space and calculation efficiency, and optimizes the refinement results through post-processing steps.
It significantly improves the speed and quality of image processing, reduces unnecessary computing overhead, adapts to large-scale image processing, maintains topological integrity, and supports diverse application scenarios.
Smart Images

Figure CN120411531A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a skeleton extraction method based on run-length encoding. Background Art
[0002] In image processing, a binary image consists of two colors, black and white, where black usually represents the background and white represents the target object. The thinning operation aims to extract the target object from the original image as a single-pixel-wide skeleton while maintaining its original topological structure. The thinning operation is usually applied to fields such as target recognition, morphological analysis, and path extraction, and is one of the core steps of many image processing algorithms.
[0003] In traditional binary image thinning operations, an iterative approach is usually used to gradually delete unnecessary pixels until the skeleton is finally obtained. However, for large-scale images or real-time processing applications, traditional methods may have problems of low computational efficiency and excessive consumption of storage resources. Since the thinning process involves multiple image scans and pixel judgments, this may lead to a long execution time of the algorithm and low processing efficiency for large images. At the same time, traditional methods need to store the entire image and multiple intermediate states in memory, increasing the storage requirements and limiting the processing capacity of the system. In addition, traditional methods rely on structural elements of fixed size, resulting in a sharp increase in computational and storage requirements when processing large images, and lack of flexibility, making it difficult to meet the requirements of different application scenarios. Summary of the Invention
[0004] The technical problem to be solved by the present invention is: to provide a skeleton extraction method based on run-length encoding, which proposes an efficient solution for the binary image thinning (skeletonization) operation through run-length encoding technology. This method optimizes the utilization of storage space and the execution efficiency of the algorithm while maintaining the image topological structure. By introducing special processing of isolated points and rapid iterative update of boundary pixels, unnecessary computational overhead is significantly reduced. At the same time, optional post-processing steps are supported to further optimize the thinning result, improving the overall image processing speed and quality, and providing important technical support for the development of image processing technology.
[0005] The technical solution adopted by the present invention to solve its technical problems is: a skeleton extraction method based on run-length encoding, including the following steps,
[0006] S1, input the run-length encoding of the region. The run-length encoding of the region consists of runs, and each run represents the continuous pixel values of one or part of the rows in the image; each run includes the row number l, the starting column cb, and the ending column ce;
[0007] S2. Set up a temporary image Pict. The temporary image Pict is an extended regional image, and each pixel in the temporary image Pict is initialized to INSIDE or BORDER;
[0008] S3. Check each pixel and its neighborhood, identify and remove isolated points;
[0009] S4. Refinement loop. By gradually deleting pixels that meet specific conditions, the region is shrunk while keeping its topology unchanged;
[0010] S5. Retain perfect points through a marking and retention mechanism;
[0011] S6. Perform post - processing after refinement so that the image finally meets the required quality and structural requirements;
[0012] S7. By restoring the temporarily removed isolated points and performing thresholding operations, the refined image is made consistent with the original region;
[0013] S8. By restoring the refined region to the original coordinate system, ensure the geometric consistency between the refined region and the original region.
[0014] Furthermore, in step S3 of the present invention, the way to identify isolated points is to check the eight - neighborhood of each pixel. If there are no INSIDE pixels in the neighborhood of the pixel, then the pixel is considered an isolated point and is removed from the image.
[0015] Furthermore, in step S4 of the present invention, the refinement loop includes the following steps
[0016] 1) Construct a neighborhood structure, and construct a neighborhood matrix for each pixel in the image;
[0017] 2) Define deletion conditions;
[0018] 3) Gradually traverse the pixels in the image. If a pixel meets the deletion conditions, mark the pixel as a candidate for deletion; otherwise, retain the pixel;
[0019] 4) Perform pixel deletion operations. After one traversal, delete all the pixels marked as candidates for deletion at once;
[0020] 5) Repeat the refinement loop, continuously checking and deleting pixels that meet the conditions;
[0021] 6) When it is found that no pixel meets the deletion conditions after traversing the entire image, stop the refinement operation.
[0022] Furthermore, in step S5 of the present invention, the types of perfect points are:
[0023] Corner points: Located at the corners of the region;
[0024] Local extreme points: Appear as local maxima or minima in the region contour or shape;
[0025] Region boundary points: Located on the region boundary.
[0026] Furthermore, the method for confirming the perfect points in the present invention is as follows:
[0027] For corner points, use the curvature method or the angle method to detect;
[0028] For local extreme points, judge by comparing the value of a point with the values of other points in its neighborhood;
[0029] For boundary points, confirm their positions by checking whether the neighborhood of the point contains background pixels.
[0030] Furthermore, in step S6 of the present invention, the post-processing methods include: removing small noise points after thinning to maintain the connectivity of the region; filling the holes after thinning to ensure the integrity of the region; smoothing the boundaries of the region to reduce jagged edges.
[0031] The beneficial effects of the present invention are that it solves the defects existing in the background technology,
[0032] 1) Improve computational efficiency: By using run-length encoding and dynamic boundary update, the computational overhead and processing time are significantly reduced.
[0033] 2) Reduce memory occupancy: Adopt a compact storage structure to optimize memory usage, suitable for processing large-scale images.
[0034] 3) Maintain topological integrity: Through topological rule constraints, ensure that the connectivity and key shape features are not damaged.
[0035] 4) Protect isolated points: Effectively detect and recover isolated points, prevent important information from being lost, and improve the robustness of the results.
[0036] 5) The results are accurate and compact: After thinning and post-processing, the output skeleton results are accurate and have no redundant pixels, suitable for subsequent analysis.
[0037] 6) Adapt to diverse scenarios: Can handle complex shapes, isolated points, and noise regions, with a wide range of applications.
[0038] 7) Easy to integrate and expand: The modular design is convenient for integration into different image processing systems and supports subsequent optimization at the same time.
[0039] 8) Support large-scale data processing: The high efficiency and memory-friendly characteristics of the algorithm make it suitable for large-scale image processing tasks. Description of the Drawings
[0040] Figure 1 It is a schematic structural diagram of a preferred embodiment of the present invention. Detailed implementation manners
[0041] Now, the present invention will be further described in detail with reference to the accompanying drawings and preferred embodiments. These drawings are all simplified schematic diagrams, only illustrating the basic structure of the present invention in a schematic manner, so they only show the components related to the present invention.
[0042] As Figure 1 shown, a skeleton extraction method based on run - length encoding effectively solves the problem of low storage and calculation efficiency in the prior art by combining run - length encoding technology with binary image dilation operation; the adopted strategies are as follows:
[0043] 1) Run - length encoding for optimized storage: Use run - length encoding to compactly store the binary image, reducing memory occupancy.
[0044] 2) Topological rule constraint: During the thinning process, detect and protect connectivity according to topological rules to prevent structural damage.
[0045] 3) Dynamic boundary processing: Use a list of boundary pixels to quickly locate the pixels to be processed, avoiding traversing the entire image and improving efficiency.
[0046] 4) Isolated point protection: Detect and temporarily remove isolated points to prevent them from being lost during thinning and finally restore them to the result.
[0047] 5) Auxiliary image for accelerating operations: Construct a small auxiliary image to map the original area, reducing the computational complexity.
[0048] 6) Fast iterative update: Utilize the fast iterative update mechanism of boundary pixels to significantly reduce unnecessary operations.
[0049] Specifically:
[0050] 1. Input: Run - length encoding (RLE) of the region
[0051] The given input is a run - length encoding of a region, which represents all adjacent pixel values in a binary image region, usually INSIDE (pixels inside the region) and BORDER (boundary pixels). Assume that the region is already represented as run - length encoding. Specifically, the run - length encoding of each region is usually composed of a set of runs, and each run represents the continuous pixel values of a row or part of a row in the image. Each run includes: l (row number), cb (starting column), ce (ending column).
[0052] 2. Set up a temporary image (Pict)
[0053] At the beginning of the algorithm, the region needs to be converted into a temporary image Pict, which is used for the thinning operation. Specifically, Pict is an extended region image, and its size is slightly larger than the original region (usually adding a border). Each pixel in Pict is initialized to INSIDE or BORDER, indicating whether the pixel is inside the region or on the border.
[0054] Let the boundary coordinates of the region be L1, C1, L2, C2. Then the width and height of Pict are respectively:
[0055] width = C2 - C1 + 3, height = L2 - L1 + 3. Initialize all pixels in Pict to INSIDE, and then mark the boundary pixels of the region as BORDER according to the run-length encoding of the region.
[0056] 3. Temporarily remove isolated points
[0057] Isolated points refer to points that have no adjacent INSIDE pixels. These points need to be temporarily removed during the thinning process because they do not affect the final skeleton. To identify isolated points, we need to check the neighborhood of each pixel.
[0058] For each pixel p, check its eight neighborhoods: {p0, p1, p2, p3, p4, p5, p6, p7}. If there are no INSIDE pixels in the neighborhood of pixel p, that is: p0 = p1 = p2 = p3 = p4 = p5 = p6 = p7 = 0. Then this pixel is considered an isolated point and is removed from the image.
[0059] 4. Thinning loop
[0060] 1) Construct the neighborhood structure
[0061] Construct a 3×3 neighborhood matrix for each pixel in the image, where the central pixel is denoted as p, and the eight surrounding pixels are numbered p0, p1, …, p7 in sequence.
[0062] 2) Define the deletion conditions
[0063] Set INSIDE pixels to be represented as 1, and background or border pixels to be represented as 0. For the central pixel p, check the pixel states in its neighborhood. For example:
[0064] When p4 (below the central pixel) is 0, it means that the area below it is the border or blank;
[0065] At the same time, it is required that at least one of p2 and p3 is 0 (that is, at least one of the upper or upper-left is empty);
[0066] And at least one of p6 and p5 is 0 (that is, at least one of the lower-right or right is empty).
[0067] If all the above conditions are satisfied, it is considered that the central pixel p meets the deletion condition and can be marked as a candidate for deletion.
[0068] For other pixels (such as p1, p7, etc.), a similar inspection method is adopted, but the order of the neighborhood positions needs to be adjusted to ensure symmetry in the judgment in each direction.
[0069] 3) Traverse the pixels in the image step by step
[0070] Traverse all the pixels in the image. For each pixel p and its corresponding 3×3 neighborhood, apply the aforementioned deletion conditions for judgment.
[0071] If the pixel p meets the deletion condition, mark this pixel as a candidate for deletion; otherwise, retain this pixel.
[0072] 4) Perform the pixel deletion operation
[0073] After one traversal, delete all the pixels marked as candidates for deletion at once, thereby reducing the size of the image area.
[0074] 5) Repeat the refinement loop
[0075] Repeat steps 3) and 4), continuously check and delete the eligible pixels. After each round of deletion operation, re-evaluate the neighborhood situation of the remaining pixels to ensure that the deletion operation does not damage the topological structure of the image area.
[0076] 6) Termination condition
[0077] When it is found that no pixel meets the deletion condition after traversing the entire image, stop the refinement operation, indicating that the image has reached the refinement goal.
[0078] 5. Retain "perfect points"
[0079] 1) Understand the concept of "perfect points":
[0080] "Perfect points" are key points that are expected to be retained during the region refinement process. These points play a decisive role in the shape and topological structure, and deleting them may damage the image structure or make the final result meaningless.
[0081] 2) Determine the types of perfect points:
[0082] Corner points: Located at the corners of the region, representing the key nodes of shape change.
[0083] Local extreme points: Appearing as local maxima or minima in the region contour or shape, which are important signs of the structure.
[0084] Region boundary points: Located on the region boundary, they are usually crucial for maintaining the connectivity and shape of the region.
[0085] 3) Use a detection method to confirm perfect points:
[0086] For corner points, use the curvature method or the angle method to detect.
[0087] For local extreme points, judge by comparing the value of a point with the values of other points in its neighborhood.
[0088] For boundary points, confirm their positions by checking whether the neighborhood of the point contains background pixels.
[0089] 4) Implement the "retained points" mechanism:
[0090] Before the thinning operation, perform a full scan of the image and mark all "perfect points" according to the above detection methods.
[0091] These marks will be used as the basis for not allowing deletion during the subsequent thinning process.
[0092] 5) Exclude perfect points during the thinning process:
[0093] In each pixel traversal and deletion operation, first check whether it is a marked perfect point.
[0094] If it is a perfect point, skip the deletion to ensure that these key points are retained throughout the thinning process.
[0095] 6) Repeat the detection and exclusion operations:
[0096] Continuously repeat the detection and marking steps throughout the thinning process to ensure that all perfect points are always correctly identified and excluded from the deletion operations as the image changes.
[0097] 6. Post - processing
[0098] During the image thinning process, although many thinning and deletion operations have been carried out, the thinned result may still have some unsatisfactory situations, or may cause some discontinuities, noises or defects in the image. At this time, the post - processing steps are particularly important. The purpose of post - processing is to correct the thinned image to ensure its quality and the integrity of its topological structure. The specific goals of post - processing usually include:
[0099] Remove small noises after thinning, and maintain the connectivity of the region. Fill the holes after thinning to ensure the integrity of the region. Smooth the boundaries of the region, reduce the jagged edges, and improve the visual effect of the image.
[0100] 7. Thresholding and restoring isolated points
[0101] After thinning and post - processing are completed, we need to threshold the image to determine which pixels belong to the final thinned region. This step usually converts the INSIDE pixels in the image to region outputs. At the same time, the isolated points that were temporarily deleted before are restored to the final region to ensure that the thinned region is consistent with the original region.
[0102] 8. Restore the original coordinate system
[0103] Since the region may have been moved to a new coordinate system during the processing, finally, the thinned region needs to be restored to the original coordinate system.
[0104] In this invention:
[0105] 1) Run - length encoding representation of the region:
[0106] The input is the run - length encoding (RLE) of the region, which is a compression method that can effectively represent adjacent pixel values (such as INSIDE and BORDER) in the image region, providing a basis for subsequent thinning operations.
[0107] 2) Construction of the temporary image Pict:
[0108] The thinning operation is carried out by constructing an extended temporary image Pict. This image is larger than the original region and contains more boundary information, which helps in the accurate processing of the region during thinning.
[0109] 3) Identification and temporary removal of isolated points:
[0110] By checking each pixel and its neighborhood, isolated points are identified and removed to ensure that the thinning process is not interfered by these points, which is crucial for maintaining the skeleton structure of the image.
[0111] 4) Thinning loop:
[0112] The core of the thinning algorithm is to gradually delete pixels that meet specific conditions to shrink the region while keeping its topological structure unchanged. The thinning conditions are based on the layout of neighboring pixels to ensure that the topological structure of the region is not damaged during the deletion process.
[0113] 5) Retention mechanism for perfect points:
[0114] For points that are morphologically crucial (such as corner points, local extreme points, boundary points, etc.), through a marking and retention mechanism, it is ensured that they are not deleted during the thinning process to maintain the key shape features of the region.
[0115] 6) Post - processing and image repair:
[0116] Post - processing is carried out after thinning, including operations such as removing noise, filling holes, and smoothing boundaries, to ensure that the image finally meets the required quality and structural requirements.
[0117] 7) Isolated point recovery and thresholding:
[0118] By recovering the temporarily removed isolated points and performing thresholding operations, ensure that the thinned image is consistent with the original area.
[0119] 8) Restore the original coordinate system:
[0120] By restoring the thinned area to the original coordinate system, ensure the geometric consistency between the thinned area and the original area.
[0121] What is described in the above specification is only the specific implementation manners of the present invention. Various examples do not constitute limitations on the essence of the present invention. Those of ordinary skill in the art can make modifications or variations to the previously described specific implementation manners after reading the specification, without departing from the essence and scope of the invention.
Claims
1. A skeleton extraction method based on run-length encoding, characterized in that: including the following steps, S1. The run-length encoding of the input area. The run-length encoding of the area consists of runs, and each run represents the consecutive pixel values of a row or a partial row in the image; each run includes a row number l, a starting column cb, and an ending column ce; S2. Set up a temporary image Pict. The temporary image Pict is an extended area image, and each pixel in the temporary image Pict is initialized to INSIDE or BORDER; S3. Check each pixel and its neighborhood, identify and remove isolated points; S4. Refinement loop. By gradually deleting pixels that meet specific conditions, the area is shrunk while keeping its topology unchanged; S5. Retain perfect points through a marking and retention mechanism; S6. Perform post-processing after refinement so that the image finally meets the required quality and structural requirements; S7. By restoring the temporarily removed isolated points and performing thresholding operations, make the refined image consistent with the original area; S8. By restoring the refined area to the original coordinate system, ensure the geometric consistency between the refined area and the original area.
2. The skeleton extraction method based on run-length encoding according to claim 1, characterized in that: In the step S3, the way to identify isolated points is to check the eight neighborhoods of each pixel. If there are no INSIDE pixels in the neighborhood of the pixel, then the pixel is considered an isolated point and removed from the image.
3. The skeleton extraction method based on run-length encoding according to claim 1, characterized in that: In the step S4, the refinement loop includes the following steps, 1) Construct a neighborhood structure, and construct a neighborhood matrix for each pixel in the image; 2) Define deletion conditions; 3) Gradually traverse the pixels in the image. If a pixel meets the deletion conditions, mark the pixel as a candidate for deletion; otherwise retain the pixel; 4) Perform pixel deletion operations. After one traversal, delete all the pixels marked as candidates for deletion at once; 5) Repeat the refinement loop, continuously check and delete pixels that meet the conditions; 6) When it is found that no pixel meets the deletion conditions after traversing the entire image, stop the refinement operation.
4. The skeleton extraction method based on run-length encoding according to claim 1, wherein: In the step S5, the types of perfect points are: Corner points: Located at the corners of the area; Local extreme points: Appear as local maxima or minima in the area contour or shape; Area boundary points: Located on the area boundary.
5. The skeleton extraction method based on run-length encoding according to claim 4, wherein: The confirmation method for the perfect points is as follows, For corner points, use the curvature method or the angle method to detect; For local extreme points, judge by comparing the value of a point with the values of other points in its neighborhood; For boundary points, confirm their positions by checking whether the neighborhood of the point contains background pixels.
6. The skeleton extraction method based on run-length encoding according to claim 1, characterized in that: In the step S6, the ways of post-processing include: removing small noise points after refinement to keep the connectivity of the area; filling holes after refinement to ensure the integrity of the area; smoothing the boundary of the area to reduce jagged edges.