A method, device and storage medium for region connectivity merging

By performing depth-first search and dynamic merging processing in high-resolution images, the problems of high computational complexity and inflexible merging conditions in the prior art are solved, and more efficient regional connectivity merging analysis is achieved.

CN119741331BActive Publication Date: 2025-06-20SHENZHEN SEICHITECH TECHN CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510245195.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-04
Publication Date
2025-06-20
Estimated Expiration
2045-03-04

AI Technical Summary

Technical Problem

In prior art In high-resolution images, independent operations of connectivity judgment and region merging lead to a significant increase in computational complexity and do not have the ability to dynamically merge and flexibly adjust merging conditions.

Method used

By obtaining the target image and converting it into a binarized image, initializing the area label matrix and stack, generating a merge distance threshold, scanning pixel by pixel for depth priority search, detecting and merging target areas that meet the conditions, and dynamically updating the area boundaries.

Benefits of technology

It improves the ability to dynamic merging and flexible adjustment of merging conditions in traditional connectivity domain analysis, reduces the computational complexity, and improves image processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119741331B_ABST
    Figure CN119741331B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, and storage medium for region connectivity merging, which are used to improve the ability of traditional connected component analysis for dynamic merging and flexible adjustment of merging conditions. Convert the target image into a binary image; initialize the region label matrix and stack, initialize the set of region boundary pixels and record the boundary pixels; generate a merging distance threshold according to the target image; perform a depth-first search, recursively visit the neighboring pixels of the current pixel, add the eligible pixels to the stack, and update the region label matrix; if there is a background pixel among the neighboring pixels, the current pixel is determined as a boundary pixel; calculate the shortest distances between all pairs of region boundary pixels and save the results, and analyze the shortest distances between all pairs of region boundary pixels and the merging distance threshold; merge the target regions that meet the merging conditions according to the analysis results; update the region label matrix and recalculate the new boundaries of the merged regions; output the merged region image and the region label matrix.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of display screen area connectivity merging, and in particular, to a method, device, and storage medium for area connectivity merging. Background Art

[0002] In the fields of image processing and computer vision, regional connectivity analysis is a very basic and crucial step in image segmentation and object extraction. Its purpose is to identify adjacent pixels in an image and merge them into connected regions. As an important means in the field of display screen detection, regional connectivity analysis plays an important role in defect detection, foreign object detection, and regional positioning detection of display screens.

[0003] Existing methods for regional connectivity analysis of display screens usually adopt run-length encoding scanning or connectivity algorithms based on neighborhood analysis. Although these methods can effectively detect connected regions, in high-resolution images, the independent operations of connectivity judgment and region merging significantly increase the computational complexity. This is because with the development of display screens, display screens gradually have more functions, and the increase in functions will lead to an increase in the number of layers of the display screen, or improvements in each layer, etc. This makes the structure of LCD screens complex. Existing LCD screens can include multiple components such as a CG cover plate, OCA glue, an upper polarizer, a TFT, a CF, a lower polarizer, and a backlight. And in the production and manufacturing process of display screens, due to the complex structure, foreign objects may be generated in many production links. These foreign objects may be generated between any two adjacent layers. All of these require high-resolution cameras to cooperate with lenses to collect images of the display screen, and the collected high-resolution images increase the difficulty of regional connectivity analysis.

[0004] Current regional connectivity calculation and region merging based on run-length codes require a large number of adjacency judgments and multiple traversals, and do not have the ability to dynamically merge and flexibly adjust merging conditions. Summary of the Invention

[0005] The present application discloses a method, device, and storage medium for area connectivity merging, which is used to improve the dynamic merging and flexible adjustment of merging conditions in traditional connected component analysis.

[0006] First aspect, an embodiment of the present application provides a method for region connectivity merging, including: obtaining a target image, converting the target image into a binary image; initializing a region label matrix, initializing a stack, initializing a set of region boundary pixels, and recording the boundary pixels of each region in the binary image; generating a merging distance threshold according to the target image; performing a depth-first search by scanning the binary image pixel by pixel, recursively accessing the neighboring pixels of the current pixel, adding the eligible pixels to the stack and marking them as members of the current region, and updating the region label matrix, and determining the current region that has completed this operation as a target region; during the depth-first search process, simultaneously detecting the pixel values of the neighboring pixels of the current pixel, if there are background pixels among the neighboring pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current region; for each target region, recursively traversing the pairs of region boundary pixels between every two target regions; calculating the shortest distances of all pairs of region boundary pixels and saving the results, and analyzing the shortest distances of all pairs of region boundary pixels and the merging distance threshold; merging the target regions that meet the merging conditions according to the analysis results; updating the region label matrix, uniformly updating the pixel labels of the original two target regions to the new region label, and recalculating the new boundary of the merged region; outputting the merged region image and the region label matrix.

[0007] Optionally, in some embodiments of the present application, after obtaining the target image and converting the target image into a binary image, before performing a depth-first search by scanning the binary image pixel by pixel, recursively accessing the neighboring pixels of the current pixel, adding the eligible pixels to the stack and marking them as members of the current region, and updating the region label matrix, and determining the current region that has completed this operation as a target region, the method further includes: detecting isolated noise points and pseudo-target regions in the binary image; filtering the isolated noise points and pseudo-target regions.

[0008] Optionally, in some embodiments of the present application, after recursively traversing the pairs of region boundary pixels between every two target regions for each target region, before calculating the shortest distances of all pairs of region boundary pixels and saving the results, and analyzing the shortest distances of all pairs of region boundary pixels and the merging distance threshold, the method further includes: estimating and generating calculation data volume by using the number of labeled target regions and the number of boundary pixels; setting a calculation data volume threshold; when the calculation data volume exceeds the calculation data volume threshold, using a data structure such as a quadtree, KD tree, or R tree to accelerate the shortest distance query calculation of region boundary pixels, or using an image parallel computing framework to distribute the shortest distance calculation task of region boundary pixel pairs to multiple processing units for concurrent processing.

[0009] Optionally, in some embodiments of the present application, the target image is an image acquired by a display screen including an internal circuit region; generating a merging distance threshold according to the target image includes: obtaining the distribution information of the in-screen circuit regions of the target display screen, where there are circuits with reflection ability arranged on the target display screen; determining at least one circuit region range on the target image according to the in-screen circuit region distribution information; calculating a plurality of merging distance thresholds according to the reflectivity of each circuit region range, the gray-scale mean value of the non-circuit regions of the target image, and the gray-scale mean value of each circuit region range of the target image.

[0010] Optionally, in some embodiments of the present application, after merging the target regions that meet the merging conditions according to the analysis result and updating the region label matrix to uniformly update the pixel labels of the original two target regions to new region labels, and before recalculating the new boundary of the merged region, the method further includes: determining the shrinking region and the expanding region of the image after the target region merging according to the circuit region distribution information, where the shrinking region is a region with an area smaller than a preset threshold, and the expanding region is a region with an area larger than a preset threshold; adjusting the merging distance threshold of the expanding region, analyzing the shortest distance between the region boundary pixels of the target region corresponding to the expanding region and the adjacent target regions, and performing region merging processing again; performing foreign object analysis according to the area information and circularity information of the shrinking region; when the analysis indicates the presence of foreign objects, performing watershed algorithm processing on the shrinking region; when the analysis indicates the absence of foreign objects, adjusting the merging distance threshold of the shrinking region, analyzing the shortest distance between the region boundary pixels of the target region corresponding to the shrinking region and the adjacent target regions, and performing region merging processing again.

[0011] Optionally, in some embodiments of the present application, when the analysis indicates the absence of foreign objects, the steps of adjusting the merging distance threshold of the shrinking region, analyzing the shortest distance between the region boundary pixels of the target region corresponding to the shrinking region and the adjacent target regions, and performing region merging processing again include: when the analysis indicates the absence of foreign objects, determining the linear circuit region in the circuit region on the target image, where the linear circuit region is a circuit range composed of dense metal lines, and there are several non-circuit gap regions between the metal lines; when there is an overlap between the linear circuit region and the shrinking region, obtaining the region proportion of the non-circuit gap region from the overlapping linear circuit region; calculating the merging distance threshold of the shrinking region according to the reflectivity of the linear circuit region, the region proportion, the gray-scale mean value of the non-circuit regions of the target image, and the gray-scale mean value of the circuit region of the target image; determining the shortest distance between the region boundary pixels of the target region corresponding to the shrinking region and the adjacent target regions, and analyzing the shortest distance using the merging distance threshold of the shrinking region; merging the target regions that meet the merging conditions according to the analysis result.

[0012] Optionally, in some embodiments of the present application, to adjust the merging distance threshold of the expansion region, analyze the shortest distance between the region boundary pixel pairs of the target region corresponding to the expansion region and the adjacent target regions, the steps of performing the region merging process again include: determining the circuit region to be adjusted corresponding to the expansion region on the target image; determining the adjacent circuit regions of the circuit region to be adjusted, and determining the reflectivity of the adjacent circuit regions; scaling and moving the circuit region to be adjusted according to the reflectivity of the adjacent circuit regions and the reflectivity of the circuit region to be adjusted to generate a target circuit region; calculating the merging distance threshold of the expansion region according to the reflectivity of the circuit region to be adjusted, the gray mean value of the non-circuit region of the target image, and the gray mean value of the target circuit region; determining the shortest distance between the region boundary pixel pairs of the target region corresponding to the expansion region and the adjacent target regions, and analyzing the shortest distance using the merging distance threshold of the expansion region; merging the target regions that meet the merging conditions according to the analysis result.

[0013] In a second aspect, an embodiment of the present application provides a device for region connectivity merging, including: an acquisition unit configured to acquire a target image and convert the target image into a binary image; an initialization unit configured to initialize a region label matrix, initialize a stack, initialize a region boundary pixel set, and record the boundary pixels of each region in the binary image; a first generation unit configured to generate a merging distance threshold according to the target image; a scanning unit configured to perform a depth-first search by scanning the binary image pixel by pixel, recursively access the neighborhood pixels of the current pixel, add the eligible pixels to the stack and mark them as members of the current region, and update the region label matrix, and determine the current region that has completed this operation as a target region; a first determination unit configured to, during the depth-first search process, simultaneously detect the pixel values of the neighborhood pixels of the current pixel, and if there is a background pixel among the neighborhood pixels, determine the current pixel as a boundary pixel and add it to the boundary set of the current region; a traversal unit configured to, for each target region, recursively traverse the region boundary pixel pairs between every two target regions; a calculation unit configured to calculate the shortest distance of all region boundary pixel pairs and save the result, and analyze the shortest distance of all region boundary pixel pairs and the merging distance threshold; a merging unit configured to merge the target regions that meet the merging conditions according to the analysis result; an updating unit configured to update the region label matrix, uniformly update the pixel labels of the original two target regions to a new region label, and recalculate the new boundary of the merged region; an output unit configured to output the merged region image and the region label matrix.

[0014] Optionally, in some embodiments of the present application, after the acquisition unit and before the scanning unit, the device further includes: a detection unit configured to detect isolated noise points and pseudo-target regions in the binary image; a filtering unit configured to filter the isolated noise points and pseudo-target regions.

[0015] Optionally, in some embodiments of the present application, after the traversal unit and before the calculation unit, the apparatus further includes: a second generation unit, configured to generate calculation data volume by estimating the number of marked target regions and the number of boundary pixels; a setting unit, configured to set a calculation data volume threshold; a first processing unit, configured to, when the calculation data volume exceeds the calculation data volume threshold, accelerate the shortest distance query calculation of the region boundary pixels by using a data structure such as a quadtree, a KD tree, or an R tree, or distribute the shortest distance calculation task of the region boundary pixel pairs to multiple processing units for concurrent processing by using an image parallel computing framework.

[0016] Optionally, in some embodiments of the present application, the target image is a display screen acquisition image including an internal circuit region; the first generation unit includes: obtaining the in-screen circuit region distribution information of the target display screen, where a circuit with a reflection ability is provided on the target display screen; determining at least one circuit region range on the target image according to the in-screen circuit region distribution information; calculating a plurality of merging distance thresholds according to the reflectivity of each circuit region range, the gray mean value of the non-circuit region of the target image, and the gray mean value of each circuit region range of the target image.

[0017] Optionally, in some embodiments of the present application, after the merging unit and before the updating unit, the apparatus further includes: a second determination unit, configured to determine a reduced region and an expanded region of the image after the target region merging according to the circuit region distribution information, where the reduced region is a region with an area smaller than a preset threshold, and the expanded region is a region with an area larger than a preset threshold; a first adjustment unit, configured to adjust the merging distance threshold of the expanded region, analyze the shortest distance between the region boundary pixels of the target region corresponding to the expanded region and the adjacent target regions, and perform region merging processing again; an analysis unit, configured to perform foreign object analysis according to the area information and circularity information of the reduced region; a second processing unit, configured to perform a watershed algorithm process on the reduced region when the analysis indicates the presence of foreign objects; a second adjustment unit, configured to adjust the merging distance threshold of the reduced region and analyze the shortest distance between the region boundary pixels of the target region corresponding to the reduced region and the adjacent target regions when the analysis indicates the absence of foreign objects, and perform region merging processing again.

[0018] Optionally, in some embodiments of the present application, the first adjustment unit includes: when analyzing that there is no foreign object, determining a linear circuit area in the circuit area of the target image, where the linear circuit area is a circuit range composed of dense metal lines, and there are several non-circuit gap areas between the metal lines; when there is an overlap between the linear circuit area and the shrinking area, obtaining the area ratio of the non-circuit gap area from the overlapping linear circuit area; calculating the merging distance threshold of the shrinking area according to the reflectivity of the linear circuit area, the area ratio, the gray mean value of the non-circuit area of the target image, and the gray mean value of the circuit area of the target image; determining the shortest distance between the region boundary pixels of the target region corresponding to the shrinking area and the adjacent target regions, and analyzing the shortest distance using the merging distance threshold of the shrinking area; merging the target regions that meet the merging conditions according to the analysis result.

[0019] Optionally, in some embodiments of the present application, the second adjustment unit includes: determining the circuit area to be adjusted corresponding to the expanding area on the target image; determining the adjacent circuit areas of the circuit area to be adjusted, and determining the reflectivity of the adjacent circuit areas; scaling and moving the circuit area to be adjusted according to the reflectivity of the adjacent circuit areas and the reflectivity of the circuit area to be adjusted to generate a target circuit area; calculating the merging distance threshold of the expanding area according to the reflectivity of the circuit area to be adjusted, the gray mean value of the non-circuit area of the target image, and the gray mean value of the target circuit area; determining the shortest distance between the region boundary pixels of the target region corresponding to the expanding area and the adjacent target regions, and analyzing the shortest distance using the merging distance threshold of the expanding area; merging the target regions that meet the merging conditions according to the analysis result.

[0020] In a third aspect, an embodiment of the present application provides a device for region connectivity merging, including:

[0021] A processor, a memory, an input / output unit, and a bus;

[0022] The processor is connected to the memory, the input / output unit, and the bus;

[0023] The memory stores a program, and the processor calls the program to execute the methods as described in the first aspect and any optional methods of the first aspect.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, it executes the methods as described in the first aspect and any optional methods of the first aspect.

[0025] From the above technical solutions, it can be seen that the embodiments of the present application have the following advantages:

[0026] In this application, first, a target image is obtained and converted into a binary image. Next, a region label matrix is initialized, a stack is initialized, a set of region boundary pixels is initialized, and the boundary pixels of each region in the binary image are recorded. A merging distance threshold is generated based on the target image. The binary image is scanned pixel by pixel for depth - first search, and the neighboring pixels of the current pixel are recursively accessed. The pixels that meet the conditions are added to the stack and marked as members of the current region, and the region label matrix is updated. The current region for which this operation is completed is determined as a target region. During the depth - first search process, the pixel values of the neighboring pixels of the current pixel are simultaneously detected. If there are background pixels among the neighboring pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current region. For each target region, the pairs of region boundary pixels between every two target regions are recursively traversed. The shortest distances of all region boundary pixel pairs are calculated and the results are saved. The shortest distances of all region boundary pixel pairs and the merging distance threshold are analyzed. According to the analysis results, the target regions that meet the merging conditions are merged. The region label matrix is updated, and the pixel labels of the original two target regions are uniformly updated to the new region label. The new boundary of the merged region is recalculated. The merged region image and the region label matrix are output.

[0027] By calculating the pairs of region boundary pixels and analyzing them with the merging distance threshold, the regions that can be merged are determined. After the regions are merged, the boundary of the merged region is dynamically updated through the boundary pixel sets of the regions before and after merging. Using the depth - first search algorithm combined with boundary pixel extraction, merging queue, and dynamic update strategy, the regional connectivity is efficiently judged and adjacent regions are merged, improving the ability of traditional connected - component analysis for dynamic merging and flexible adjustment of merging conditions. Brief Description of the Drawings

[0028] To more clearly illustrate the technical solutions in the embodiments of this application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0029] Figure 1 It is a schematic diagram of an embodiment of the method for regional connectivity merging of this application;

[0030] Figure 2 It is a schematic diagram of an embodiment of the method for pre - processing the target image of this application;

[0031] Figure 3 It is a schematic diagram of an embodiment of the method for improving the efficiency of connected - component processing of this application;

[0032] Figure 4Schematic diagram of an embodiment of the method for generating a merging distance threshold for this application;

[0033] Figure 5 Schematic diagram of an embodiment of the method for detecting and adjusting after connected component merging for this application;

[0034] Figure 6 Schematic diagram of an embodiment of the method for processing shrinking regions for this application;

[0035] Figure 7 Schematic diagram of an embodiment of the method for processing expanding regions for this application;

[0036] Figure 8 Schematic diagram of an embodiment of the apparatus for connected region merging for this application;

[0037] Figure 9 Schematic diagram of another embodiment of the apparatus for connected region merging for this application. Detailed implementation manners

[0038] In the following description, for the purpose of illustration rather than limitation, specific details such as specific system architectures, technologies, etc. are proposed to thoroughly understand the embodiments of this application. However, those skilled in the art should clearly understand that this application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of this application.

[0039] It should be understood that when used in the specification and appended claims of this application, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.

[0040] It should also be understood that the term "and / or" as used in the specification and appended claims of this application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0041] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" according to the context. Similarly, the phrase "if determined" or "if [the described condition or event] is detected" can be interpreted as meaning "once determined" or "in response to determining" or "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]" according to the context.

[0042] In addition, in the description of the specification and the appended claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and should not be construed as indicating or implying relative importance.

[0043] The reference to "one embodiment" or "some embodiments" in the description of the present application means that a specific feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized.

[0044] In the prior art, for the method of analyzing the regional connectivity of a display screen, run-length encoding scanning or a connectivity algorithm based on neighborhood analysis is usually adopted. Although these methods can effectively detect connected regions, in high-resolution images, the independent operations of connectivity judgment and region merging significantly increase the computational complexity. This is because with the development of display screens, display screens gradually have more functions, and the increase in functions will lead to an increase in the number of layers of the display screen, or improvements in each layer, etc. This makes the structure of the LCD screen complex. The existing LCD screen may include multiple components such as a CG cover plate, OCA glue, an upper polarizer, a TFT, a CF, a lower polarizer, and a backlight. And during the production and manufacturing process of the display screen, due to the complex structure, foreign objects may be generated in many production links, and these foreign objects may be generated between any two adjacent layers. All of these require high-resolution cameras to cooperate with lenses to collect images of the display screen, and the collected high-resolution images increase the difficulty of regional connectivity analysis.

[0045] Currently, both the regional connectivity calculation and region merging based on run-length codes require a large number of adjacency judgments and multiple traversals, and do not have the ability of dynamic merging and flexible adjustment of merging conditions.

[0046] Based on this, the present application discloses a method, device, and storage medium for regional connectivity merging, which are used to improve the ability of dynamic merging and flexible adjustment of merging conditions in traditional connected domain analysis.

[0047] Next, the technical solutions in the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.

[0048] The method of the present application can be applied to servers, devices, terminals, or other devices with logical processing capabilities. In this regard, the present application makes no limitation. For the convenience of description, the following will take the execution entity as a terminal as an example for description.

[0049] Please refer to Figure 1 , an embodiment of a method for region connectivity merging provided by the present application includes:

[0050] 101. Obtain a target image and convert the target image into a binary image.

[0051] In the embodiment of the present application, the target image is mainly an image generated in production inspection and other links of the display screen. Before performing connected component analysis, it is necessary to first perform binary processing on the target image to generate a binary image.

[0052] In the embodiment of the present application, first judge the input image format to ensure that the processed image is already in the standard binary image format, that is, the pixel value of the target area is 1 (white), and the pixel value of the background area is 0 (black).

[0053] 102. Initialize a region label matrix, initialize a stack, initialize a set of region boundary pixels, and record the boundary pixels of each region in the binary image.

[0054] 103. Generate a merging distance threshold according to the target image.

[0055] In the embodiment of the present application, it is necessary to initialize a region label matrix, then initialize a stack, initialize a set of region boundary pixels, record the boundary pixels of each region in the binary image, and then generate a merging distance threshold according to the target image.

[0056] Specifically, initialize the data structure

[0057] 1. Region label matrix: Initialize a matrix with the same size as the input image (binary image) to mark the region label to which each pixel point belongs. When initializing, the label values of all pixel points are set to 0, indicating unvisited.

[0058] 2. Initialize a stack: A stack data structure used to implement DFS, storing the pixels currently being visited.

[0059] 3. Region boundary pixel set: Record the boundary pixels of each region. The boundary pixels refer to the foreground pixels adjacent to the background pixels.

[0060] 4. Create a merging queue: Store the regions to be merged and the shortest distances of the boundary pixels of each region to avoid repeated calculations.

[0061] 5. Merging distance threshold: Set the merging distance threshold for adjacent regions. In the embodiments of the present application, it needs to be flexibly set according to requirements such as actual detection items. The specific setting scheme will be explained in the subsequent embodiments.

[0062] Through the above 5 steps, the preprocessing link of connected component analysis can be completed.

[0063] 104. Scan the binary image pixel by pixel for depth - first search, recursively visit the neighborhood pixels of the current pixel, add the eligible pixels to the stack and mark them as members of the current region, and update the region label matrix. Determine the current region that has completed this operation as a target region.

[0064] In the embodiments of the present application, the terminal starts a depth - first search (DFS). First, start from any unvisited pixel point (generally, it can start from the upper - left corner of the image and traverse the image in row - first order or column - first order), and scan the binary image pixel by pixel. For each unvisited pixel of the target region, start a depth - first search (DFS).

[0065] During the DFS process, recursively visit the neighborhood of the current pixel (generally 4 - neighborhood or 8 - neighborhood). If its neighborhood pixel is a pixel of the target region, add it to the stack and mark it as a member of the current region.

[0066] During each DFS recursion process, simultaneously update the region label matrix, and mark all pixels connected to the current starting pixel with the same region label.

[0067] 105. During the depth - first search process, simultaneously detect the pixel values of the neighborhood pixels of the current pixel. If there is a background pixel among the neighborhood pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current region.

[0068] During the depth - first search process, boundary pixel extraction is also required. Specifically, during the DFS process of the terminal, simultaneously check the neighborhood pixel values of the current pixel. If there is a background pixel among the neighborhood pixels (at least one neighborhood pixel value is 0), the current pixel is regarded as a boundary pixel and added to the boundary set of the region.

[0069] After the depth - first search (DFS) ends, that is, after the DFS traversal ends, each pixel point in the image is marked with a unique region label to which it belongs, and at the same time, the boundary pixel points of each region are extracted.

[0070] 106. For each target region, recursively traverse each pair of region boundary pixels between every two target regions.

[0071] 107. Calculate the shortest distances between all pairs of boundary pixels of the regions and save the results, and analyze the shortest distances between all pairs of boundary pixels of the regions and the merging distance threshold.

[0072] After the depth-first search is completed, dynamic judgment is also required to merge and update adjacent regions.

[0073] First, calculate the shortest distances of the region boundaries. For each marked target region, recursively traverse the boundary pixels of the current target region and any other target region, calculate the shortest distances between each pair of boundary pixels of the two regions, and save the results.

[0074] Among them, the distance calculation can use distance measurement methods such as Euclidean distance or Manhattan distance to measure the relative distance between two regions.

[0075] 108. Merge the target regions that meet the merging conditions according to the analysis results.

[0076] 109. Update the region label matrix, uniformly update the pixel labels of the original two target regions to the new region label, and recalculate the new boundary of the merged region.

[0077] Judgment of the region merging conditions. First, according to the preset merging distance threshold, if the shortest distance between the boundaries of two regions is less than the threshold, it is considered that these two regions are adjacent and can be merged.

[0078] Next, the terminal manages all pairs of regions that meet the conditions through the merging queue to avoid repeated calculations and redundant operations.

[0079] After the merging condition judgment is completed, the terminal needs to dynamically merge adjacent regions.

[0080] For each pair of regions in the merging queue, judge by comparing the shortest distance of its boundary with the preset merging distance threshold. If the merging condition is met, merge these two regions into a new region.

[0081] After merging, update the region label matrix, and uniformly update the pixel labels of the original two regions to the new region label.

[0082] After merging, it is necessary to recalculate the new boundary of the merged region. The new boundary of the merged region can be dynamically updated through the boundary pixel sets of the regions before and after merging.

[0083] 110. Output the merged region image and the region label matrix.

[0084] The terminal outputs the merged regional image and the regional label matrix. Specifically, after region connectivity analysis and adjacent region merging, a new regional label matrix is output, where each pixel is assigned a unique regional label. All merged regions will have a unified label value, indicating that they belong to the same merged region. The output regional label matrix can be further used for subsequent image processing tasks, such as region feature extraction, object detection, image segmentation, etc.

[0085] In the embodiment of the present application, first, a target image is obtained and converted into a binary image. Next, the regional label matrix is initialized, a stack is initialized, the set of regional boundary pixels is initialized, and the boundary pixels of each region in the binary image are recorded. A merging distance threshold is generated according to the target image. The binary image is scanned pixel by pixel for depth-first search, the neighborhood pixels of the current pixel are recursively accessed, the eligible pixels are added to the stack and marked as members of the current region, and the regional label matrix is updated. The current region that has completed this operation is determined as a target region. During the depth-first search process, the pixel values of the neighborhood pixels of the current pixel are also detected. If there are background pixels among the neighborhood pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current region. For each target region, the pairs of regional boundary pixels between every two target regions are recursively traversed. The shortest distances of all pairs of regional boundary pixels are calculated and the results are saved. The shortest distances of all pairs of regional boundary pixels are analyzed together with the merging distance threshold. According to the analysis results, the target regions that meet the merging conditions are merged. The regional label matrix is updated, and the pixel labels of the original two target regions are uniformly updated to the new regional label, and the new boundary of the merged region is recalculated. The merged regional image and the regional label matrix are output.

[0086] By calculating pairs of regional boundary pixels and analyzing them with the merging distance threshold, the regions that can be merged are determined. After the regions are merged, the boundary of the merged region is dynamically updated through the boundary pixel sets of the regions before and after merging. By combining the depth-first search algorithm with boundary pixel extraction, merging queue, and dynamic update strategy, the regional connectivity and adjacent region merging are efficiently judged, improving the dynamic merging and flexible adjustment of merging conditions in traditional connected component analysis.

[0087] Secondly, by combining the depth-first search algorithm with boundary pixel extraction, merging queue, and dynamic update strategy, the regional connectivity and adjacent region merging can be efficiently judged, greatly improving the calculation efficiency and effectively reducing the repeated traversal of the image and unnecessary computational overhead.

[0088] Moreover, in the embodiment of the present application, the merging distance threshold can be flexibly set according to actual needs to dynamically judge and merge adjacent regions, adapting to different image analysis tasks.

[0089] Please refer to Figure 2 , an embodiment of a method for preprocessing a target image provided by this application includes:

[0090] 201. Detect isolated noise points and pseudo-target regions in the binary image.

[0091] 202. Filter out the isolated noise points and pseudo-target regions.

[0092] In the embodiment of this application, the terminal needs to detect whether there are isolated noise points and pseudo-target regions in the binary image. An isolated noise point refers to a single pixel point or a pixel point region with a number that does not meet the detection purpose, and a pseudo-target region refers to a pixel point region with a shape that does not meet the detection item.

[0093] Specifically, for denoising processing of the binary image, first perform denoising processing on the input binary image to eliminate isolated noise points and small-area pseudo-target regions. Common methods in the embodiment of this application include median filtering, mean filtering, Gaussian filtering, morphological processing, etc.

[0094] Please refer to Figure 3 , an embodiment of a method for improving the efficiency of connected component processing provided by this application includes:

[0095] 301. Estimate using the number of marked target regions and the number of boundary pixels to generate the calculated data volume.

[0096] 302. Set the calculated data volume threshold.

[0097] 303. When the calculated data volume exceeds the calculated data volume threshold, use the data structures of quadtree, KD-tree or R-tree to accelerate the shortest distance query calculation of the region boundary pixels, or use the image parallel computing framework to distribute the shortest distance calculation tasks of the region boundary pixel pairs to multiple processing units for concurrent processing.

[0098] In the embodiment of this application, in order to improve the efficiency of connected components, the terminal first estimates using the number of marked target regions and the number of boundary pixels to generate the calculated data volume, and sets the calculated data volume threshold, and then determines whether the calculated data volume exceeds the calculated data volume threshold. If it exceeds, use data structures such as quadtree, KD-tree or R-tree to accelerate the shortest distance query calculation of the region boundary pixels, or use the image parallel computing framework to distribute the shortest distance calculation tasks of the region boundary pixel pairs to multiple processing units for concurrent processing.

[0099] Specifically, before calculation, the number of marked target regions and the number of boundary pixels can be used to estimate the amount of data to be calculated. By setting a calculation data volume threshold, when the estimated calculation data volume exceeds this threshold, data structures such as KD - tree can be used to accelerate the calculation of the shortest distance query for the boundary pixels of the region, or an image parallel computing framework (such as CUDA or OpenCL) can be used to distribute the shortest distance calculation task of the boundary pixel pairs to multiple processing units for concurrent processing to achieve the purpose.

[0100] Please refer to Figure 4 , an embodiment of a method for generating a merging distance threshold provided by this application includes:

[0101] 401. Obtain the distribution information of the in - screen circuit regions of the target display screen, and there are circuit blocks with reflection ability set on the target display screen.

[0102] 402. Determine the circuit regions on the target image according to the in - screen circuit region distribution information.

[0103] 403. Calculate the merging distance threshold according to the reflectivity of the circuit blocks, the average gray value of the non - circuit regions of the target image, and the average gray value of the circuit regions of the target image.

[0104] In the embodiments of this application, the connected - component analysis is mainly for LCD screens with internal circuits set on the pixel layer, and the detection items to be carried out are the detection items of the circuit regions and the display regions.

[0105] With the continuous update and improvement of LCD screens, the functionality of LCD screens has been continuously developed. Adding necessary circuit modules inside the LCD screen has become a means to improve the functionality of the display screen. In order to reduce the influence of circuit modules on the detection of the screen body defects (external light source detection) and in - screen defects (pixel - layer light source detection) of the LCD screen, usually as thin circuit modules as possible are prepared to reduce the reflection of light sources, and thus reduce the influence on the detection image. However, even if as thin circuits as possible have been adopted and then certain refinement processing (area refinement of the circuit structure) has been carried out, when implementing some specific functions, due to the complex components or coupling methods required by the functional circuit, there may still be a thickness that can affect the light source reflection, because the main material of the existing platform internal circuit is metal, and some metals have a certain reflection ability.

[0106] In order to reduce the influence, it is usually necessary to accurately locate the circuit regions on the captured image (target image) of the LCD screen, and then perform gray - scale adjustment on the whole image according to the pixel information of the circuit regions on the captured image of the LCD screen to reduce the influence brought by the circuit regions on other LCD screen detections.

[0107] In the embodiment of the present application, the circuit area distribution information within the target display screen is first obtained. The target display screen may be provided with at least one circuit area with reflective ability, that is, the internal circuit distribution information of the LCD screen during the production process, as well as the internal circuit structure, material, thickness, area, etc., are first obtained. The reflective ability of the circuit block can be analyzed based on the internal circuit structure, material, thickness and area data, and then the circuit with stronger reflective ability (the circuit that will affect subsequent detection) is roughly determined based on the internal circuit distribution information. Next, the circuit area and non-circuit area are determined on the target image based on the circuit area distribution information within the screen. The circuit area is a roughly positioned area, because it is not positioned by analyzing the pixel information of the captured image, but directly using standard circuit distribution data for positioning, which may result in deviations. Next, the reflectivity of the circuit block is pre-calculated. This data can calculate its reflectivity to the pixel layer light source through parameters such as material and thickness.

[0108] Because the circuits in the circuit area of ​​the LCD screen are complex, there are circuits composed of dense metal lines and entire circuit blocks. The entire circuit area has no gaps in the non-circuit area, and in the circuit composed of dense metal lines, there are usually some non-circuit areas (non-circuit gaps) between two adjacent metal lines.

[0109] When we roughly delineate the above two types of circuit areas on the target image, we usually need to reduce the circuit area again when extracting the grayscale mean to prevent interference from non-circuit areas on the boundaries of the original circuit area.

[0110] The pixel mean of this type of non-circuit area is also calculated by shrinking the non-circuit area and then calculating the grayscale to reduce the grayscale interference of the circuit area. After calculating the grayscale mean of the non-circuit area, the circuit area of ​​the target image (with a reflectivity reaching a preset threshold) is determined, and the grayscale mean is calculated after shrinking.

[0111] After calculating the grayscale mean of the non-circuit area of ​​the target image and the grayscale mean of the circuit area of ​​the target image, the merge distance threshold is calculated in combination with the reflectivity of the preset circuit block. The calculation formula is as follows.

[0112]

[0113] in, is the merge distance threshold, is the grayscale mean of the non-circuit area, is the mean grayscale value of the circuit area, is the reflectivity of the circuit block, is the unit length between two adjacent pixels in the LCD screen with an internal circuit. For the merging distance threshold calculated in the above manner, the greater the reflectivity, the greater the difference between the entire image circuit area and the non-circuit area. Thus, a large merging distance threshold is not required for connected component analysis. Conversely, a slightly larger merging distance threshold is needed, especially for circuit areas with gaps in the non-circuit area. Through this method, such circuit areas can be better detected, improving the effect of connected component analysis.

[0114] Please refer to Figure 5 , an embodiment of a method for detecting and adjusting after connected component merging provided by this application includes:

[0115] 501. Determine the reduced area and the expanded area of the image after merging the target areas. The reduced area is the area with an area smaller than the preset threshold, and the expanded area is the area with an area larger than the preset threshold.

[0116] 502. Adjust the merging distance threshold of the expanded area, analyze the shortest distance of the region boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target areas, and perform region merging processing again.

[0117] 503. Perform foreign object analysis based on the area information and roundness information of the reduced area.

[0118] 504. When the analysis indicates the presence of foreign objects, perform the watershed algorithm on the reduced area.

[0119] 505. When the analysis indicates the absence of foreign objects, adjust the merging distance threshold of the reduced area, analyze the shortest distance of the region boundary pixel pairs of the target area corresponding to the reduced area and the adjacent target areas, and perform region merging processing again.

[0120] In the embodiment of this application, the terminal determines the reduced area and the expanded area of the image after merging the target areas according to the circuit area distribution information. The reduced area is the circuit area with an area smaller than the preset threshold, and the expanded area is the circuit area with an area larger than the preset threshold. That is, analyze the detected circuit areas to check for abnormalities. Usually, it is compared and analyzed with the circuit area distribution information in the screen. If the detected circuit area is smaller than the area in the circuit area distribution information in the screen, it is determined as the reduced area. If the detected circuit area is larger than the area in the circuit area distribution information in the screen, it is determined as the expanded area.

[0121] There are various reasons for the generation of the reduced area. The common reason is the presence of foreign objects, which leads to a decrease in the gray level mean value, and then leads to a decrease in the merging distance threshold. Another common reason is the gaps in the non-circuit area in the circuit composed of dense metal lines. When calculating the gray level mean value, these non-circuit area gaps will lower the gray level mean value, and then lead to a decrease in the merging distance threshold.

[0122] Therefore, it is necessary to first perform foreign object analysis based on the area information and roundness information of the shrunk region. When the area is greater than the distribution information of the in-screen circuit region and the roundness information indicates the existence of a shape (irregular) that does not belong to the circuit, it can be determined that there is a foreign object, and the watershed algorithm needs to be applied to the shrunk region to make it meet the preset threshold. If it is not a foreign object, the merging distance threshold of the shrunk region needs to be adjusted (increased), and the shortest distance between the region boundary pixels of the shrunk region and other adjacent target regions needs to be analyzed again, and the region merging process can be carried out again to solve the problem.

[0123] When determining the circuit region and non-circuit region on the target image according to the distribution information of the in-screen circuit region, due to the deviation of rough positioning, one circuit region may encompass another adjacent circuit region, and the reflectivity of this adjacent circuit region is stronger than that of the current circuit region, resulting in an increase in the average gray value, and further causing an increase in the merging distance threshold, resulting in an expanded region.

[0124] At this time, it is necessary to adjust the merging distance threshold of the expanded region, analyze the shortest distance between the region boundary pixels of the target region corresponding to the expanded region and the adjacent target regions, and perform the region merging process again.

[0125] Please refer to Figure 6 , an embodiment of a method for processing a shrunk region provided by the present application includes:

[0126] 601. When the analysis indicates the absence of foreign objects, determine the linear circuit region in the circuit region of the target image. The linear circuit region is a circuit range composed of dense metal lines, and there are several non-circuit gap regions between the metal lines;

[0127] 602. When there is an overlap between the linear circuit region and the shrunk region, obtain the region proportion of the non-circuit gap region from the overlapping linear circuit region;

[0128] 603. Calculate the merging distance threshold of the shrunk region according to the reflectivity of the linear circuit region, the region proportion, the average gray value of the non-circuit region of the target image, and the average gray value of the circuit region of the target image;

[0129] 604. Determine the shortest distance between the region boundary pixels of the target region corresponding to the shrunk region and the adjacent target regions, and analyze the shortest distance using the merging distance threshold of the shrunk region;

[0130] 605. Merge the target regions that meet the merging conditions according to the analysis results.

[0131] In the embodiments of the present application, when the analysis indicates that there is no foreign object, the terminal first determines the linear circuit area in the circuit area of the target image. The linear circuit area is a circuit range composed of dense metal lines, and there are several non-circuit gap areas between the metal lines. By comparing the positional relationship between the linear circuit area and the shrunk area, when there is an overlap between the linear circuit area and the shrunk area, it indicates that the appearance of the shrunk area is caused by the non-circuit gaps between the metal lines. At this time, it is necessary to obtain the area ratio of the non-circuit gap area from the overlapping linear circuit area. This parameter can be directly obtained from the circuit area distribution information without pixel data analysis and calculation through an equivalent image.

[0132] When the area ratio of the circuit gap area in a linear circuit area is calculate the merging distance threshold of the shrunk area according to the reflectivity of the linear circuit area, the area ratio, the gray mean value of the non-circuit area of the target image, and the gray mean value of the circuit area of the target image. Specifically, it is necessary to adjust the gray mean value of the circuit area, and the formula is as follows:

[0133]

[0134]

[0135]

[0136] Where is the adjusted merging distance threshold of the shrunk area, is the gray mean value of the non-circuit area, is the original gray mean value of the circuit area, is the adjusted gray mean value of the circuit area, is the reflectivity of the circuit block, is the unit length between two adjacent pixels in the LCD screen with an internal circuit.

[0137] After calculating the new merging distance threshold, return to the steps before merging. For the shrunk area, determine the shortest distance between the target area corresponding to the shrunk area and the area boundary pixels of the adjacent target area, and analyze the shortest distance using the merging distance threshold of the shrunk area. Merge the target areas that meet the merging conditions according to the analysis results.

[0138] Please refer to Figure 7 for an embodiment of a method for processing an expanded area provided by the present application, including:

[0139] 701. Determine the circuit area to be adjusted corresponding to the expanded area on the target image;

[0140] 702. Determine the adjacent circuit regions of the circuit region to be adjusted, and determine the reflectivity of the adjacent circuit regions;

[0141] 703. Scale and move the circuit region to be adjusted according to the reflectivity of the adjacent circuit regions and the reflectivity of the circuit region to be adjusted to generate a target circuit region;

[0142] 704. Calculate the merging distance threshold of the expanded region according to the reflectivity of the circuit region to be adjusted, the gray - scale mean value of the non - circuit regions of the target image, and the gray - scale mean value of the target circuit region;

[0143] 705. Determine the shortest distance between the region boundary pixel pairs of the target region corresponding to the expanded region and the adjacent target regions, and analyze the shortest distance using the merging distance threshold of the expanded region;

[0144] 706. Merge the target regions that meet the merging conditions according to the analysis results.

[0145] In the embodiment of the present application, the terminal determines the circuit region to be adjusted corresponding to the expanded region on the target image, determines the adjacent circuit regions of the circuit region to be adjusted, and determines the reflectivity of the adjacent circuit regions. Compare the magnitudes of the reflectivity of the adjacent circuit regions and the reflectivity of the circuit region to be adjusted. When the reflectivity of the adjacent circuit region is greater than the reflectivity of the circuit region to be adjusted, reduce the circuit region to be adjusted. When reducing, move as far as possible away from the part of the adjacent circuit region with a large reflectivity. If there is no adjacent circuit region in a certain direction, or there is no circuit region with a large reflectivity, position adjustment can be made in this direction to reduce the situation where the target circuit region coincides with the adjacent circuit region with a large reflectivity again.

[0146] After generating the target circuit region, the terminal calculates the merging distance threshold of the expanded region according to the reflectivity of the circuit region to be adjusted, the gray - scale mean value of the non - circuit regions of the target image, and the gray - scale mean value of the target circuit region. The calculation method is the same as that in Embodiment 4 of the present application, and will not be elaborated here. Determine the shortest distance between the region boundary pixel pairs of the target region corresponding to the expanded region and the adjacent target regions, and analyze the shortest distance using the merging distance threshold of the expanded region. Merge the target regions that meet the merging conditions according to the analysis results.

[0147] Please refer to Figure 8 , an embodiment of a device for region - connected merging provided by the present application includes:

[0148] An acquisition unit 801, configured to acquire a target image and convert the target image into a binary image.

[0149] A detection unit 802, configured to detect isolated noise points and pseudo - target regions in the binary image.

[0150] The filtering unit 803 is used to filter out isolated noise points and pseudo-target areas.

[0151] The initialization unit 804 is used to initialize the region label matrix and initialize a stack to record the boundary pixels of each region in the binary image.

[0152] The first generation unit 805 is used to generate a merging distance threshold according to the target image.

[0153] Optionally, the target image is an acquisition image of a display screen containing a circuit area.

[0154] The first generation unit 805 includes:

[0155] Obtain the distribution information of the in-screen circuit areas of the target display screen, where there are circuits with reflective capabilities on the target display screen.

[0156] Determine at least one circuit area range on the target image according to the distribution information of the in-screen circuit areas.

[0157] Calculate several merging distance thresholds according to the reflectivity of each circuit area range, the gray mean value of the non-circuit areas of the target image, and the gray mean value of each circuit area range of the target image.

[0158] The scanning unit 806 is used to perform a depth-first search by scanning the binary image pixel by pixel, recursively access the neighboring pixels of the current pixel, add the qualified pixels to the stack and mark them as members of the current region, and update the region label matrix, and determine the current region that has completed this operation as a target region.

[0159] The first determination unit 807 is used to detect the pixel values of the neighboring pixels of the current pixel during the depth-first search process. If there are background pixels among the neighboring pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current region.

[0160] The traversal unit 808 is used to recursively traverse each pair of region boundary pixels between every two target regions for each target region.

[0161] The second generation unit 809 is used to estimate and generate the calculation data volume by using the number of labeled target regions and the number of boundary pixels.

[0162] The setting unit 810 is used to set a calculation data volume threshold.

[0163] The first processing unit 811 is used to, when the calculation data volume exceeds the calculation data volume threshold, use data structures such as quadtrees, KD-trees, or R-trees to accelerate the calculation of the shortest distance query for region boundary pixels, or use an image parallel computing framework to distribute the shortest distance calculation tasks of region boundary pixel pairs to multiple processing units for concurrent processing.

[0164] A calculation unit 812 is configured to calculate the shortest distances between all pairs of boundary pixels of the entire region and save the results, and analyze the shortest distances between all pairs of boundary pixels of the entire region and the merging distance threshold.

[0165] A merging unit 813 is configured to merge the target regions that meet the merging conditions according to the analysis results.

[0166] A second determination unit 814 is configured to determine the reduced region and the expanded region of the image after the target regions are merged according to the circuit region distribution information, where the reduced region is a region with an area smaller than a preset threshold, and the expanded region is a region with an area larger than a preset threshold.

[0167] A first adjustment unit 815 is configured to adjust the merging distance threshold of the expanded region, analyze the shortest distances between pairs of boundary pixels of the target regions corresponding to the expanded region and the adjacent target regions, and perform region merging processing again.

[0168] Optionally, in some embodiments of the present application, the first adjustment unit includes: when the analysis indicates that there is no foreign object, determining the linear circuit region in the circuit region of the target image, where the linear circuit region is a circuit range composed of dense metal lines, and there are several non-circuit gap regions between the metal lines; when there is an overlap between the linear circuit region and the reduced region, obtaining the region ratio of the non-circuit gap regions from the overlapping linear circuit region; calculating the merging distance threshold of the reduced region according to the reflectivity of the linear circuit region, the region ratio, the gray mean value of the non-circuit region of the target image, and the gray mean value of the circuit region of the target image; determining the shortest distances between pairs of boundary pixels of the target regions corresponding to the reduced region and the adjacent target regions, and analyzing the shortest distances using the merging distance threshold of the reduced region; and merging the target regions that meet the merging conditions according to the analysis results.

[0169] An analysis unit 816 is configured to perform foreign object analysis according to the area information and circularity information of the reduced region.

[0170] A second processing unit 817 is configured to perform a watershed algorithm process on the reduced region when the analysis indicates that there is a foreign object.

[0171] A second adjustment unit 818 is configured to adjust the merging distance threshold of the reduced region and analyze the shortest distances between pairs of boundary pixels of the target regions corresponding to the reduced region and the adjacent target regions when the analysis indicates that there is no foreign object, and perform region merging processing again.

[0172] Optionally, in some embodiments of the present application, the second adjustment unit includes: determining a circuit area to be adjusted corresponding to the expansion area on the target image; determining adjacent circuit areas of the circuit area to be adjusted, and determining the reflectivity of the adjacent circuit areas; scaling and moving the circuit area to be adjusted according to the reflectivity of the adjacent circuit areas and the reflectivity of the circuit area to be adjusted to generate a target circuit area; calculating a merging distance threshold of the expansion area according to the reflectivity of the circuit area to be adjusted, the gray-scale mean value of the non-circuit area of the target image, and the gray-scale mean value of the target circuit area; determining the shortest distance between the region boundaries of the target region corresponding to the expansion area and the adjacent target regions, and analyzing the shortest distance using the merging distance threshold of the expansion area; merging the target regions that meet the merging conditions according to the analysis result.

[0173] The updating unit 819 is configured to update the region label matrix, uniformly update the pixel labels of the original two target regions to new region labels, and recalculate the new boundary of the merged region.

[0174] The output unit 820 is configured to output the merged region image and the region label matrix.

[0175] Please refer to Figure 9 , the present application provides a device for region connectivity merging, including:

[0176] A processor 901, a memory 902, an input / output unit 903, and a bus 904.

[0177] The processor 901 is connected to the memory 902, the input / output unit 903, and the bus 904.

[0178] The memory 902 stores a program, and the processor 901 calls the program to execute the methods in Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 and Figure 7 .

[0179] The present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, it executes the methods in Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 and Figure 7 .

[0180] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0181] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.

[0182] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0183] In addition, in each embodiment of the present application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0184] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, read-only memory), random access memories (RAM, random access memory), magnetic disks, or optical discs that can store program codes.

Claims

1. A method for connecting and merging regions, characterized in that: include: Acquire a target image, and convert the target image into a binary image; Initialize a region label matrix, initialize a stack, initialize a region boundary pixel set and record the boundary pixels of each region in the binary image; generating a merge distance threshold according to the target image; The step of generating a merge distance threshold according to the target image includes: obtaining the in-screen circuit area distribution information of the target display screen, the target image is a display screen captured image including an internal circuit area, and a circuit with reflective capability is provided on the target display screen; determining at least one circuit area range on the target image according to the in-screen circuit area distribution information; calculating a plurality of merge distance thresholds according to the reflectivity of each circuit area range, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of each circuit area range of the target image; Scanning the binary image pixel by pixel to perform a depth-first search, recursively accessing neighboring pixels of the current pixel, adding pixels that meet the conditions to a stack and marking them as members of the current region, and updating the region label matrix to determine the current region as a target region; During the depth-first search, the pixel values ​​of the neighboring pixels of the current pixel are detected at the same time. If there are background pixels in the neighboring pixels, the current pixel is determined as a boundary pixel and added to the boundary set of the current area; For each target region, recursively traverse the region boundary pixel pairs between every two target regions; Calculate the shortest distance of all region boundary pixel pairs and save the result, and analyze the shortest distance of all region boundary pixel pairs and the merge distance threshold; Merge the target areas that meet the merging conditions according to the analysis results; Updating the region label matrix, uniformly updating the pixel labels of the two original target regions to new region labels, and recalculating the new boundary of the merged region; Output the merged region image and region label matrix.

2. The method according to claim 1, characterized in that After the step of acquiring the target image and converting the target image into a binary image, and before the step of scanning the binary image pixel by pixel to perform a depth-first search, recursively accessing the neighboring pixels of the current pixel, adding the pixels that meet the conditions to the stack and marking them as members of the current region, and updating the region label matrix, and determining the current region that has completed the operation as a target region, the method further includes: Detecting isolated noise points and pseudo target areas in the binary image; The isolated noise points and the pseudo target areas are filtered out.

3. The method according to claim 1, characterized in that After the step of recursively traversing the region boundary pixel pairs between every two target regions for each target region, and before the step of calculating the shortest distances of all region boundary pixel pairs and saving the results, and analyzing the shortest distances of all region boundary pixel pairs and the combined distance threshold, the method further includes: The number of marked target areas and the number of boundary pixels are estimated to generate the calculation data volume; Set the calculation data volume threshold; When the amount of calculated data exceeds the threshold value of the amount of calculated data, a quadtree, KD tree or R-tree data structure is used to accelerate the shortest distance query calculation for region boundary pixels, or an image parallel computing framework is used to distribute the shortest distance calculation task for region boundary pixel pairs to multiple processing units for concurrent processing.

4. The method according to claim 1, characterized in that: After the step of merging the target areas meeting the merging condition according to the analysis result, and before the step of updating the area label matrix, uniformly updating the pixel labels of the original two target areas to new area labels, and recalculating the new boundary of the merged area, the method further includes: Determine a shrinking area and an expanding area of ​​the image after the target area is merged according to the circuit area distribution information, wherein the shrinking area is an area whose area is smaller than a preset threshold, and the expanding area is an area whose area is larger than the preset threshold; Adjusting the merging distance threshold of the expanded area, analyzing the shortest distance between the area boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and performing area merging processing again; Conduct foreign body analysis based on the area information and roundness information of the shrinking area; When the analysis indicates the presence of foreign matter, the watershed algorithm is applied to the shrunken area; When the analysis indicates that there is no foreign matter, the merge distance threshold of the shrunk area is adjusted, and the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunk area and the adjacent target area is analyzed, and the area merging process is performed again.

5. The method according to claim 4, characterized in that When the analysis indicates that there is no foreign matter, the step of adjusting the merge distance threshold of the shrinking area, analyzing the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrinking area and the adjacent target area, and performing area merging processing again includes: When the analysis indicates that no foreign matter exists, a linear circuit area in the circuit area on the target image is determined, wherein the linear circuit area is a circuit range composed of dense metal lines, and a number of non-circuit gap areas exist between the metal lines; When the linear circuit area and the shrinkage area overlap, obtaining the area ratio of the non-circuit gap area from the overlapping linear circuit area; Calculating a merge distance threshold of the shrinking area according to the reflectivity of the linear circuit area, the area proportion, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image; Determine the shortest distance between the target area corresponding to the shrunk area and the area boundary pixel pairs adjacent to the target area, and analyze the shortest distance using the merged distance threshold of the shrunk area; Based on the analysis results, target areas that meet the merging conditions are merged.

6. The method according to claim 4, characterized in that The step of adjusting the merging distance threshold of the expanded area, analyzing the shortest distance between the area boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and performing area merging processing again comprises: Determine the circuit area to be adjusted corresponding to the expanded area on the target image; Determining a circuit region adjacent to the circuit region to be adjusted, and determining a reflectivity of the adjacent circuit region; Scaling and moving the circuit area to be adjusted according to the reflectivity of the adjacent circuit area and the reflectivity of the circuit area to be adjusted to generate a target circuit area; Calculate a merge distance threshold of the expanded area according to the reflectivity of the circuit area to be adjusted, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the target circuit area; Determine the shortest distance between the target area corresponding to the expanded area and the area boundary pixel pairs adjacent to the target area, and use the merged distance threshold of the expanded area to analyze the shortest distance; Based on the analysis results, target areas that meet the merging conditions are merged.

7. A device for connecting and merging regions, characterized in that: include: An acquisition unit, used for acquiring a target image and converting the target image into a binary image; An initialization unit, used to initialize a region label matrix, initialize a stack, initialize a region boundary pixel set and record the boundary pixels of each region in the binary image; A first generating unit, configured to generate a merge distance threshold according to the target image; The target image is a display screen acquisition image including an internal circuit area; The first generating unit includes: obtaining the circuit area distribution information of the target display screen, where the target display screen is provided with a circuit with reflection capability; determining at least one circuit area range on the target image according to the circuit area distribution information of the target screen; calculating a plurality of merge distance thresholds according to the reflectivity of each circuit area range, the grayscale mean of the non-circuit area of ​​the target image and the grayscale mean of each circuit area range of the target image; A scanning unit, used for scanning the binary image pixel by pixel to perform a depth-first search, recursively accessing neighboring pixels of a current pixel, adding pixels that meet the conditions to a stack and marking them as members of a current region, and updating the region label matrix to determine the current region as a target region; A first determination unit is used to simultaneously detect pixel values ​​of neighboring pixels of the current pixel during the depth-first search process. If there are background pixels in the neighboring pixels, the current pixel is determined as a boundary pixel and added to a boundary set of the current region; A traversal unit, used for recursively traversing a region boundary pixel pair between every two target regions for each target region; A calculation unit, used for calculating the shortest distance of all region boundary pixel pairs and saving the result, and analyzing the shortest distance of all region boundary pixel pairs and the combined distance threshold; A merging unit, used to merge target areas meeting the merging conditions according to the analysis results; An updating unit, used to update the region label matrix, update the original pixel labels of the two target regions to new region labels, and recalculate the new boundary of the merged region; The output unit is used to output the merged region image and region label matrix.

8. The device according to claim 7, characterized in that The device also includes: A detection unit, used to detect isolated noise points and pseudo target areas in the binary image; A filtering unit is used to filter out the isolated noise points and the pseudo target area.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed on a computer, the method according to any one of claims 1 to 6 is performed.

Citation Information

Patent Citations

  • Line drawing interruption identification method and device of electronic whiteboard, electronic whiteboard and medium

    CN116682127A