Region communication and combination method and device and storage medium

By adopting the depth-first search and merging distance threshold analysis methods in high-resolution image processing, the problems of high computational complexity and inflexible merging conditions in the prior art are solved, and dynamic merging and efficient image processing are realized.

CN119741331AActive Publication Date: 2025-04-01SHENZHEN SEICHITECH TECHN CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510245195.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-04
Publication Date
2025-04-01
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 taking the target image and converting it into a binarized image, initializing the area tag matrix and stack, generating a merged distance threshold, pixel-by-pixel scan for depth-first search, recursively accessing neighborhood pixels, marking area members and updating the tag matrix. At the same time, the boundary pixels are detected, the shortest distance of the area boundary pixel pair is calculated, the merge conditions are analyzed and the area merge is performed.

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 CN119741331A_ABST
    Figure CN119741331A_ABST
Patent Text Reader

Abstract

The invention discloses a region connection and combination method and device and a storage medium. The method and device are used for improving the capabilities of dynamic combination and flexible combination condition adjustment of traditional connected domain analysis. Converting the target image into a binary image; initializing a region label matrix and a stack, initializing a region boundary pixel set and recording boundary pixels; generating a merging distance threshold according to the target image; performing depth-first search, recursively accessing neighborhood pixels of the current pixel, adding the pixels meeting conditions into a stack, and updating a region label matrix; if the background pixel exists in the neighborhood pixels, determining the current pixel as a boundary pixel; calculating the shortest distance of the boundary pixel pairs of all the regions, storing the result, and analyzing the shortest distance of the boundary pixel pairs of all the regions and the combined distance threshold; according to the analysis result, combining the target areas meeting the combination condition; updating the region label matrix, and recalculating a new boundary of the merged region; and outputting 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 more particularly to a method, device and storage medium for area connectivity merging. Background Art

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

[0003] Existing regional connectivity analysis methods for display screens usually use run-length coding scanning or connectivity algorithms based on neighborhood analysis. Although these methods can effectively detect connected areas, the independent operations of connectivity judgment and regional merging in high-resolution images significantly increase the computational complexity. This is because with the development of display screens, display screens gradually have more functionality, and the increase in functionality will increase the number of layers of display screens, or improve each layer. This makes the structure of LCD screens complex. Existing LCD screens may include multiple components such as CG cover plates, OCA glue, upper polarizers, TFT, CF, lower polarizers, and backlights. In addition, during the production and manufacturing process of display screens, foreign matter may be generated in many production links due to the complex structure. These foreign matter may be generated between any two adjacent layers. These all require high-resolution cameras to cooperate with lenses to capture images of the display screen, and the captured high-resolution images increase the difficulty of regional connectivity analysis.

[0004] The current regional connectivity calculation and regional 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 regional connectivity merging, which are used to improve the ability of dynamic merging and flexible adjustment of merging conditions in traditional connectivity domain analysis.

[0006] In a first aspect, an embodiment of the present application provides a method for connecting and merging regions, comprising: acquiring a target image, converting the target image into a binary image; initializing a region label matrix, initializing a stack, initializing a region boundary pixel set and recording the boundary pixels of each region in the binary image; generating a merging distance threshold according to the target image; scanning the binary image pixel by pixel to perform a depth-first search, recursively accessing the neighboring pixels of the current pixel, adding pixels that meet the conditions to the stack and marking them as members of the current region, and updating the region label matrix, determining the current region that completes the operation as a target region; while performing the depth-first search, simultaneously detecting the current pixel The pixel value of the neighborhood pixel, if there is a background pixel in the neighborhood pixel, the current pixel is determined as a boundary pixel and added to the boundary set of the current area; for each target area, recursively traverse the region boundary pixel pairs between every two target areas; calculate the shortest distance of all region boundary pixel pairs and save the result, 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; update the region label matrix, update the pixel labels of the original two target areas to the new region label, and recalculate the new boundary of the merged area; output the merged region image and region label matrix.

[0007] Optionally, in some embodiments of the present application, after acquiring the target image and converting the target image into a binary image, the binary image is scanned pixel by pixel to perform a depth-first search, the neighborhood 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. Before the current region that completes the operation is determined as a target region, the method also includes: detecting isolated noise points and pseudo-target regions in the binary image; and filtering out the isolated noise points and pseudo-target regions.

[0008] Optionally, in some embodiments of the present application, for each target area, after recursively traversing the area boundary pixel pairs between every two target areas, calculating the shortest distance of all area boundary pixel pairs and saving the result, before analyzing the shortest distance of all area boundary pixel pairs and the merged distance threshold, the method also includes: using the number of marked target areas and the number of boundary pixels to estimate and generate a calculation data volume; setting a calculation data volume threshold; when the calculation data volume exceeds the calculation data volume threshold, using a quadtree, KD tree or R tree data structure to accelerate the shortest distance query calculation of area boundary pixels, or using an image parallel computing framework to distribute the shortest distance calculation task of area boundary pixel pairs to multiple processing units for concurrent processing.

[0009] Optionally, in some embodiments of the present application, the target image is a captured image of a display screen including an internal circuit area; generating a merge distance threshold based on the target image includes: obtaining in-screen circuit area distribution information of the target display screen, the target display screen being provided with a circuit with reflective capability; determining at least one circuit area range on the target image based on the in-screen circuit area distribution information; and calculating a number of merge distance thresholds based on 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.

[0010] Optionally, in some embodiments of the present application, after merging the target areas that meet the merging conditions according to the analysis results, updating the area label matrix, uniformly updating the pixel labels of the original two target areas to new area labels, and before recalculating the new boundary of the merged area, the method also includes: determining the shrunk area and the expanded area of ​​the image after the target areas are merged according to the circuit area distribution information, the shrunk area is an area with an area area less than a preset threshold, and the expanded area is an area with an area area greater than a 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; performing foreign matter analysis according to the area information and roundness information of the shrunk area; when the analysis indicates the presence of foreign matter, performing watershed algorithm processing on the shrunk area; when the analysis indicates the absence of foreign matter, adjusting the merging distance threshold of the shrunk area, analyzing the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunk area and the adjacent target area, and performing area merging processing again.

[0011] Optionally, in some embodiments of the present application, when the analysis indicates that there is no foreign matter, the merging 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 step of performing area merging processing again includes: when the analysis indicates that there is no foreign matter, determining the linear circuit area in the circuit area on 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; when the linear circuit area and the shrunk area overlap, obtaining the area ratio of the non-circuit gap area from the overlapping linear circuit area; calculating the merging distance threshold of the shrunk area according to the reflectivity, area ratio of the linear circuit area, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image; determining the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunk area and the adjacent target area, and using the merging distance threshold of the shrunk area to analyze the shortest distance; merging the target areas that meet the merging conditions according to the analysis results.

[0012] Optionally, in some embodiments of the present application, a merging distance threshold of the expanded area is adjusted, and the shortest distance between the area boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area is analyzed, and the step of performing area merging processing again includes: determining the circuit area to be adjusted corresponding to the expanded area on the target image; determining the adjacent circuit area of ​​the circuit area to be adjusted, and determining the reflectivity of the adjacent circuit area; 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; calculating the merging 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; determining the shortest distance between the area boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and using the merging distance threshold of the expanded area to analyze the shortest distance; merging the target areas that meet the merging conditions according to the analysis results.

[0013] In a second aspect, an embodiment of the present application provides a device for connecting and merging regions, comprising: an acquisition unit, used to acquire a target image and convert 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 generation unit, used to generate a merging distance threshold according to the target image; a scanning unit, used to scan the binary image pixel by pixel to perform a depth-first search, recursively access the neighboring pixels of the current pixel, add the pixels that meet the conditions to the stack and mark them as members of the current region, and update the region label matrix, and determine the current region that completes the operation as a target region; a first determination unit, used to simultaneously detect the current region during the depth-first search. The pixel values ​​of the neighboring pixels of the pixel are calculated. 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. A traversal unit is used to recursively traverse the region boundary pixel pairs between every two target areas for each target area. A calculation unit is used to calculate the shortest distance of all region boundary pixel pairs and save the results, and analyze the shortest distance of all region boundary pixel pairs and the merging distance threshold. A merging unit is used to merge the target areas that meet the merging conditions according to the analysis results. An updating unit is used to update the region label matrix, uniformly update the pixel labels of the original two target areas to new region labels, and recalculate the new boundary of the merged area. An output unit is used to output the merged region image and region label matrix.

[0014] Optionally, in some embodiments of the present application, after the acquisition unit and before the scanning unit, the device also includes: a detection unit for detecting isolated noise points and pseudo target areas in the binary image; and a filtering unit for filtering out isolated noise points and pseudo target areas.

[0015] Optionally, in some embodiments of the present application, after the traversal unit and before the calculation unit, the device also includes: a second generation unit, used to generate a calculation data volume by using the number of marked target areas and the estimated number of boundary pixels; a setting unit, used to set a calculation data volume threshold; a first processing unit, used to accelerate the shortest distance query calculation of region boundary pixels by using a quadtree, KD tree or R tree data structure when the calculation data volume exceeds the calculation data volume threshold, or to distribute the shortest distance calculation task of 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 captured image of a display screen including an internal circuit area; the first generation unit includes: obtaining in-screen circuit area distribution information of the target display screen, on which a circuit with reflective capability is provided; determining at least one circuit area range on the target image according to the in-screen circuit area distribution information; and calculating a plurality of merged 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.

[0017] Optionally, in some embodiments of the present application, after the merging unit and before the updating unit, the device also includes: a second determination unit, used to determine the shrunk area and the expanded area of ​​the image after the target area is merged according to the circuit area distribution information, the shrunk area is an area with an area less than a preset threshold, and the expanded area is an area with an area greater than the preset threshold; a first adjustment unit, used to adjust the merging distance threshold of the expanded area, analyze the shortest distance between the target area corresponding to the expanded area and the area boundary pixel pairs of the adjacent target area, and perform area merging processing again; an analysis unit, used to perform foreign matter analysis based on the area information and roundness information of the shrunk area; a second processing unit, used to perform watershed algorithm processing on the shrunk area when the analysis indicates the presence of foreign matter; a second adjustment unit, used to adjust the merging distance threshold of the shrunk area when the analysis indicates the absence of foreign matter, analyze the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunk area and the adjacent target area, and perform area merging processing again.

[0018] Optionally, in some embodiments of the present application, the first adjustment unit includes: when the analysis indicates that there is no foreign matter, determining a linear circuit area in the circuit area on the target image, the linear circuit area being a circuit range composed of dense metal lines, and there are a number of non-circuit gap areas between the metal lines; when the linear circuit area and the shrunken area overlap, obtaining the area ratio of the non-circuit gap area from the overlapping linear circuit area; calculating a merging distance threshold of the shrunken area based on the reflectivity, area ratio of the linear circuit area, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image; determining the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunken area and the adjacent target area, and analyzing the shortest distance using the merging distance threshold of the shrunken area; merging the target areas that meet the merging conditions based on the analysis results.

[0019] Optionally, in some embodiments of the present application, the second adjustment unit includes: determining the circuit area to be adjusted corresponding to the expanded area on the target image; determining the adjacent circuit area of ​​the circuit area to be adjusted, and determining the reflectivity of the adjacent circuit area; 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; calculating a merging 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; determining the shortest distance between the region boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and using the merging distance threshold of the expanded area to analyze the shortest distance; and merging the target areas that meet the merging conditions according to the analysis results.

[0020] In a third aspect, an embodiment of the present application provides a device for connecting and merging regions, including: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the first aspect and any optional method of the first aspect.

[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method of the first aspect.

[0022] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: In this application, the target image is first obtained and converted into a binary image. Next, the region label matrix is ​​initialized, a stack is initialized, the region boundary pixel set is initialized and the boundary pixels of each region in the binary image are recorded. A merge distance threshold is generated according to the target image. The binary image is scanned pixel by pixel for depth-first search, 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, and the current region that completes the operation is determined as a target region. During the depth-first search process, 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 region. For each target region, the region boundary pixel pairs between each two target regions are recursively traversed. The shortest distance of all region boundary pixel pairs is calculated and the results are saved, and the shortest distance of all region boundary pixel pairs and the merge distance threshold are analyzed. According to the analysis results, the target regions that meet the merge conditions are merged. The region label matrix is ​​updated, the pixel labels of the original two target regions are uniformly updated to new region labels, and the new boundaries of the merged region are recalculated. Output the merged region image and region label matrix.

[0023] By calculating the region boundary pixel pairs and analyzing them with the merge distance threshold, the regions that can be merged are determined. After the regions are merged, the boundary pixels of the regions before and after the merger are dynamically updated. The depth-first search algorithm is combined with boundary pixel extraction, merge queue and dynamic update strategy to efficiently judge the regional connectivity and merge adjacent regions, thereby improving the dynamic merging and flexible adjustment of merging conditions of traditional connected domain analysis. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0025] Figure 1 A schematic diagram of an embodiment of the method for regional connection and merging of the present application; Figure 2 A schematic diagram of an embodiment of a method for preprocessing a target image of the present application; Figure 3 A schematic diagram of an embodiment of a method for improving the processing efficiency of connected domains in the present application; Figure 4 A schematic diagram of an embodiment of a method for generating a merge distance threshold for the present application; Figure 5 A schematic diagram of an embodiment of a method for detecting and adjusting after connecting domains are merged according to the present application; Figure 6 A schematic diagram of an embodiment of a method for processing a shrinking area in the present application; Figure 7 A schematic diagram of an embodiment of a method for processing an expanded area for the present application; Figure 8 A schematic diagram of an embodiment of a device for connecting and merging regions of the present application; Fig. 9 A schematic diagram of another embodiment of the device for connecting and merging regions of the present application. DETAILED DESCRIPTION

[0026] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may 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 prevent unnecessary details from obstructing the description of the present application.

[0027] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of 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 combinations thereof.

[0028] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

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

[0030] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0031] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some 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 in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0032] In the prior art, the regional connectivity analysis method for display screens usually adopts run-length coding scanning or connectivity algorithms based on neighborhood analysis. Although these methods can effectively detect connected areas, the independent operations of connectivity judgment and regional merging in high-resolution images significantly increase the computational complexity. This is because with the development of display screens, display screens gradually have more functionality, and the increase in functionality will increase the number of layers of display screens, or the improvement of each layer. This makes the structure of LCD screens complex. Existing LCD screens may include multiple components such as CG cover plates, OCA glue, upper polarizers, TFT, CF, lower polarizers, and backlights. In addition, during the production and manufacturing process of display screens, foreign matter may be generated in many production links due to the complex structure. These foreign matter may be generated between any two adjacent layers. These all 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.

[0033] The current regional connectivity calculation and regional 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.

[0034] 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 connectivity domain analysis.

[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0036] The method of the present application can be applied to a server, a device, a terminal or other devices with logic processing capabilities, and the present application does not limit this. For the convenience of description, the following description is made by taking the execution subject as an example of a terminal.

[0037] See also Figure 1 The present application provides an embodiment of a method for regional connectivity merging, including: 101. Obtain a target image, and convert the target image into a binary image.

[0038] In the embodiment of the present application, the target image is mainly an image generated by the display screen during production testing and other links. Before performing the connected domain analysis, the target image needs to be binarized to generate a binary image.

[0039] In the embodiment of the present application, the input image format is first determined to ensure that the processed image is already in a 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).

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

[0041] 103. Generate a merge distance threshold according to the target image.

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

[0043] Specifically, initialize the data structure 1. Region label matrix: Initialize a matrix of the same size as the input image (binarized image) to mark the region label to which each pixel belongs. During initialization, the label value of all pixels is set to 0, indicating that they have not been visited.

[0044] 2. Initialize a stack: a stack data structure used to implement DFS and store the pixel currently being accessed.

[0045] 3. Region boundary pixel set: records the boundary pixels of each region. Boundary pixels refer to foreground pixels adjacent to background pixels.

[0046] 4. Create a merge queue: store the areas to be merged and the shortest distances between the boundary pixels of each area to avoid repeated calculations.

[0047] 5. Merge distance threshold: Set the merge distance threshold for adjacent areas. In the embodiment of the present application, it is necessary to flexibly set it according to the actual detection items and other requirements. The specific setting scheme will be explained in the subsequent embodiments.

[0048] Through the above five steps, the preprocessing phase of connected domain analysis can be completed.

[0049] 104. Scan the binary image pixel by pixel to perform depth-first search, recursively visit 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 completes the operation as a target region.

[0050] In the embodiment of the present application, the terminal starts a depth-first search (DFS), first starting from any unvisited pixel point (generally, it can be selected to start from the upper left corner of the image and traverse the image in row priority or column priority order), and scans the binary image pixel by pixel. For each unvisited pixel in the target area, a depth-first search (DFS) is started.

[0051] In the DFS process, the neighborhood of the current pixel (usually 4 neighborhoods or 8 neighborhoods) is recursively visited. If its neighboring pixel is a pixel in the target area, it is added to the stack and marked as a member of the current area.

[0052] In each DFS recursive process, the region label matrix is ​​updated simultaneously, marking all pixels connected to the current starting pixel with the same region label.

[0053] 105. During the depth-first search process, the pixel values ​​of the neighboring pixels of the current pixel are detected simultaneously. 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.

[0054] In the process of depth-first search, boundary pixel extraction is also required. In the DFS process, the terminal checks the neighboring pixel values ​​of the current pixel at the same time. If there are background pixels in the neighboring pixels (at least one neighboring pixel has a value of 0), the current pixel is regarded as a boundary pixel and added to the boundary set of the area.

[0055] When the depth-first search (DFS) ends, that is, the DFS traversal ends, each pixel in the image is marked with a unique region label, and the boundary pixels of each region are extracted.

[0056] 106. For each target region, recursively traverse the region boundary pixel pairs between every two target regions.

[0057] 107. 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 merged distance threshold.

[0058] After completing the depth-first search, dynamic judgment is required to merge and update adjacent areas.

[0059] First, the shortest distance between the region boundaries is calculated. For each marked target region, the boundary pixels between the current target region and any other target region are recursively traversed, the shortest distance between every pair of region boundary pixels is calculated, and the result is saved.

[0060] The distance calculation can use distance measurement methods such as Euclidean distance or Manhattan distance to measure the relative distance between two areas.

[0061] 108. Based on the analysis results, target areas that meet the merging conditions are merged.

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

[0063] The region merging condition is judged, first according to the preset merging distance threshold, if the shortest boundary distance between two regions is less than the threshold, then the two regions are considered to be adjacent and can be merged.

[0064] Next, the terminal manages all region pairs that meet the conditions by merging queues to avoid repeated calculations and redundant operations.

[0065] After completing the merging condition judgment, the terminal needs to dynamically merge adjacent areas.

[0066] For each pair of regions in the merge queue, the shortest distance between their boundaries is compared with the preset merge distance threshold. If the merge condition is met, the two regions are merged into a new region.

[0067] After merging, the region label matrix is ​​updated, and the pixel labels of the original two regions are uniformly updated to the new region label.

[0068] After merging, the new boundary of the merged area needs to be recalculated. The boundary of the merged area can be dynamically updated by the boundary pixel set of the areas before and after merging.

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

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

[0071] In the embodiment of the present application, the target image is first obtained and converted into a binary image. Next, the region label matrix is ​​initialized, a stack is initialized, the region boundary pixel set is initialized and the boundary pixels of each region in the binary image are recorded. A merge distance threshold is generated according to the target image. The binary image is scanned pixel by pixel for depth-first search, 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, and the current region that completes the operation is determined as a target region. During the depth-first search process, 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 region. For each target region, the region boundary pixel pairs between each two target regions are recursively traversed. The shortest distance of all region boundary pixel pairs is calculated and the results are saved, and the shortest distance of all region boundary pixel pairs and the merge distance threshold are analyzed. According to the analysis results, the target regions that meet the merge conditions are merged. The region label matrix is ​​updated, the pixel labels of the original two target regions are uniformly updated to new region labels, and the new boundaries of the merged region are recalculated. Output the merged region image and region label matrix.

[0072] By calculating the region boundary pixel pairs and analyzing them with the merge distance threshold, the regions that can be merged are determined. After the regions are merged, the boundary pixels of the regions before and after the merger are dynamically updated. The depth-first search algorithm is combined with boundary pixel extraction, merge queue and dynamic update strategy to efficiently judge the regional connectivity and merge adjacent regions, thereby improving the dynamic merging and flexible adjustment of merging conditions of traditional connected domain analysis.

[0073] Secondly, the use of depth-first search algorithm combined with boundary pixel extraction and merging queue and dynamic update strategy can efficiently determine regional connectivity and merge adjacent regions, greatly improving computational efficiency and effectively reducing repeated image traversal and unnecessary computational overhead.

[0074] Furthermore, in the embodiments of the present application, the merging distance threshold can be flexibly set according to actual needs, and adjacent areas can be dynamically judged and merged to adapt to different image analysis tasks.

[0075] See also Figure 2 The present application provides an embodiment of a method for preprocessing a target image, comprising: 201. Detect isolated noise points and pseudo target areas in binary images.

[0076] 202. Filter out isolated noise points and false target areas.

[0077] In an embodiment of the present application, the terminal needs to detect whether there are isolated noise points and false target areas in the binary image. The isolated noise point refers to a single pixel point or a pixel point area whose number does not meet the detection purpose, and the false target area refers to a pixel point area whose shape does not meet the detection item.

[0078] Specifically, for binary image denoising, firstly, the input binary image is denoised to eliminate isolated noise points and small pseudo target areas. Common methods in the embodiments of the present application include median filtering, mean filtering, Gaussian filtering, morphological processing, etc.

[0079] See also Figure 3 The present application provides an embodiment of a method for improving the processing efficiency of a connected domain, comprising: 301. Use the number of marked target areas and the number of boundary pixels to estimate and generate the calculation data volume.

[0080] 302. Set a threshold for the amount of data to be calculated.

[0081] 303. When the amount of calculated data exceeds the threshold of the amount of calculated data, a quadtree, KD tree or R-tree data structure is used to accelerate the shortest distance query calculation of region boundary pixels, or an image parallel computing framework is used to distribute the shortest distance calculation task of region boundary pixel pairs to multiple processing units for concurrent processing.

[0082] In an embodiment of the present application, in order to improve the efficiency of the connected domain, the terminal first uses the number of marked target areas and the number of boundary pixels to estimate, generates a calculation data volume, and sets a calculation data volume threshold, and then determines whether the calculation data volume exceeds the calculation data volume threshold. If it exceeds, a quadtree, KD tree, or R tree or other data structure is used to accelerate the shortest distance query calculation of the region boundary pixels, or uses an image parallel computing framework to distribute the shortest distance calculation task of the region boundary pixel pairs to multiple processing units for concurrent processing.

[0083] Specifically, before calculation, the amount of data to be calculated can be estimated by using the number of marked target regions and the number of boundary pixels. By setting a threshold for the amount of data to be calculated, when the estimated amount of data to be calculated exceeds the threshold, data structures such as KD trees can be used to accelerate the shortest distance query calculation for region boundary pixels, or image parallel computing frameworks (such as CUDA or OpenCL) can be used to distribute the shortest distance calculation tasks for boundary pixel pairs to multiple processing units for concurrent processing, thereby achieving the goal.

[0084] See also Figure 4 The present application provides an embodiment of a method for generating a merge distance threshold, comprising: 401. Obtaining information on the distribution of circuit regions within a target display screen, wherein the target display screen is provided with a circuit block having a reflective capability.

[0085] 402. Determine a circuit area on a target image according to the circuit area distribution information within the screen.

[0086] 403. Calculate a merge distance threshold according to the reflectivity of the circuit block, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image.

[0087] In the embodiment of the present application, the connected domain analysis is mainly aimed at the LCD screen with an internal circuit arranged on the pixel layer, and the inspection items that need to be performed are the inspection items of the circuit area and the display area.

[0088] With the continuous update and improvement of LCD screens, the functionality of LCD screens is constantly being 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 impact of the circuit module on the detection of screen defects (external light source detection) and screen defects (pixel layer light source detection) of the LCD screen, thin circuit modules are usually prepared as much as possible to reduce the reflection of the light source, thereby reducing the impact on the detection image. However, even if thin circuits have been used as much as possible and then refined to a certain extent (area refinement of circuit structure), 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 reflection of the light source, because the main material of the internal circuit of the existing platform is metal, and some metals have a certain reflective ability.

[0089] In order to reduce the impact, it is usually necessary to accurately locate the circuit area on the LCD screen image (target image), and then adjust the grayscale of the entire image based on the pixel information of the circuit area on the LCD screen image to reduce the impact of the circuit area on other LCD screen detections.

[0090] 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.

[0091] 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.

[0092] 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.

[0093] 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.

[0094] 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.

[0095]

[0096] 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, The unit length between two adjacent pixels in the LCD screen containing the internal circuit is calculated by the above method. When the reflectivity is greater, the difference between the circuit area and the non-circuit area of ​​the entire image is greater, and a large merging distance threshold is not required to perform connected domain analysis. On the contrary, a slightly larger merging distance threshold is required, especially for circuit areas with gaps in non-circuit areas. This method can better detect such circuit areas and improve the effect of connected domain analysis.

[0097] See also Figure 5 The present application provides an embodiment of a method for detecting and adjusting connected domains after merging, including: 501. Determine a contraction region and an expansion region of the image after the target region is merged, wherein the contraction region is a region whose area is smaller than a preset threshold, and the expansion region is a region whose area is larger than the preset threshold.

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

[0099] 503. Perform foreign matter analysis based on the area information and roundness information of the shrinking area.

[0100] 504. When the analysis indicates the presence of foreign matter, the watershed algorithm is applied to the shrunken area.

[0101] 505. When the analysis indicates that there is no foreign matter, the merge distance threshold of the shrinking area is adjusted, and the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrinking area and the adjacent target area is analyzed, and the area merging process is performed again.

[0102] In an embodiment of the present application, the terminal determines the shrunk area and the expanded area of ​​the image after the target area is merged according to the circuit area distribution information. The shrunk area is a circuit area whose area is smaller than a preset threshold, and the expanded area is a circuit area whose area is larger than the preset threshold. That is, the detected circuit area is analyzed to see whether there is any abnormality, and is usually compared and analyzed with the circuit area distribution information within the screen. If the detected circuit area is smaller than the area in the circuit area distribution information within the screen, it is determined to be a shrunk area. If the detected circuit area is larger than the area in the circuit area distribution information within the screen, it is determined to be an expanded area.

[0103] There are many reasons for the shrinking area. A common reason is the presence of foreign matter, which causes the grayscale mean to decrease, thereby causing the merge distance threshold to decrease. Another common reason is the gap in the non-circuit area in the circuit composed of dense metal lines. When calculating the grayscale mean, such non-circuit area gaps will lower the grayscale mean, thereby causing the merge distance threshold to decrease.

[0104] Therefore, it is necessary to first analyze foreign matter based on the area information and roundness information of the shrunk area. When the area is larger than the circuit area distribution information in the screen, and the roundness information shows that there is an irregular shape that does not belong to the circuit, it can be determined that there is a foreign matter, and the shrunk area needs to be processed by the watershed algorithm to make it meet the preset threshold. If it is not a foreign matter, it is necessary to adjust the merge distance threshold of the shrunk area (increase it), and analyze the shortest distance between the boundary pixel pairs of the shrunk area and other adjacent target areas again, and then perform the area merge process again to solve the problem.

[0105] When determining the circuit area and non-circuit area on the target image based on the circuit area distribution information on the screen, due to the deviation of coarse positioning, a circuit area may include another adjacent circuit area, and the reflection ability of this adjacent circuit area is stronger than the current circuit area, which causes the grayscale mean to increase, thereby increasing the merge distance threshold and resulting in an expanded area.

[0106] At this time, it is necessary to adjust the merging distance threshold of the expanded area, analyze the shortest distance between the target area corresponding to the expanded area and the area boundary pixel pairs adjacent to the target area, and perform area merging again.

[0107] See also Figure 6 The present application provides an embodiment of a method for processing a shrinking area, comprising: 601. When the analysis indicates that there is no foreign matter, determine a linear circuit area in the circuit area on the target image, where the linear circuit area is a circuit range composed of dense metal circuits, and there are a number of non-circuit gap areas between the metal circuits; 602. When the linear circuit area and the shrinkage area overlap, obtain the area ratio of the non-circuit gap area from the overlapping linear circuit area; 603. Calculate a merge distance threshold of the shrinking area according to the reflectivity of the linear circuit area, the area ratio, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image; 604. Determine the shortest distance between the region boundary pixel pairs of the target region corresponding to the shrunk region and the adjacent target region, and analyze the shortest distance using the merged distance threshold of the shrunk region; 605. According to the analysis result, target areas meeting the merging conditions are merged.

[0108] In the embodiment of the present application, when the analysis indicates that there is no foreign matter, the terminal first determines the linear circuit area in the circuit area on the target image, wherein 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. Comparing the positional relationship between the linear circuit area and the shrinking area, when the linear circuit area and the shrinking area overlap, it indicates that the appearance of the shrinking 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 the need to perform pixel data analysis and calculation through equal images.

[0109] When the area ratio of the circuit gap area in a linear circuit area is When the linear circuit area is used, the merge distance threshold of the shrinking area is calculated according to the reflectivity of the linear circuit area, the area ratio, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image. Specifically, the grayscale mean of the circuit area needs to be adjusted, and the formula is as follows:

[0110]

[0111]

[0112] in, is the merge distance threshold after the shrinking area is adjusted. is the grayscale mean of the non-circuit area, is the grayscale mean of the original circuit area, is the grayscale mean of the adjusted circuit area, is the reflectivity of the circuit block, It is the unit length between two adjacent pixels in the LCD screen containing the internal circuit.

[0113] After calculating the new merge distance threshold, return to the steps before merging, determine the shortest distance between the target area corresponding to the shrunk area and the area boundary pixel pairs of the adjacent target area, and use the merge distance threshold of the shrunk area to analyze the shortest distance. According to the analysis results, merge the target areas that meet the merging conditions.

[0114] See also Figure 7 The present application provides an embodiment of a method for processing an expansion area, comprising: 701. Determine a circuit area to be adjusted corresponding to the expanded area on the target image; 702. Determine a circuit region adjacent to the circuit region to be adjusted, and determine a reflectivity of the adjacent circuit region; 703. 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; 704. 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; 705. Determine the shortest distance between the region boundary pixel pairs of the target region corresponding to the expanded region and the adjacent target region, and analyze the shortest distance using the merged distance threshold of the expanded region; 706. Merge the target areas that meet the merging conditions according to the analysis results.

[0115] In the embodiment of the present application, the terminal determines the circuit area to be adjusted corresponding to the expanded area on the target image, determines the adjacent circuit area of ​​the circuit area to be adjusted, and determines the reflectivity of the adjacent circuit area. Compare the reflectivity of the adjacent circuit area with the reflectivity of the circuit area to be adjusted. When the reflectivity of the adjacent circuit area is greater than the reflectivity of the circuit area to be adjusted, the circuit area to be adjusted is reduced, and the part of the adjacent circuit area with a large reflectivity is as far away as possible during the reduction. If there is no adjacent circuit area in a certain direction, or there is no circuit area with a large reflectivity, the position can be adjusted in this direction to reduce the situation where the target circuit area overlaps with the adjacent circuit area with a large reflectivity again.

[0116] After the target circuit area is generated, the terminal calculates the 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. The calculation method is the same as that of Example 4 of the present application, which will not be repeated here. Determine the shortest distance between the target area corresponding to the expanded area and the area boundary pixel pairs of the adjacent target area, and use the merge distance threshold of the expanded area to analyze the shortest distance. Merge the target areas that meet the merging conditions according to the analysis results.

[0117] See also Figure 8 The present application provides an embodiment of a device for connecting and merging regions, including: The acquisition unit 801 is used to acquire a target image and convert the target image into a binary image.

[0118] The detection unit 802 is used to detect isolated noise points and pseudo target areas in the binary image.

[0119] The filtering unit 803 is used to filter out isolated noise points and false target areas.

[0120] 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.

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

[0122] Optionally, the target image is a captured image of a display screen including a circuit area.

[0123] The first generating unit 805 includes: The circuit area distribution information within the target display screen is obtained, and the target display screen is provided with a circuit with reflection capability.

[0124] At least one circuit area range is determined on the target image according to the circuit area distribution information within the screen.

[0125] Several merge distance thresholds are calculated 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.

[0126] The scanning unit 806 is used to scan the binary image pixel by pixel to perform a depth-first search, 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 completes the operation as a target region.

[0127] The first determination unit 807 is used to simultaneously detect the pixel values ​​of the 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 the boundary set of the current area.

[0128] The traversal unit 808 is used to recursively traverse the region boundary pixel pairs between every two target regions for each target region.

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

[0130] The setting unit 810 is used to set a threshold value for calculating the data volume.

[0131] The first processing unit 811 is used to use a quadtree, KD tree or R-tree data structure to accelerate the shortest distance query calculation of region boundary pixels when the amount of calculated data exceeds a calculation data amount threshold, or to use an image parallel computing framework to distribute the shortest distance calculation task of region boundary pixel pairs to multiple processing units for concurrent processing.

[0132] The calculation unit 812 is used 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 combined distance threshold.

[0133] The merging unit 813 is used to merge the target areas meeting the merging conditions according to the analysis result.

[0134] The second determination unit 814 is used to determine the shrinking area and the expanding area of ​​the image after the target area is merged according to the circuit area distribution information, the shrinking area is the area whose area is smaller than the preset threshold, and the expanding area is the area whose area is larger than the preset threshold.

[0135] The first adjustment unit 815 is used to adjust the merging distance threshold of the expanded area, analyze the shortest distance between the area boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and perform area merging processing again.

[0136] Optionally, in some embodiments of the present application, the first adjustment unit includes: when the analysis indicates that there is no foreign matter, determining a linear circuit area in the circuit area on the target image, the linear circuit area being a circuit range composed of dense metal lines, and there are a number of non-circuit gap areas between the metal lines; when the linear circuit area and the shrunken area overlap, obtaining the area ratio of the non-circuit gap area from the overlapping linear circuit area; calculating a merging distance threshold of the shrunken area based on the reflectivity, area ratio of the linear circuit area, the grayscale mean of the non-circuit area of ​​the target image, and the grayscale mean of the circuit area of ​​the target image; determining the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunken area and the adjacent target area, and analyzing the shortest distance using the merging distance threshold of the shrunken area; merging the target areas that meet the merging conditions based on the analysis results.

[0137] The analysis unit 816 is used to perform foreign matter analysis based on the area information and roundness information of the shrinking area.

[0138] The second processing unit 817 is used to perform watershed algorithm processing on the shrinking area when the analysis indicates that there is a foreign object.

[0139] The second adjustment unit 818 is used to adjust the merge distance threshold of the shrunk area when the analysis indicates that there is no foreign matter, and analyze the shortest distance between the area boundary pixel pairs of the target area corresponding to the shrunk area and the adjacent target area, and perform area merging processing again.

[0140] Optionally, in some embodiments of the present application, the second adjustment unit includes: determining the circuit area to be adjusted corresponding to the expanded area on the target image; determining the adjacent circuit area of ​​the circuit area to be adjusted, and determining the reflectivity of the adjacent circuit area; 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; calculating a merging 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; determining the shortest distance between the region boundary pixel pairs of the target area corresponding to the expanded area and the adjacent target area, and using the merging distance threshold of the expanded area to analyze the shortest distance; and merging the target areas that meet the merging conditions according to the analysis results.

[0141] The updating unit 819 is 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.

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

[0143] See also Fig. 9 The present application provides a device for regional connectivity merging, comprising: Processor 901 , memory 902 , input-output unit 903 , and bus 904 .

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

[0145] The memory 902 stores a program, and the processor 901 calls the program to execute the following steps: Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 and Figure 7 The method in .

[0146] The present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, the program performs the following steps: Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 and Figure 7 The method in .

[0147] 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 aforementioned method embodiments and will not be repeated here.

[0148] In the 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 only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

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

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

[0151] If the 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 this understanding, the technical solution of the present application is essentially 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, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

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; 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, and determining the current region that completes the operation 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 completes 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 any one of claims 1 to 3, characterized in that The target image is a display screen captured image including an internal circuit area; The step of generating a merge distance threshold according to the target image comprises: Acquiring information on the distribution of circuit regions within a target display screen, wherein the target display screen is provided with a circuit having a reflective capability; Determine at least one circuit area range on the target image according to the circuit area distribution information within the screen; A plurality of merge distance thresholds are calculated according to the reflectivity of each circuit area range, the grayscale mean value of the non-circuit area of ​​the target image, and the grayscale mean value of each circuit area range of the target image.

5. The method according to claim 4, 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; Perform 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.

6. The method according to claim 5, 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.

7. The method according to claim 5, 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.

8. 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; 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, and determining the current region that completes the operation 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.

9. The device according to claim 8, 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.

10. 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 7 is performed.

Citation Information

Patent Citations

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

    CN116682127A