A method for filling regional holes based on run length encoding
By using a regional hole filling method based on run-length encoding, constructing a connectivity table and utilizing depth-first search and mask array, the problem of incomplete filling of large-sized or complex-shaped holes in traditional methods is solved, achieving efficient and accurate hole filling effects.
Patent Information
- Application Number
- CN202510241345.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-03-03
AI Technical Summary
Traditional hole filling methods suffer from low efficiency or incomplete filling when dealing with large or complex-shaped holes, and have high computational complexity.
A region hole filling method based on run-length encoding is adopted. By obtaining the original region information and background region information of the image, a run-length connectivity table is constructed. The labels of the connected run-length encodings are recorded using depth-first search and mask array to simplify boundary processing, improve the accuracy of connected region extraction and reduce the complexity of the algorithm.
It achieves efficient filling of holes of various shapes and sizes, reduces computational complexity, improves filling accuracy and robustness, and is suitable for different image processing systems.
Smart Images

Figure CN120147194B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of digital image processing, and in particular relates to a method for filling regional holes based on run length coding. Background Art
[0002] Hole filling is an important technique in morphological image processing. It can be used to remove small holes or defects in binary images, thereby improving image quality. This technique has a wide range of applications in computer vision, image processing, pattern recognition, and other fields.
[0003] Morphology is a theoretical framework based on set theory and topology that is used to describe and manipulate structural and shape information in images. Basic operations in morphology include erosion, dilation, opening, and closing. Common hole filling methods in morphology include: hole filling based on opening operations, hole filling based on flood filling, and hole filling based on reconstruction operations.
[0004] Hole filling based on the opening operation is the most basic hole filling method. It first dilates the binary image to fill the holes, then performs an opening operation (erosion followed by dilation) to restore the object boundaries. However, it can only fill small holes; larger holes are ineffective and may not be successfully filled.
[0005] Hole filling based on flooding treats the image as terrain, with holes treated as ponds or bodies of water. Starting from a seed point, water is gradually allowed to flow through the hole area until the current hole is filled. However, this method requires accurate hole location for seed placement, and each hole must have a seed placed for proper filling.
[0006] This method of hole filling based on reconstruction operations uses morphological reconstruction operations to accurately fill holes. The steps are to first calculate a marked mask for the original region (taking the boundary points around the image except for those belonging to the original region), and then reconstruct the marked region. The reconstruction method uses a 3*3 structuring element to expand the marked mask, and then constrains it with the original region. It iterates until the result is unchanged, and then inverts it to obtain the filling result. The advantage is that it can fill holes of any size. The disadvantage is that it can only use 3*3 structuring elements, otherwise it will result in incomplete filling. In addition, each expansion requires a constraint with the original region, and the computational complexity increases with the number of required iterations.
[0007] In summary, traditional hole filling methods have shortcomings in hole size adaptability, seed positioning complexity, and computational complexity. When dealing with holes of complex shapes or large areas, there are problems of low efficiency or incomplete filling. Summary of the Invention
[0008] The purpose of the present invention is to provide a method for filling regional holes based on run-length encoding, which can effectively overcome the shortcomings of traditional methods in dealing with large-sized or complex-shaped holes, and has higher accuracy and lower computational complexity in implementation.
[0009] The technical solutions adopted by the present invention are as follows:
[0010] A method for filling a region hole based on run length encoding, comprising:
[0011] Obtaining the original region information of the image, and obtaining the inverse information of the original region based on the original region information;
[0012] Obtain the corresponding background area information based on the inverted information of the original area;
[0013] The hole filling area information is obtained based on the original area information and the background area information.
[0014] In a preferred embodiment, the steps of obtaining original region information of an image and obtaining inverted information of the original region based on the original region information include:
[0015] Get the original area information of the image;
[0016] Obtain the corresponding minimum circumscribed rectangle information based on the original area information;
[0017] Each side of the minimum circumscribed rectangle is extended outward by one pixel width, and the extended result is marked as the Rect area information;
[0018] The candidate background area BP information is obtained according to the Rect area information and the original area information, and marked as the inverse information of the original area.
[0019] In a preferred solution, the step of obtaining corresponding background area information based on the inverted information of the original area includes:
[0020] Obtain the corresponding candidate background area BP information based on the inverted information of the original area;
[0021] Obtain the run length code and adjacency relationship of the candidate background area BP information;
[0022] Constructing a trip connectivity relationship table based on the trip codes and adjacency relationships of the candidate background area BP information, wherein the first trip code in the trip connectivity relationship table is marked as the starting trip code;
[0023] Obtain all run codes connected to the starting run code according to the run connectivity relationship table and mark them as connected run code information;
[0024] Obtaining the order of each run length code in the connected run length code information;
[0025] The background area information is obtained according to the order of each run length encoding.
[0026] In a preferred embodiment, the adjacency relationship includes eight neighborhoods and four neighborhoods.
[0027] In a preferred solution, the step of constructing a run connectivity table based on the run coding and adjacency relationship of the candidate background area BP information includes:
[0028] Obtain the start and end numbers of each row of run length coding in the run length coding of the candidate background area BP information;
[0029] Get the inter-line information based on the start and end numbers of each line of run-length encoding;
[0030] The run length codes of two adjacent rows are compared in sequence according to the inter-row information, and a run length connectivity relationship table of the upward and downward connectivity marks and the downward and upward connectivity marks is obtained.
[0031] In a preferred solution, the first run length code in the background area BP information belongs to the background area, and all run length codes in the background area are connected to the first run length code.
[0032] In a preferred solution, the step of obtaining the order of each run length code in the connected run length code information includes:
[0033] Mark the first run length code in the candidate background area BP information as the root node;
[0034] Mark the run codes connected to the root node in the run connectivity relationship table as child nodes;
[0035] According to the depth-first search traversal method, recursively search and record the label data of all child nodes connected to the root node;
[0036] Get the order of each run length encoding according to the label data.
[0037] In a preferred solution, the step of recursively searching and recording the label data of all child nodes connected to the root node according to the depth-first search traversal method includes:
[0038] Obtain the total number of run length codes in the candidate background area BP information, and create a binary mask array equal to the total number of run length codes in the candidate background area BP information, wherein the initial state of the mask array is all zero values;
[0039] During the depth-first search traversal, when a child node connected to the root node is detected, the value of the corresponding index bit in the mask array is updated to the active state;
[0040] Get the root node storage order. After traversal is completed, perform linear scan according to the root node storage order based on the activation state of the mask array.
[0041] The activated child nodes in the mask array are directly output to the background area set, and the spatial arrangement relationship of the run length encoding in the original run length encoding storage order is maintained, and the label data is obtained.
[0042] In a preferred solution, the step of obtaining hole filling area information based on original area information and background area information includes:
[0043] Get the corresponding Rect area information according to the original area information;
[0044] Get the hole filling area information based on the Rect area information and the background area information.
[0045] And, a regional hole filling terminal based on run length coding, comprising:
[0046] one or more processors;
[0047] a storage device having one or more programs stored thereon;
[0048] When one or more programs are executed by one or more processors, the one or more processors implement a region hole filling method based on run length encoding.
[0049] The technical effects achieved by the present invention are:
[0050] The present invention directly obtains the candidate background area by inverting the original area and constructing an extended rectangular area, which simplifies the complexity of boundary processing in traditional hole filling, and uses run-length coding to segment the area. Combined with the dual adjacency relationship judgment, it can more accurately identify the connectivity between each code in the background area, thereby improving the accuracy of connected area extraction. The mask method is used to record the labels of the connected run-length codes, so that when the background area is subsequently summarized, there is no need to additionally reorder the run-length codes, thereby saving computing resources and reducing algorithm complexity. The integrity of the candidate background area is guaranteed by the extended rectangle, and the accurate extraction of the background area is guaranteed by the depth-first search. It can adapt to the hole filling of original areas of various shapes and sizes, has good robustness, is easy to implement in different image processing systems, is convenient for promotion and use in practical applications, and is also beneficial to subsequent hardware implementation and software optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 It is a flow chart of the method provided by the present invention. DETAILED DESCRIPTION
[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0053] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0054] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in a preferred embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it constitute a separate or selective embodiment that is mutually exclusive of other embodiments.
[0055] Secondly, the present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention in detail, for the sake of convenience, the schematic diagrams are only examples and should not limit the scope of protection of the present invention.
[0056] Please see the attached Figure 1 As shown, a method for filling a region hole based on run length encoding is provided, comprising:
[0057] S1. Obtain original region information of the image, and obtain inverse information of the original region based on the original region information;
[0058] S2. Obtain the corresponding background area information based on the inverted information of the original area;
[0059] S3. Obtain hole filling area information based on the original area information and the background area information.
[0060] As in steps S1 to S3 above, the original area to be filled with holes is extracted from the image. This area represents the target area that needs to be filled with holes. The minimum circumscribed rectangle of the original area is calculated and extended by one pixel on each of its four sides to form a rectangle (denoted as Rect) slightly larger than the minimum circumscribed rectangle. Then, the original area is subtracted from the Rect area to obtain a candidate background area BP. In fact, the original area is "inverted" to obtain the extended background part excluding the original area. The run-length encoding method is used for the candidate background area BP to encode continuous pixel segments. Based on the encoded candidate area, a run-length connectivity relationship table is established. The connectivity between the run codes is determined by setting a dual adjacency relationship (i.e., if the original hole filling adopts an eight-neighborhood, then a four-neighborhood is adopted here, and vice versa). Since Rect is extended by one pixel on each side of the minimum circumscribed regular rectangle, the first run code of the candidate background area must belong to the background area, and all the run codes in the background area are connected to it. With the first run code as the root node, a depth-first search is used to traverse the run connectivity table, and the labels of all run codes connected to the root node are recorded. In order to avoid order confusion during the traversal process, a mask with the size of the total number of run codes is used to record them. During the traversal, the connected run codes are recorded. The corresponding position of the run encoding is marked as 1. After the traversal is completed, the background area is directly extracted in the encoding order without reordering. By subtracting the Rect area obtained from the inverted information of the original area from the background area, the area filled with holes is obtained. This area not only retains the internal structure of the original area, but also completely fills the discontinuous area caused by the existence of holes. By inverting the original area and constructing an extended rectangular area, the candidate background area is directly obtained, which simplifies the complexity of boundary processing in traditional hole filling. The run encoding is used to segment the area, and then combined with the dual adjacency judgment (four-neighborhood and eight-neighborhood interchange), it can be more accurate. The connectivity between each code in the background area is accurately identified, thereby improving the accuracy of connected area extraction. The labels of the connected run codes are recorded in a mask manner, so that when the background area is subsequently summarized, there is no need to reorder the run codes, thereby saving computing resources and reducing the complexity of the algorithm. The integrity of the candidate background area is ensured by expanding the rectangle, and the accurate extraction of the background area is ensured by depth-first search. It can adapt to the filling of holes in the original area of various shapes and sizes, has good robustness, is easy to implement in different image processing systems, is convenient for promotion and use in practical applications, and is also conducive to subsequent hardware implementation and software optimization.
[0061] In a preferred embodiment, the steps of obtaining original region information of an image and obtaining inverted information of the original region based on the original region information include:
[0062] S101, obtaining original area information of an image;
[0063] S102, obtaining the corresponding minimum circumscribed regular rectangle information according to the original area information;
[0064] S103, extending each side of the minimum circumscribed regular rectangle information outward by one pixel width, and marking the extension result as Rect area information;
[0065] S104 , obtaining candidate background area BP information according to the Rect area information and the original area information, and marking it as the inverse information of the original area.
[0066] As in the above steps S101 to S104, the original area in the image that needs to be filled with holes is extracted, and based on the original area information obtained, the minimum circumscribed rectangle that can completely surround the original area is calculated. This rectangle can accurately describe the boundary range of the original area, and each side of the minimum circumscribed rectangle is extended outward by one pixel width to obtain an area slightly larger than the original rectangle, which is recorded as the Rect area information. This extension ensures that the Rect area must contain all the boundary pixels of the original area and leaves "room" for generating the alternative background area, thereby forming a transition area. The Rect area information is used to perform a difference operation with the original area information: that is, the Rect area is used. Subtract the original area, and the resulting area is the candidate background area BP, also known as the inverse information of the original area. The candidate background area is the part outside the original area but surrounded by the Rect, which provides a clear background basis for subsequent filling of holes. By extending each side of the minimum circumscribed regular rectangle by one pixel, it can be ensured that the generated Rect area not only completely covers the original area, but also provides a circle of protection edge for the background area, ensuring that all parts belonging to the background are continuous and connected, thereby improving the reliability of connectivity judgment, and using simple geometric operations (such as rectangle expansion and area difference) to directly construct the candidate background area, reducing the computational complexity of complex area segmentation and edge detection.
[0067] In a preferred embodiment, the step of obtaining the corresponding background area information based on the inverted information of the original area includes:
[0068] S201, obtaining corresponding candidate background area BP information according to the inverted information of the original area;
[0069] S202, obtaining the run length code and adjacency relationship of the candidate background area BP information;
[0070] S203: constructing a run connectivity relationship table based on the run codes and adjacency relationships of the candidate background area BP information, wherein the first run code in the run connectivity relationship table is marked as the starting run code;
[0071] S204: Acquire all run codes connected to the starting run code according to the run connectivity relationship table and mark them as connected run code information;
[0072] S205, obtaining the order of each run length code in the connected run length code information;
[0073] S206 : Acquire background area information according to the order of each run length encoding.
[0074] It should be noted that the adjacency relationship includes eight-neighborhood and four-neighborhood.
[0075] As in steps S201 to S206 above, based on the inverted information of the original area, the candidate background area BP is obtained by subtracting the expanded Rect area from the original area. This area includes all pixels outside the original area but surrounded by the Rect. Run-length coding is applied to the candidate background area BP to convert continuous pixel segments into discrete coding units. At the same time, the connection between each coding unit is determined based on a predefined adjacency relationship (which can be an eight-neighborhood or a four-neighborhood). The obtained run-length coding and adjacency relationship are used to construct a connectivity relationship table to record the connectivity information between each run-length code and the adjacent codes. Since the Rect area expansion ensures that the first run-length code of the candidate area must be located in the background, this code is marked as the starting run-length code. With the starting run-length code as the root node, a depth-first search (DFS) method is used to recursively traverse the constructed connectivity relationship table to find and record all pixels connected to the starting run-length code. Connected run-length codes form a complete set of connected run-length codes. Although the order of the results of the depth-first search traversal may be disordered, by pre-recording the order of each run-length code in the image, the connected codes obtained by the traversal can be sorted to ensure that the background area information is consistent with the original structure of the image. Finally, according to the sorted run-length codes, the pixel segments corresponding to each code are integrated in turn to form the final background area information, providing accurate background data for subsequent hole filling. By using run-length codes and adjacency relationship judgment, the connectivity between each pixel segment in the candidate background area can be accurately determined to ensure that only the parts that are truly connected to the starting run-length code are extracted, thereby excluding noise or isolated areas. Run-length coding compresses continuous pixels into smaller coding units, greatly reducing the amount of computational complexity of pixel-by-pixel processing. At the same time, using the connectivity table for depth-first search can quickly locate and extract background areas, improving the overall algorithm efficiency.
[0076] In a preferred embodiment, the step of constructing a run connectivity table based on the run length coding and adjacency relationship of the candidate background area BP information includes:
[0077] S2031, obtaining the start and end numbers of each row of run length coding in the run length coding of the candidate background area BP information;
[0078] S2032, obtaining inter-row information according to the start number and end number of each row of run-length encoding;
[0079] S2033: Compare the run length codes of two adjacent rows in order according to the inter-row information, and obtain a run length connectivity relationship table of the upward and downward connectivity marks and the downward and upward connectivity marks.
[0080] It is worth mentioning that the first run length code in the background area BP information belongs to the background area, and all run length codes in the background area are connected to the first run length code.
[0081] As in steps S2031 to S2033 above, after the candidate background area BP is run-length coded, each row is segmented into several continuous pixel segments. The starting and ending positions (labels) of each run-length code in each row are extracted to provide accurate position information for subsequent inter-row comparison. Based on the starting and ending labels of each row of run-length codes, the spatial overlap or proximity between two adjacent rows is determined. The inter-row information reflects the possible connectivity between the corresponding run-length codes of the two rows, that is, which run-length codes have intersecting or adjacent parts in the vertical direction. Using the obtained inter-row information, the run-length codes of two adjacent rows are sequentially compared. During the comparison process, the upper row run-length code is assigned a "downward connected" mark, and the lower row run-length code is assigned a "upward connected" mark, thereby A complete run connectivity table is formed. Since the first run code in the background area BP information has been determined to belong to the background area, and all run codes in the background area are connected to the first run code, the constructed connectivity table can ensure that starting from the first run code, all run codes connected to it can be recursively found. By recording the start and end labels of each row of run codes and using inter-row information to determine connectivity, the connectivity relationship between adjacent runs can be accurately captured, thereby effectively distinguishing the background area from the non-background area. Only local comparison of adjacent rows is required, without the need for global search, which reduces the amount of computation. At the same time, the constructed connectivity table provides an efficient data structure for subsequent depth-first search to extract the complete background area.
[0082] In a preferred embodiment, the step of obtaining the sequence of each run length code in the connected run length code information includes:
[0083] S2051, marking the first run length code in the candidate background area BP information as a root node;
[0084] S2052: Mark the run codes connected to the root node in the run connectivity relationship table as child nodes;
[0085] S2053. Recursively search and record the label data of all child nodes connected to the root node according to the depth-first search traversal method;
[0086] S2054. Obtain the sequence of each run length encoding according to the label data.
[0087] As in steps S2051 to S2054 above, the first run-length code is selected from the information of the candidate background area BP as the root node. Since this run-length code must belong to the background area, it serves as the starting point for connecting area extraction and provides a reliable starting point for subsequent traversal. Using the previously constructed run-length connectivity table, all run-length codes directly connected to the root node are identified and marked as child nodes. A preliminary connectivity graph is constructed, which clarifies which run-length codes have a direct connection relationship with the root node. A depth-first search (DFS) traversal method is used to recursively search all child nodes connected to the root node starting from the root node. During the traversal process, the label data of each visited run-length code is gradually recorded, thereby forming a complete connected graph. Through the code set, DFS ensures that all directly or indirectly connected run codes can be captured without omission. According to the label data recorded in the recursive process, the order of each run code in the entire connected area is determined. After arranging these run codes in order, they can be directly used to construct the background area information without additional sorting operations. By taking the first run code as the root node and using DFS traversal, it is ensured that all run codes connected to the root node in the background area are retrieved, thereby ensuring the integrity of the area extraction. By directly recording the label data in the DFS process and determining the order of the run codes based on this data, the additional sorting step is omitted, making the subsequent process of constructing the background area more direct and simple.
[0088] In a preferred embodiment, the step of recursively searching and recording the label data of all child nodes connected to the root node according to the depth-first search traversal method includes:
[0089] S20531. Obtain the total number of run length codes in the candidate background area BP information, and create a binary mask array equal to the total number of run length codes in the candidate background area BP information. The initial state of the mask array is all zero values.
[0090] S20532. During the depth-first search traversal process, when a child node connected to the root node is detected, the value of the corresponding index bit in the mask array is updated to an activated state;
[0091] S20533. Obtain the root node storage order. After traversal is completed, perform a linear scan based on the root node storage order according to the activation state of the mask array.
[0092] S20534: Output the activated child nodes in the mask array directly to the background area set, while maintaining the spatial arrangement relationship of the run length encoding in the original run length encoding storage order, and obtain the label data.
[0093] As in steps S20531 to S20534 above, the total number of all run-length codes in the candidate background area BP is first obtained. Then, a binary mask array of the same size is created based on the total number. Initially, all positions in the mask array are zero, indicating that no run-length codes connected to the root node have been marked. A depth-first search (DFS) is used to recursively traverse the run-length connectivity table starting from the root node. When a run-length code is detected to be connected to the root node during the traversal process, the value of the corresponding index bit in the mask array is updated to an active state (e.g., set to 1) to record that the run-length code has been accessed and belongs to a connected area. After the DFS traversal is completed, the mask array is linearly scanned according to the storage order of the root nodes (i.e., the arrangement order of the original run-length codes in the data structure). By scanning the mask array, all active indexes are extracted in the original order. In this way, It ensures that all connected run codes are recorded and their spatial arrangement relationship in the original storage order is preserved. The run codes marked as active in the mask array are directly output to the background area set, and the label data of these run codes are obtained synchronously, finally forming a complete, continuous and ordered background area set. Using the binary mask array, only one marking operation is required for each run code, avoiding repeated calculation or additional sorting, thereby greatly improving the efficiency of connected area extraction. By performing linear scanning in the original storage order, the spatial relationship of the run codes in the background area is ensured not to be disrupted, which is conducive to subsequent area construction and image restoration, making the filled area naturally connected with the original image. It is suitable for alternative background areas of different scales and complexities. Even if the area shape is complex, the integrity and accuracy of the connectivity data can be guaranteed through masks and DFS, thereby improving the stability and adaptability of the algorithm.
[0094] In a preferred embodiment, the step of obtaining hole filling area information based on the original area information and the background area information includes:
[0095] S301, obtaining corresponding Rect area information according to the original area information;
[0096] S302: Obtain hole filling area information based on Rect area information and background area information
[0097] As in the above steps S301 to S302, based on the original area information, the minimum circumscribed rectangle of the area is first calculated, that is, the minimum rectangle that can completely cover the original area. In order to ensure that the boundary of the original area is covered and to reserve edge space for subsequent operations, each side of the minimum circumscribed rectangle is expanded outward by one pixel width to obtain the expanded rectangular area (i.e., the Rect area). This not only ensures that all pixels of the original area are included, but also constructs a reference area slightly larger than the original area to provide a geometric basis for hole filling. The obtained Rect area information and the background area information obtained by the previous step (i.e., the area after the original area is inverted) are used to perform a regional difference operation on the two. Specifically, the Rect area includes the original area and the surrounding background part, and the background area information is not included. The information indicates the connected background outside the original area in the Rect, and the Rect area is subtracted from the background area to remove the background part to obtain the area information after filling the holes, that is, the holes in the original area are "filled" to obtain a continuous and complete target area, ensuring that the boundaries of the original area are fully protected, and providing sufficient space for hole filling to avoid incomplete filling due to boundary truncation. Simple geometric operations (rectangular expansion and area subtraction) are used to achieve hole filling, avoiding complex image segmentation or edge detection steps, simplifying the entire processing flow, and reducing computational complexity. Combined with the background area information, it can accurately identify and remove the background part outside the original area, thereby accurately obtaining the area after filling the holes, ensuring regional continuity and natural transition of shapes.
[0098] And, a regional hole filling terminal based on run length coding, comprising:
[0099] one or more processors;
[0100] a storage device having one or more programs stored thereon;
[0101] When one or more programs are executed by one or more processors, the one or more processors implement a region hole filling method based on run length encoding.
[0102] The foregoing is merely a preferred embodiment of the present invention. It should be noted that those skilled in the art may make various improvements and modifications without departing from the principles of the present invention, and such improvements and modifications are also within the scope of protection of the present invention. Structures, devices, and operating methods not specifically described or explained herein shall, unless otherwise specified or limited, be implemented in accordance with conventional means in the art.
Claims
1. A method for filling regional holes based on run length encoding, characterized in that: include: Obtaining the original region information of the image, and obtaining the inverse information of the original region based on the original region information; Obtain the corresponding background area information based on the inverted information of the original area; Obtain hole filling area information based on original area information and background area information; The steps of obtaining original region information of an image and obtaining inverse information of the original region based on the original region information include: Get the original area information of the image; Obtain the corresponding minimum circumscribed rectangle information based on the original area information; Each side of the minimum circumscribed rectangle is extended outward by one pixel width, and the extended result is marked as the Rect area information; Obtain candidate background area BP information based on the Rect area information and the original area information, and mark it as the inverse information of the original area. Subtract the original area from the Rect area, and the resulting area is the candidate background area BP; The steps of obtaining the corresponding background area information according to the inverted information of the original area include: Obtain the corresponding candidate background area BP information based on the inverted information of the original area; Obtain the run length code and adjacency relationship of the candidate background area BP information; Constructing a trip connectivity relationship table based on the trip codes and adjacency relationships of the candidate background area BP information, wherein the first trip code in the trip connectivity relationship table is marked as the starting trip code; Obtain all run codes connected to the starting run code according to the run connectivity relationship table and mark them as connected run code information; Obtaining the order of each run length code in the connected run length code information; Obtaining background area information according to the order of each run length code, specifically, sequentially integrating pixel segments corresponding to each code according to the sorted run length code to form final background area information; The steps of obtaining hole filling area information according to original area information and background area information include: Get the corresponding Rect area information according to the original area information; The hole filling area information is obtained based on the Rect area information and the background area information. The hole filling area information refers to the area information after the hole is filled, obtained by performing a difference operation between the Rect area and the background area.
2. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: Adjacency relationships include eight-neighborhood and four-neighborhood.
3. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The step of constructing a trip connectivity table based on the trip codes and adjacency relationships of the candidate background area BP information includes: Obtain the start and end numbers of each row of run length coding in the run length coding of the candidate background area BP information; Get the inter-line information based on the start and end numbers of each line of run-length encoding; The run length codes of two adjacent rows are compared in sequence according to the inter-row information, and a run length connectivity relationship table of the upward and downward connectivity marks and the downward and upward connectivity marks is obtained.
4. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The first run length code in the background area BP information belongs to the background area, and all run length codes in the background area are connected to the first run length code.
5. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The step of obtaining the order of each run length code in the connected run length code information includes: Mark the first run length code in the candidate background area BP information as the root node; Mark the run codes connected to the root node in the run connectivity relationship table as child nodes; According to the depth-first search traversal method, recursively search and record the label data of all child nodes connected to the root node; Get the order of each run length encoding according to the label data.
6. The method for filling regional holes based on run length encoding according to claim 5, characterized in that: According to the depth-first search traversal method, the steps of recursively searching and recording the label data of all child nodes connected to the root node include: Obtain the total number of run length codes in the candidate background area BP information, and create a binary mask array equal to the total number of run length codes in the candidate background area BP information, wherein the initial state of the mask array is all zero values; During the depth-first search traversal, when a child node connected to the root node is detected, the value of the corresponding index bit in the mask array is updated to the active state; Get the root node storage order. After traversal is completed, perform linear scan according to the root node storage order based on the activation state of the mask array. The activated child nodes in the mask array are directly output to the background area set, and the spatial arrangement relationship of the run length encoding in the original run length encoding storage order is maintained, and the label data is obtained.
7. A regional hole filling terminal based on run length encoding, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon; When one or more programs are executed by one or more processors, the one or more processors implement the region hole filling method based on run length encoding as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Color point cloud geometric coding triangular hole repairing method based on multi-view projection
CN116416154A
Method and system for rapidly extracting connected domain based on run-length coding
CN117152458A