Regional hole filling method based on run-length coding
Through a stroke coding method, a stroke connection relationship table is constructed and depth-first search is combined with depth-first search, the problems of inefficiency and incomplete filling of traditional hole filling methods when dealing with large-size or complex-shaped holes are solved, and efficient and accurate hole filling effect is achieved.
Patent Information
- Application Number
- CN202510241345.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-03-03
AI Technical Summary
Traditional hole filling methods have problems of inefficiency or incomplete filling when dealing with large-sized or complex-shaped holes.
The area hole filling method based on stroke encoding is adopted. By obtaining the original area information and background area information of the image, a trip connectivity relationship table is constructed, and combined with depth priority search, the background area is accurately identified and extracted, and hole filling is realized.
It improves the accuracy and efficiency of hole filling, reduces the complexity of the algorithm, adapts to hole filling of various shapes and sizes, and has good robustness.
Smart Images

Figure CN120147194A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of digital image processing, and particularly relates to a method for filling regional holes based on run-length encoding. Background Art
[0002] Hole filling is an important technique in morphological image processing, which can be used to eliminate small holes or defects in binary images, thereby improving the quality of images. This technique has a wide range of applications in the fields of computer vision, image processing, pattern recognition, etc.
[0003] Morphology is a theoretical system based on set theory and topology, which is used to describe and process the structural and shape information in images. The basic operations in morphology include erosion, dilation, opening operation, and closing operation, etc. The commonly used hole filling methods in morphology mainly include the following several kinds: hole filling based on opening operation, hole filling based on flood filling, and hole filling based on reconstruction operation.
[0004] Hole filling based on opening operation is the most basic hole filling method. The steps are to first perform a dilation operation on the binary image to fill the holes, and then perform an opening operation (erosion first and then dilation) to restore the object boundary. The disadvantage is that it can only fill small holes, and the effect on large holes is not good and cannot be filled successfully.
[0005] Hole filling based on flood filling regards the image as a terrain, and the holes are regarded as ponds or waters. Starting from the seed point, let the water gradually flood over the hole area until the current hole is filled. The disadvantage is that the position of the hole needs to be located to correctly place the seed, and a seed needs to be placed for each hole to be filled normally.
[0006] Hole filling based on reconstruction operation uses morphological reconstruction operation to accurately fill the holes. The steps are to first obtain a marker mask for the original area (take the boundary points around the image except those belonging to the original area), and then perform a reconstruction operation on the marked area. The reconstruction method is to dilate the marker mask using a 3*3 structuring element, and then be constrained by the original area, and iterate until the result remains unchanged, and then take the inverse to obtain the filling result. The advantage is that it can fill holes of any size, and the disadvantage is that only a 3*3 structuring element can be used, otherwise it will cause incomplete filling, and each dilation requires a constraint with the original area, and the computational complexity will increase with the required number of iterations.
[0007] In summary, the traditional hole filling methods have deficiencies in terms of hole size adaptability, seed positioning complexity, and computational complexity. When dealing with complex shapes or large-area holes, there are problems of low efficiency or incomplete filling. Summary of the Invention
[0008] The object of the present invention is to provide a method for filling holes in a region based on run-length encoding, which can effectively overcome the deficiencies of traditional methods in dealing with large-sized or complex-shaped holes, and has high precision and low computational complexity in implementation.
[0009] The technical solution adopted by the present invention is as follows:
[0010] A method for filling holes in a region based on run-length encoding, comprising:
[0011] Obtaining the original region information of the image, and obtaining the inverted information of the original region according to the original region information;
[0012] Obtaining the corresponding background region information according to the inverted information of the original region;
[0013] Obtaining the hole filling region information according to the original region information and the background region information.
[0014] In a preferred embodiment, the step of obtaining the original region information of the image and obtaining the inverted information of the original region according to the original region information includes:
[0015] Obtaining the original region information of the image;
[0016] Obtaining the information of the smallest circumscribed rectangle corresponding to the original region information;
[0017] Expanding each side of the information of the smallest circumscribed rectangle by one pixel width, and marking the expansion result as the Rect region information;
[0018] Obtaining the alternative background region BP information according to the Rect region information and the original region information, and marking it as the inverted information of the original region.
[0019] In a preferred embodiment, the step of obtaining the corresponding background region information according to the inverted information of the original region includes:
[0020] Obtaining the alternative background region BP information corresponding to the inverted information of the original region;
[0021] Obtaining the run-length encoding and adjacency relationship of the alternative background region BP information;
[0022] Constructing a run-length connectivity relationship table according to the run-length encoding and adjacency relationship of the alternative background region BP information, wherein the first run-length encoding in the run-length connectivity relationship table is marked as the starting run-length encoding;
[0023] Obtaining all the run-length encodings connected to the starting run-length encoding according to the run-length connectivity relationship table, and marking them as the connected run-length encoding information;
[0024] Obtaining the order of each run-length encoding in the connected run-length encoding information;
[0025] Obtain background area information according to the order of each run-length encoding.
[0026] In a preferred embodiment, the adjacency relationship includes eight-neighborhood and four-neighborhood.
[0027] In a preferred embodiment, the step of constructing a run connectivity relationship table according to the run-length encoding of the alternative background area BP information and the adjacency relationship includes:
[0028] Obtain the starting label and the ending label of each row of run-length encoding in the run-length encoding of the alternative background area BP information;
[0029] Obtain inter-row information according to the starting label and the ending label of each row of run-length encoding;
[0030] According to the inter-row information, compare the run-length encodings of adjacent two rows in sequence between rows, and obtain a run connectivity relationship table of the upward connectivity flag from the upper row to the lower row and the downward connectivity flag from the lower row to the upper row.
[0031] In a preferred embodiment, the first run-length encoding in the background area BP information belongs to the background area, and the run-length encodings in all background areas are connected to the first run-length encoding.
[0032] In a preferred embodiment, the step of obtaining the order of each run-length encoding in the connected run-length encoding information includes:
[0033] Mark the first run-length encoding in the alternative background area BP information as the root node;
[0034] Mark the run-length encodings connected to the root node in the run connectivity relationship table as child nodes;
[0035] According to the traversal method of depth-first search, recursively search for and record the label data of all child nodes connected to the root node;
[0036] Obtain the order of each run-length encoding according to the label data.
[0037] In a preferred embodiment, the step of recursively searching for and recording the label data of all child nodes connected to the root node according to the traversal method of depth-first search includes:
[0038] Obtain the total number of run-length encodings in the alternative background area BP information, create a binary mask array equal to the total number of run-length encodings in the alternative background area BP information, and the initial state of the mask array is all zero values;
[0039] During the depth-first search traversal process, when detecting a child node connected to the root node, update the value of the corresponding index bit in the mask array to the active state;
[0040] Obtain the storage order of the root node. After completing the traversal, perform a linear scan according to the storage order of the root node based on the activation status of the mask array;
[0041] Directly output the activated child nodes in the mask array to the background area set, and maintain the spatial arrangement relationship of the run-length encoding in the original run-length encoding storage order, and obtain the label data.
[0042] In a preferred solution, the steps of obtaining the hole filling area information according to the original area information and the background area information include:
[0043] Obtain the corresponding Rect area information according to the original area information;
[0044] Obtain the hole filling area information according to the Rect area information and the background area information.
[0045] And, a region hole filling terminal based on run-length encoding includes:
[0046] One or more processors;
[0047] A storage device on which one or more programs are stored;
[0048] 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.
[0049] The technical effects achieved by the present invention are:
[0050] In the present invention, by taking the inverse of 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 region is segmented using run-length encoding, and combined with the judgment of dual adjacency relationships, the connectivity between each encoding in the background area can be more accurately identified, thereby improving the accuracy of connected region extraction. The mask method is used to record the labels of connected run-length encodings, so that when summarizing the background area subsequently, there is no need to reorder the run-length encoding additionally, thus saving computing resources and reducing the algorithm complexity. By extending the rectangle to ensure the integrity of the candidate background area, and then using depth-first search to ensure the accurate extraction of the background area, it can adapt to hole filling of original areas of various shapes and sizes, has good robustness, is easy to implement in different image processing systems, is convenient to promote and use in practical applications, and is also conducive to subsequent hardware implementation and software optimization. Description of the Drawings
[0051] Figure 1 is the flowchart of the method provided by the present invention. Detailed Embodiments
[0052] To make the above objects, features, and advantages of the present invention more apparent and understandable, the following detailed description of the specific embodiments of the present invention will be provided in conjunction with the accompanying drawings of the specification.
[0053] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, the present invention may be implemented in other ways different from those described herein. Those skilled in the art can make similar generalizations without departing from the spirit of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.
[0054] Secondly, the so-called "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation manner of the present invention. The phrase "in a preferred embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments.
[0055] Thirdly, the present invention will be described in detail in conjunction with schematic diagrams. When describing the embodiments of the present invention in detail, for the sake of convenience of explanation, the schematic diagrams are only examples and should not limit the scope of protection of the present invention herein.
[0056] Please refer to the attached Figure 1 As shown, a method for filling holes in a region based on run-length encoding is provided, including:
[0057] S1. Obtain the original region information of the image and obtain the inverted information of the original region according to the original region information;
[0058] S2. Obtain the corresponding background region information according to the inverted information of the original region;
[0059] S3. Obtain the hole filling region information according to the original region information and the background region information.
[0060] In the above steps S1 to S3, the original region to be hole-filled is extracted from the image. This region represents the target region that needs to be processed for hole filling. By calculating the minimum bounding rectangle of the original region and expanding one pixel on each of its four sides, a rectangle slightly larger than the minimum bounding rectangle is formed (denoted as Rect). Then, the original region is subtracted from the Rect region to obtain a candidate background region BP. In fact, it is to "invert" the original region to get the extended background part outside the original region. The run-length encoding method is used for the candidate background region BP to encode continuous pixel segments. Based on the encoded candidate region, a run connectivity relation table is established. By setting dual adjacency relations (that is, if the original hole filling uses eight-neighborhood, then four-neighborhood is used here, and vice versa) to judge the connectivity between each run encoding. Since Rect expands one pixel on each side compared to the minimum bounding rectangle, the first run encoding of the candidate background region must belong to the background region, and all run encodings in the background region are connected to it. Using this first run encoding as the root node, the run connectivity relation table is traversed by depth-first search, and the labels of all run encodings connected to the root node are recorded. To avoid disorder in the traversal order, the method uses a mask with the total number of run encodings to record. During the traversal, the corresponding positions of the connected run encodings are marked as 1. After the traversal, the background region is directly extracted in the encoding order without reordering. By subtracting the background region from the Rect region obtained from the inversion information of the original region, the region filled with holes is obtained. This region not only retains the internal structure of the original region but also completely fills the discontinuous region caused by the existence of holes. By inverting the original region and constructing an extended rectangular region, the candidate background region is directly obtained, which simplifies the complexity of boundary processing in traditional hole filling. Using run-length encoding to segment the region and combining with the judgment of dual adjacency relations (the interchange of four-neighborhood and eight-neighborhood) can more accurately identify the connectivity between each encoding in the background region, thus improving the accuracy of connected region extraction. Using the mask method to record the labels of connected run encodings makes it unnecessary to reorder the run encodings additionally when summarizing the background region later, thus saving computing resources and reducing the algorithm complexity. By expanding the rectangle to ensure the integrity of the candidate background region and then using depth-first search to ensure the accurate extraction of the background region, it can adapt to hole filling of original regions with various shapes and sizes, has good robustness, is easy to implement in different image processing systems, is convenient to promote and use in practical applications, and is also beneficial to subsequent hardware implementation and software optimization.
[0061] In a preferred embodiment, the steps of obtaining the original region information of the image and obtaining the inverted information of the original region according to the original region information include:
[0062] S101. Obtain the original region information of the image;
[0063] S102. Obtain the information of the minimum circumscribed rectangle corresponding to the original region information;
[0064] S103. Expand each side of the minimum circumscribed rectangle information by one pixel width, and mark the expansion result as the Rect region information;
[0065] S104. Obtain the alternative background region BP information according to the Rect region information and the original region information, and mark it as the inverted information of the original region.
[0066] In the above steps S101 to S104, the original region that needs to be subjected to hole filling processing in the image is extracted. According to the obtained original region information, the minimum circumscribed rectangle that can completely enclose the original region is calculated. This rectangle can accurately describe the boundary range of the original region. Expand each side of the minimum circumscribed rectangle by one pixel width to obtain a region slightly larger than the original rectangle, denoted as the Rect region information. This expansion ensures that the Rect region necessarily contains all the boundary pixels of the original region and leaves "room" for generating the alternative background region, thus forming a transition region. Use the Rect region information and the original region information to perform a subtraction operation: subtract the original region from the Rect region, and the resulting region is the alternative background region BP, also known as the inverted information of the original region. This alternative background region is the part outside the original region but enclosed by the Rect, providing a clear background basis for subsequent hole filling. By expanding each side of the minimum circumscribed rectangle by one pixel, it can be ensured that the generated Rect region not only completely covers the original region but also provides a protective edge for the background region, ensuring that all parts belonging to the background are continuous and connected, thereby improving the reliability of connectivity judgment. Use simple geometric operations (such as rectangle expansion and region subtraction) to directly construct the candidate background region, reducing the computational complexity of complex region segmentation and edge detection.
[0067] In a preferred embodiment, the step of obtaining the background region information according to the inverted information of the original region includes:
[0068] S201. Obtain the alternative background region BP information according to the inverted information of the original region;
[0069] S202. Obtain the run-length encoding and adjacency relationship of the alternative background region BP information;
[0070] S203. Construct a run-length connectivity relationship table according to the run-length encoding and adjacency relationship of the alternative background region BP information, where the first run-length encoding in the run-length connectivity relationship table is marked as the starting run-length encoding;
[0071] S204. Obtain all the run-length encodings connected to the starting run-length encoding according to the run-length connectivity relationship table, and mark them as the connected run-length encoding information;
[0072] S205. Obtain the order of each run - length code in the connected run - length code information;
[0073] S206. Obtain the background region information according to the order of each run - length code.
[0074] It should be noted that the adjacency relationship includes eight - neighborhood and four - neighborhood.
[0075] As in the above steps S201 to S206, according to the original region inversion information, by subtracting the expanded Rect region from the original region, the candidate background region BP is obtained. This region contains all the pixels outside the original region but enclosed by Rect. The candidate background region BP is processed using run - length encoding, converting continuous pixel segments into discrete encoding units. At the same time, according to the predefined adjacency relationship (which can be eight - neighborhood or four - neighborhood), the connection situation between each encoding unit is determined. Using the obtained run - length code and adjacency relationship, a connectivity relationship table is constructed to record the connectivity information between each run - length code and its adjacent codes. Since the Rect region expansion ensures that the first run - length code of the candidate region must be in the background, this code is marked as the starting run - length code. Taking the starting run - length code as the root node, according to the constructed connectivity relationship table, the depth - first search (DFS) method is used to recursively traverse, find and record all the run - length codes connected to the starting run - length code, forming a complete set of connected run - length codes. Although the result order 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 traversal can be sorted to ensure that the background region 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 sequence to form the final background region information, providing accurate background data for subsequent hole filling. Using run - length encoding and adjacency relationship judgment can accurately determine the connectivity between pixel segments in the candidate background region, ensuring that only the part truly connected to the starting run - length code is extracted, thus excluding noise or isolated regions. Run - length encoding compresses continuous pixels into smaller encoding units, greatly reducing the computational amount of per - pixel processing. At the same time, using the connectivity relationship table for depth - first search can quickly locate and extract the background region, improving the overall algorithm efficiency.
[0076] In a preferred embodiment, the steps of constructing a run - length connectivity relationship table according to the run - length code of the alternative background region BP information and the adjacency relationship include:
[0077] S2031. Obtain the starting label and ending label of each row of run - length codes in the run - length code of the alternative background region BP information;
[0078] S2032. Obtain the inter - row information according to the starting label and ending label of each row of run - length codes;
[0079] S2033. Compare the run-length encodings of adjacent rows in sequence according to the inter-row information, and obtain the run connectivity relationship table of the upward-downward connectivity markers and the downward-upward connectivity markers.
[0080] It is worth mentioning that the first run-length encoding in the background area BP information belongs to the background area, and all the run-length encodings in all background areas are connected to the first run-length encoding.
[0081] As in the above steps S2031 to S2033, after run-length encoding the alternative background area BP, each row will be divided into several consecutive pixel segments, extract the starting positions and ending positions (labels) of the run-length encodings in each row, provide accurate position information for subsequent inter-row comparison, according to the starting and ending labels of the run-length encodings in each row, determine the spatial overlap or proximity between adjacent rows, the inter-row information reflects the possible connectivity relationship between the corresponding run-length encodings of two rows, that is, which run-length encodings have overlapping or adjacent parts in the vertical direction, using the obtained inter-row information, compare the run-length encodings of adjacent rows in sequence, during the comparison process, assign the label of "downward connectivity" to the upward run-length encoding and the label of "upward connectivity" to the downward run-length encoding, thus forming a complete run connectivity relationship table. Since the first run-length encoding in the background area BP information has been determined to belong to the background area, and all the run-length encodings in the background area are connected to the first run-length encoding, the constructed connectivity relationship table can ensure that starting from the first run-length encoding, all the run-length encodings connected to it can be recursively found. By recording the starting and ending labels of the run-length encodings in each row and using the inter-row information to judge connectivity, the connectivity relationship between adjacent runs can be accurately captured, thus effectively distinguishing the background area from the non-background area. Only local comparison of adjacent rows is required, without global search, reducing the computational amount; at the same time, the constructed connectivity relationship table provides an efficient data structure for subsequent depth-first search to extract the complete background area.
[0082] In a preferred embodiment, the steps of obtaining the order of each run-length encoding in the connected run-length encoding information include:
[0083] S2051. Mark the first run-length encoding in the alternative background area BP information as the root node;
[0084] S2052. Mark the run-length encodings connected to the root node in the run connectivity relationship table as child nodes;
[0085] S2053. According to the traversal method of depth-first search, recursively search for and record the label data of all child nodes connected to the root node;
[0086] S2054. Obtain the order of each run-length encoding according to the label data.
[0087] In the above steps S2051 to S2054, from the information of the alternative background region BP, the first run-length code is selected as the root node. Since this run-length code must belong to the background region, it serves as the starting point for extracting the connected region, providing a reliable starting point for subsequent traversal. Using the run-length connectivity relation table constructed previously, all run-length codes directly connected to the root node are identified and marked as child nodes, constructing a preliminary connected graph and clarifying which run-length codes have a direct connection relationship with the root node. Adopting the depth-first search (DFS) traversal method, starting from the root node, recursively search for all its connected child nodes. During the traversal process, gradually record the label data of each visited run-length code, thus forming a complete set of connected codes. DFS ensures that all directly or indirectly connected run-length codes can be captured without omission. According to the label data recorded during the recursive process, determine the order of each run-length code in the entire connected region. After arranging these run-length codes in order, they can be directly used to construct the background region information without additional sorting operations. By using the first run-length code as the root node and performing DFS traversal, it is ensured that all run-length codes connected to the root node in the background region are retrieved, thus guaranteeing the integrity of region extraction. By directly recording the label data during the DFS process and determining the order of the run-length codes based on this data, the additional sorting step is omitted, making the subsequent process of constructing the background region more straightforward and simple.
[0088] In a preferred embodiment, the step of recursively searching for 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 alternative background region BP information, create a binary mask array equal to the total number of run-length codes in the alternative background region BP information, and 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, update the value of the corresponding index bit in the mask array to the active state;
[0091] S20533. Obtain the storage order of the root node. After the traversal is completed, perform a linear scan according to the active state of the mask array and the storage order of the root node;
[0092] S20534. Directly output the child nodes in the active state in the mask array to the background region set, and maintain the spatial arrangement relationship of the run-length codes in the original storage order of the run-length codes, and obtain the label data.
[0093] As in the above steps S20531 to S20534, firstly, the total number of all run length codes in the candidate background area BP is obtained, and then a binary mask array of the same size is created according to the total number. Initially, all positions of the mask array are zero, indicating that no run length code connected to the root node has been marked. The depth-first search (DFS) method is adopted to recursively traverse the run connection relationship 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 activated state (for example, 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 node (that is, the arrangement order of the original run length codes in the data structure). By scanning the mask array, all the indexes in the activated state 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 retained. The run codes marked as activated 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, it ensures that the spatial relationship of the run codes in the background area is not disrupted, which is conducive to subsequent area construction and image restoration, so that the filled area is 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 according to 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 according to Rect area information and background area information
[0097] In the above steps S301 to S302, according to the original region information, first calculate the minimum circumscribed rectangle of this region, that is, the smallest rectangle that can completely cover the original region. To ensure covering the boundary of the original region and reserving an edge space for subsequent operations, each side of this minimum circumscribed rectangle is extended outward by one pixel width to obtain an extended rectangular region (i.e., the Rect region), which not only ensures that all pixels of the original region are included, but also constructs a reference region slightly larger than the original region, providing a geometric basis for hole filling. Using the obtained Rect region information and the background region information (i.e., the region after taking the inverse of the original region) obtained through the previous steps, perform a region difference operation on the two. Specifically, the Rect region contains the original region and the surrounding background part, while the background region information indicates the connected background outside the original region in the Rect. Perform a difference operation between the Rect region and the background region to remove the background part, obtaining the region information after filling the holes, that is, "filling" the holes within the original region to obtain a continuous and complete target region, ensuring that the boundary of the original region is fully protected and providing sufficient space for hole filling, avoiding incomplete filling caused by boundary truncation. Hole filling is achieved by simple geometric operations (rectangle expansion and region difference), avoiding complex image segmentation or edge detection steps, simplifying the entire processing flow, and reducing the computational complexity. Combining the background region information can accurately identify and remove the background part outside the original region, thereby precisely obtaining the region after filling the holes, ensuring regional continuity and natural transition of the shape.
[0098] And, a region hole filling terminal based on run-length encoding includes:
[0099] One or more processors;
[0100] A storage device on which one or more programs are stored;
[0101] 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.
[0102] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art in this technical field, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention. The structures, devices, and operation methods not specifically described and explained in the present invention, unless otherwise specifically stated and limited, are implemented according to the conventional means in this field.
Claims
1. A method for filling regional holes based on run length encoding, characterized in that: include: Obtaining original region information of the image, and obtaining inverse information of the original region according to the original region information; Obtain the corresponding background area information based on the inverted information of the original area; The hole filling area information is obtained according to the original area information and the background area information.
2. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The steps of obtaining original region information of an image and obtaining inverse information of the original region according to the original region information include: Get the original area information of the image; Obtain the corresponding minimum circumscribed regular rectangle information according to the original area information; Each side of the minimum circumscribed regular rectangle information is extended outward by one pixel width, and the extended result is marked as Rect area information; 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.
3. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The step of obtaining the corresponding background area information according to the inverted information of the original area includes: Obtain the corresponding candidate background area BP information according to the inverse information of the original area; Obtain the run length code and adjacency relationship of the candidate background area BP information; Construct a trip connectivity relationship table according to the trip codes and adjacency relationship 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 the run codes connected to the starting run code according to the run connection 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; The background area information is obtained according to the order of each run length encoding.
4. The method for filling regional holes based on run length encoding according to claim 3, characterized in that: Adjacency relationships include eight-neighborhood and four-neighborhood.
5. The method for filling regional holes based on run length encoding according to claim 3, characterized in that: The step of constructing a trip connectivity table according to the trip codes and adjacency relationships of the candidate background area BP information includes: Obtain the start number and the end number of each line of run length coding in the run length coding of the candidate background area BP information; Get the inter-line information according to the start and end numbers of each line of run length encoding; The run length codes of two adjacent rows are compared in order 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.
6. The method for filling regional holes based on run length encoding according to claim 3, characterized in that: The first run length code in the background area BP information belongs to the background area, and all the run length codes in the background area are connected to the first run length code.
7. The method for filling regional holes based on run length encoding according to claim 3, characterized in that: The step of obtaining the order of each run length coding in the connected run length coding information comprises: 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.
8. The method for filling regional holes based on run length encoding according to claim 7, characterized in that: According to the traversal method of depth-first search, 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 an activated 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.
9. The method for filling regional holes based on run length encoding according to claim 1, characterized in that: The step of obtaining hole filling area information according to the original area information and the background area information includes: Get the corresponding Rect area information according to the original area information; Get the hole filling area information based on the Rect area information and the background area information.
10. A regional hole filling terminal based on run length coding, 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 area hole filling method based on run length coding as described in any one of claims 1 to 9.
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
Eye ground color photo repairing method, device and system based on diffusion model, medium and program product
CN119477758A
Hole filling method using estimated spatio-temporal background information, and recording medium and apparatus for performing the same
US20180357813A1
Cited By
Hole filling method based on run-length coding and image processing device
CN120635082A
Hole filling method based on run-length encoding and image processing device
CN120635082B