Double image detection method and device, electronic equipment and storage medium
By partitioning the image and configuring dedicated ghosting feature conditions, the problem of inaccurate defect identification caused by ghosting in automatic optical inspection systems is solved, achieving efficient and accurate ghosting detection and improving the reliability of the detection results.
Patent Information
- Application Number
- CN202511947145.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, image acquisition in automated optical inspection systems is prone to ghosting, which leads to a decrease in the accuracy and stability of defect identification and affects the reliability of inspection results.
By dividing the image to be detected into partitions and configuring exclusive ghosting feature conditions for each partition, and combining the relative azimuth angle of the candidate defect area with the ghosting feature conditions, targeted discrimination is performed to determine the ghosting detection result.
It improves the accuracy and reliability of ghost detection, reduces algorithm overhead, and enhances the accuracy and reliability of defect detection.
Smart Images

Figure CN122089635A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to a method, apparatus, electronic device and storage medium for ghost detection. Background Technology
[0002] With the development of optical inspection technology, Automated Optical Inspection (AOI) systems have been widely used in automated production lines. This system acquires images of the product surface and, relying on specialized image processing algorithms, can automatically identify various surface defects such as scratches, stains, foreign objects, and cracks.
[0003] However, in actual testing, due to the combined influence of various factors, the acquired images often exhibit ghosting. The presence of ghosting severely interferes with the accuracy and stability of defect identification, thereby affecting the reliability of the final detection results. Summary of the Invention
[0004] This disclosure provides a ghosting detection method, apparatus, electronic device, and storage medium to at least solve the above-mentioned technical problems existing in the prior art.
[0005] According to a first aspect of this disclosure, a ghosting detection method is provided, the method comprising: Acquire the image to be detected; Defect regions are extracted from the image to be detected to obtain a set of candidate defect regions; The image to be detected is divided into multiple image partitions; For any two candidate defect regions in the candidate defect region set, determine the relative azimuth angle of the candidate defect region pair. Determine the image partition to which the candidate defect region belongs, and obtain the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs; Based on the ghosting feature conditions and the relative azimuth angle, the ghosting detection result is determined, wherein the ghosting detection result is whether the candidate defect region includes a ghost.
[0006] In one possible implementation, the method further includes: Obtain the pairwise distance threshold; Determine the spatial distance between any two candidate defect regions in the candidate defect region set; Two candidate defect regions whose spatial distance is less than or equal to the pair distance threshold are combined to form the candidate defect region pair.
[0007] In one possible implementation, determining the relative azimuth angle of the candidate defect region pair includes: Based on the centroid coordinates of the two candidate defect regions in the candidate defect region pair, the relative orientation vectors of the two candidate defect regions are determined. The relative orientation vector is transformed to obtain the initial angle value; The relative azimuth angle is obtained by applying interval constraints to the initial angle value.
[0008] In one possible implementation, dividing the image to be detected into multiple image partitions includes: Obtain the partition ratio parameter and the size parameter of the image to be detected; Based on the partition ratio parameter and the size parameter of the image to be detected, the size information of each image partition is obtained; The image to be detected is divided based on the size information of each image partition to obtain multiple image partitions.
[0009] In one possible implementation, determining the image partition to which the candidate defect region belongs includes: Based on the midpoint coordinates of the two candidate defect regions in the candidate defect region pair and the size information of each image partition, the image partition to which the candidate defect region pair belongs is determined.
[0010] In one possible implementation, the ghosting feature conditions include ghosting angle features and angle tolerance; Accordingly, determining the ghost detection result based on the ghost feature conditions and the relative azimuth angle includes: Determine the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the ghost angle feature; If the circumferential angular distance is less than or equal to the angular tolerance, then the ghosting detection result is determined to be that the candidate defect region includes ghosting.
[0011] In one possible implementation, if the ghosting detection result indicates that the candidate defect region contains a ghost, the method further includes: The candidate defect regions are subjected to ghosting removal processing to obtain the target defect region.
[0012] In one possible implementation, the method further includes: Connectivity extraction is performed on the target defect regions to obtain the target connected components corresponding to each target defect region; Extract the geometric feature information of the target connected component, including centroid coordinates, pixel area, minimum bounding rectangle size, and edge contour point array.
[0013] In one possible implementation, the ghosting feature conditions include ghosting angle features, angle tolerance, ghosting geometric features, and geometric tolerance; Accordingly, determining the ghost detection result based on the ghost feature conditions and the relative azimuth angle includes: Determine the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the ghost angle feature; Angle consistency score is determined based on the circumferential angular distance and the angle tolerance; Determine the geometric similarity between two candidate defect regions within the candidate defect region and the geometric matching degree of the ghosting geometric features; Based on the geometric matching degree and the geometric tolerance, a geometric consistency score is determined; The ghosting detection result is determined based on the angle consistency score and the geometric consistency score.
[0014] In one embodiment, the plurality of image partitions includes a left partition, a center partition, and a right partition.
[0015] In one possible implementation, the method further includes: Determine if an inherent angular offset exists; In response to the existence of the inherent angle offset, the ghost angle feature is determined based on the inherent angle offset.
[0016] According to a second aspect of this disclosure, a ghosting detection apparatus is provided, the apparatus comprising: The image acquisition module is used to acquire the image to be detected; The region generation module is used to extract defect regions from the image to be detected and obtain a set of candidate defect regions; A partitioning module is used to divide the image to be detected into multiple image partitions; An angle discrimination module is used to determine the relative azimuth angle of a candidate defect region pair consisting of any two candidate defect regions in the candidate defect region set. The condition acquisition module is used to determine the image partition to which the candidate defect region belongs, and to acquire the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs; The ghosting decision module is used to determine the ghosting detection result based on the ghosting feature conditions and the relative azimuth angle. The ghosting detection result is whether the candidate defect region includes a ghost.
[0017] In one possible embodiment, the device further includes a pairwise screening module for: Obtain the pairwise distance threshold; Determine the spatial distance between any two candidate defect regions in the candidate defect region set; Two candidate defect regions whose spatial distance is less than or equal to the pair distance threshold are combined to form the candidate defect region pair.
[0018] In one possible implementation, the angle determination module is further configured to: Based on the centroid coordinates of the two candidate defect regions in the candidate defect region pair, the relative orientation vectors of the two candidate defect regions are determined. The relative orientation vector is transformed to obtain the initial angle value; The relative azimuth angle is obtained by applying interval constraints to the initial angle value.
[0019] In one possible implementation, the partitioning module is further configured to: Obtain the partition ratio parameter and the size parameter of the image to be detected; Based on the partition ratio parameter and the size parameter of the image to be detected, the size information of each image partition is obtained; The image to be detected is divided based on the size information of each image partition to obtain multiple image partitions.
[0020] In one possible implementation, the condition acquisition module is further configured to: Based on the midpoint coordinates of the two candidate defect regions in the candidate defect region pair and the size information of each image partition, the image partition to which the candidate defect region pair belongs is determined.
[0021] In one possible implementation, the ghosting feature conditions include ghosting angle features and angle tolerance; The ghosting decision module is also used for: Determine the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the ghost angle feature; If the circumferential angular distance is less than or equal to the angular tolerance, then the ghosting detection result is determined to be that the candidate defect region includes ghosting.
[0022] In one embodiment, the device further includes a ghosting elimination module, used to: perform ghosting elimination processing on the candidate defect region pair to obtain the target defect region.
[0023] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods described in this disclosure.
[0024] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing the computer to perform the methods described in this disclosure.
[0025] The ghosting detection method, apparatus, electronic device, and storage medium disclosed herein achieve efficient and accurate ghosting detection by dividing the image to be detected into partitions and configuring specific ghosting feature conditions for different image partitions for targeted discrimination. This scheme has low algorithm overhead and effectively improves the accuracy and reliability of defect detection.
[0026] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0027] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which: In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
[0028] Figure 1 A schematic diagram illustrating the implementation flow of a ghost detection method according to an embodiment of this disclosure is shown; Figure 2 A schematic diagram of an image partitioning according to an embodiment of the present disclosure is shown; Figure 3 A schematic diagram of an image to be detected according to an embodiment of the present disclosure is shown; Figure 4 A schematic diagram showing the detection result of an image to be detected according to an embodiment of the present disclosure is illustrated; Figure 5 A schematic diagram of the composition structure of a ghost detection device according to an embodiment of the present disclosure is shown; Figure 6 A schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0029] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.
[0030] In the practical application of AOI systems, due to the combined influence of various factors such as the inherent characteristics of the optical imaging system, the coaxial or ring light source configuration, the light reflection effect inside the lens, the multi-layer structure of the glass substrate, and the thickness of the cover glass itself, the acquired inspection images often exhibit ghosting. Ghosting refers to the phenomenon where the same physical defect, under the influence of light reflection, semi-transparency, or optical distortion, forms multiple adjacent virtual images or repeated candidate regions in the image, with specific spatial positions and angular relationships. If ghosting is not effectively suppressed, it will cause a series of serious problems: the algorithm is prone to misjudging ghosting as multiple independent real defects, resulting in a significant increase in over-detection and false alarm rates, causing a large number of good products to be judged as defective products, directly reducing the overall product yield; the same defect being counted repeatedly will seriously affect the accuracy of defect statistics; a large number of ghosting candidate regions entering the re-judgment stage will also significantly increase the cost and production cycle of manual re-inspection, and may even lead to confusion in downstream picking or sorting strategies.
[0031] To address the ghosting problem, there are currently several solutions. Among them, area or confidence-based screening methods based on non-maximum suppression rely on the setting of confidence and cross-union ratio thresholds, making it difficult to effectively identify symmetrical ghosts that are close in distance but do not overlap. Heuristic rule-based methods based on morphology and connected components are highly sensitive to parameters and thresholds, and have poor generalization ability across different production batches and detection equipment. End-to-end deep learning suppression solutions not only require massive amounts of labeled samples to complete model training, but the models are also extremely sensitive to subtle changes in optical configuration, making them prone to performance fluctuations.
[0032] To solve the above-mentioned technical problems, this disclosure proposes the following technical solutions: According to a first aspect of the embodiments of this disclosure, a ghosting detection method is proposed, such as... Figure 1 As shown, the method includes the following steps: Step 101: Obtain the image to be detected.
[0033] The image to be detected is an image containing the object to be detected. The method of acquiring it can be determined according to the actual application scenario. For example, the image of the object to be detected can be acquired by real-time imaging equipment such as industrial cameras, or the historical detection images stored locally can be read directly.
[0034] Step 102: Extract the defect region from the image to be detected to obtain a set of candidate defect regions.
[0035] First, the detection region in the image to be detected needs to be determined. Specifically, if the output of the preceding detection process contains a positive detection region, then that region is directly used as the detection region; if the output of the preceding detection process contains a negative region mask, then the detection region is obtained by subtracting the negative region mask from the entire image to be detected; if there is no preceding detection data to support it, then the detection region is determined by manually selecting the bounding box in advance.
[0036] After the detection area is delineated, suspected defect areas are extracted within the area to form a candidate defect area set. The extraction methods include, but are not limited to, traditional algorithms such as grayscale threshold segmentation and region growing, deep learning algorithms based on image segmentation or target detection models, and multi-method fusion strategies that combine traditional algorithms with deep learning algorithms. This step does not limit the specific method for defect area extraction.
[0037] Step 103: Divide the image to be detected into multiple image partitions.
[0038] First, based on the imaging characteristics of the imaging device acquiring the image to be tested, the basis for determining the image partitioning is established, clarifying the number of image partitions and the boundary thresholds of each partition. Imaging characteristics include parameters such as optical path characteristics, shooting angle, and ghosting imaging patterns. For example, if the ghosting in the image captured by the imaging device exhibits different characteristics at different horizontal positions, the image to be tested is divided into multiple regions along the width direction; if the ghosting exhibits different characteristics at different vertical positions, the image to be tested is divided into multiple regions along the height direction.
[0039] In one embodiment, the camera imaging characteristics show that there is a significant difference between the central region and the two side regions of the image, and the image can be directly divided into three image partitions: left partition, center partition, and right partition.
[0040] Step 104: For any two candidate defect regions in the candidate defect region set, determine the relative azimuth angle of the candidate defect region pair.
[0041] First, all candidate defect regions in the candidate defect region set are traversed pairwise. Based on preset screening criteria, those that meet the requirements are selected to form candidate defect region pairs. The preset screening criteria are based on features such as region spacing and area difference, and are used to eliminate candidate defect region combinations that clearly do not belong to a true defect-ghost pairing relationship. For example, a distance threshold can be used as a screening criterion: if the centroid distance between two candidate defect regions exceeds the threshold, it is determined that they do not have the pairing characteristics of defect-ghost and are directly excluded; if it does not exceed the threshold, it is determined that they have the potential to form a defect-ghost pair and are included in subsequent analysis.
[0042] For the selected candidate defect region pairs, calculate their relative azimuth angle. Specifically, the relative azimuth angle is the angle between the ray pointing from the centroid of one candidate defect region to the centroid of the other candidate defect region and the preset reference direction. This can be calculated using the vector angle formula or the coordinate difference arctangent function.
[0043] Step 105: Determine the image partition to which the candidate defect region belongs, and obtain the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs.
[0044] Since the delineation of image partitions is based on imaging characteristics such as the optical path characteristics of the imaging device, the shooting angle, and the ghosting imaging rules, the ghosting within different image partitions will exhibit different angles, distances, and other characteristics. Therefore, each image partition corresponds to specific ghosting feature conditions. These ghosting feature conditions need to be pre-calibrated based on the imaging characteristics of each image partition. In practice, the image partition to which the candidate defect region belongs is first determined, which can be based on the centroid coordinates, geometric center position, etc., of the candidate defect region pair. Then, the pre-calibrated ghosting feature conditions for that partition are retrieved.
[0045] Step 106: Determine the ghost detection result based on the ghost feature conditions and relative azimuth angle. The ghost detection result is whether the candidate defect area includes a ghost.
[0046] In practice, the relative azimuth angle of the candidate defect region pair is checked for consistency with the ghosting feature condition of its respective partition: if the relative azimuth angle meets the determination requirements of the ghosting feature condition, it is determined that there is ghosting in the candidate defect region pair; if the relative azimuth angle does not meet the determination requirements of the ghosting feature condition, it is determined that there is no ghosting in the candidate defect region pair.
[0047] The solution in this embodiment divides the image into partitions based on the characteristics of the imaging device and configures specific ghosting feature conditions for different partitions to perform targeted discrimination, which can efficiently and accurately detect ghosting. This solution has low algorithm overhead and effectively improves the accuracy and reliability of defect detection.
[0048] In another embodiment of this disclosure, the method further includes: obtaining a pairwise distance threshold; determining the spatial distance between any two candidate defect regions in the candidate defect region set; and forming a candidate defect region pair by combining two candidate defect regions whose spatial distance is less than or equal to the pairwise distance threshold.
[0049] Among them, the pair distance threshold is the maximum spatial distance that may constitute a defect-ghost pair. Its value must be greater than 0, and is preferably 8–80 pixels. In specific execution, the candidate defect areas are concentrated to meet the following requirements. For any two candidate defect regions, calculate the spatial distance between them. This spatial distance can be characterized by the Euclidean distance, Manhattan distance, or Chebyshev distance between the centroids or geometric centers of the two candidate defect regions. If the spatial distance is less than or equal to the maximum pairwise distance threshold, the calculation is performed. If the two candidate defect regions are found to be true, then they are identified as a pair of candidate defect regions to be determined; otherwise, the combination is excluded and not included in the subsequent ghosting determination process.
[0050] For example, suppose the candidate defect region set contains 3 candidate defect regions, numbered sequentially as follows: i =1,2,3, then select the numbers that satisfy The combinations are (1,2), (1,3), and (2,3), which are the three pairs. The squared Euclidean distance between the centroids of the two regions is calculated using the following formula (1): (1) in, Let x be the x-coordinate of the centroid of the j-th candidate defect region. Let be the x-coordinate of the centroid of the i-th candidate defect region. Let be the ordinate of the centroid of the j-th candidate defect region. Let be the ordinate of the centroid of the i-th candidate defect region; It is the square of the Euclidean distance between the centroids of the i-th and j-th candidate defect regions.
[0051] like If the region pair is found to be a candidate defect region pair, then the region pair is determined to be a candidate defect region pair to be determined; otherwise, the region pair is determined to be a defect-ghosting pair and is directly eliminated.
[0052] This embodiment filters candidate defect region pairs by setting a pairwise distance threshold, which can directly eliminate region combinations that are too far apart in space and obviously do not have defect-ghosting pairing features, greatly reducing the amount of computation for subsequent ghosting determination. While reducing the overall algorithm overhead, it improves the efficiency and accuracy of ghosting detection.
[0053] In one implementation, if the density of candidate defect regions is high, spatial grid partitioning, hash storage, or kd-tree nearest neighbor retrieval can be used to accelerate pairwise selection. Specifically, the image is first spatially gridded, or the coordinate information of candidate defect regions is hashed and stored, or a kd-tree spatial index structure is constructed. Then, based on the above spatial indexing method, only other candidate defect regions that are in the same grid, adjacent grid, or nearest neighbor range as the target candidate defect region are retrieved and treated as potential pairing objects. Finally, subsequent operations such as relative azimuth angle calculation and angle consistency determination are performed only on the selected potential pairing objects, thereby significantly reducing redundant calculations generated by global pairwise pairing and significantly improving the selection efficiency of candidate defect region pairs while ensuring pairing accuracy.
[0054] In another embodiment of this disclosure, determining the relative azimuth angle of the candidate defect region pair includes: determining the relative azimuth vector of the two candidate defect regions based on the centroid coordinates of the two candidate defect regions in the candidate defect region pair; transforming the relative azimuth vector to obtain an initial angle value; and applying interval constraints to the initial angle value to obtain the relative azimuth angle.
[0055] First, based on the centroid coordinates of two candidate defect regions aligned with the candidate defect region, their relative orientation vector is calculated. The abscissa of this vector represents the difference in the abscissas of the two region centroids, and the ordinate represents the difference in the ordinates of the two region centroids. For example, the difference in the abscissas of the vector is... The difference in the vertical coordinates is ,in( , ) are the centroid coordinates of the i-th region, ( , ) is the centroid coordinate of the j-th region.
[0056] Secondly, the obtained relative orientation vector is transformed by calculating the corresponding radian value of the vector using the arctangent function, and then converting the radian value into an angle value to obtain the initial angle value corresponding to the relative orientation vector. Specifically, this can be achieved using the following formula (2): (2) in, The original relative azimuth angles between the i-th and j-th candidate defect regions are given in degrees. This is the arctangent function calculated based on the difference between the ordinate and the abscissa, and its output is in radians.
[0057] Finally, the initial angle value is constrained by an interval. Since the initial angle value calculated by the arctangent function ranges from -180° to 180°, in order to ensure consistency with the subsequent comparison with the ghosting feature conditions, the initial angle value needs to be uniformly reduced to the interval of 0° to 360°. Specifically, if the initial angle value is less than 0°, then 360° is added to it. The angle obtained after the interval constraint is the relative azimuth angle of the candidate defect region pair.
[0058] The solution in this embodiment determines the relative azimuth vector, transforms the initial angle value, and calculates the relative azimuth angle of the candidate defect region pair using interval constraints. The accuracy of the angle calculation is ensured by using centroid coordinates. At the same time, the initial angle value is uniformly reduced to a fixed range through interval constraints, which effectively avoids ambiguity of the angle value and improves the consistency and reliability of subsequent comparison with the partition ghosting feature conditions, thereby ensuring the accuracy of the ghosting detection results.
[0059] In another embodiment of this disclosure, dividing the image to be detected into multiple image partitions includes: obtaining partition ratio parameters and size parameters of the image to be detected; obtaining size information of each image partition based on the partition ratio parameters and size parameters of the image to be detected; and dividing the image to be detected into multiple image partitions based on the size information of each image partition.
[0060] The partition ratio parameter is a control parameter used to define the range of each image partition. It can be specifically expressed as the proportion of each partition's width to the total image width, or the absolute width value of each partition. This parameter needs to be determined in advance based on the optical path characteristics of the imaging device, the shooting angle, and the ghosting imaging rules. In practice, firstly, the partition ratio parameter and the size parameters representing the size of the image to be detected are obtained. These size parameters include the image width and the image height. Secondly, the partition ratio parameter and the image size parameters are combined to calculate the size information of each image partition. This size information includes, but is not limited to, width, height, and boundary coordinates. Finally, based on the calculated size information of each image partition, the image to be detected is divided into regions, thus obtaining multiple image partitions with clearly defined boundaries.
[0061] For example, the size parameters of the image to be detected include the image width W and the image height H. The center coordinates of the image are calculated based on these two parameters. ,in , Cy= Set the partition ratio parameter to... ρ This parameter characterizes the proportion of the center band width to the total image width, and its value ranges from (0,1), preferably 0.15-0.35. The actual width of the center band... Obtained by multiplying the image width W by the scaling parameter ρ, and the formula is . Taking the abscissa of the image center as the reference, extend half of the center band width to both the left and right sides respectively, and calculate the left boundary L and the right boundary R of the center band. The corresponding calculation formulas are , . Finally, based on the boundaries L and R as the division basis, the image is divided into three image partitions: the left partition, the center partition, and the right partition as shown in Figure 2 . In the figure, the colored area is the candidate defect area
[0062] In the solution of this embodiment, by combining the calculation of the partition scaling parameter and the image size parameter to determine the boundaries and ranges of each partition, not only the standardized division of the image partition is achieved, but also the parameters can be flexibly adjusted according to the characteristics of the imaging device and the ghost imaging law, adapting to the requirements of different detection scenarios, and improving the pertinence and accuracy of subsequent ghost feature condition matching
[0063] In another feasible embodiment of the present disclosure, determining the image partition to which the candidate defect area pair belongs includes: based on the midpoint coordinates of the two candidate defect areas in the candidate defect area pair and the size information of each image partition, determining the image partition to which the candidate defect area pair belongs
[0064] First, obtain the centroid coordinates of the two areas in the candidate defect area pair. Then, based on these centroid coordinates, calculate the midpoint coordinates of the two candidate defect areas. Specifically, the abscissa of this midpoint coordinate is the average value of the abscissas of the centroids of the two areas, and the ordinate is the average value of the ordinates of the centroids of the two areas. Secondly, retrieve the size information of each pre-divided image partition, and this information can be specifically characterized as the boundary coordinates of each partition, the size parameters of each partition, etc. Finally, compare the midpoint coordinates with the size information of each image partition to determine the specific image partition to which this candidate defect area pair belongs
[0065] Exemplarily, taking the scenario of dividing into three image partitions of left, middle, and right as an example, first calculate the midpoint of the centroids of the two areas in the candidate defect area pair, whose abscissa is the average value of the abscissas of the centroids of the two areas, and the ordinate is the average value of the ordinates of the centroids of the two areas. The formula is . Where ([[]] , ) is the centroid coordinate of the i-th area, and ([[]] , ) is the centroid coordinate of the j-th area. The retrieved size information of each image partition includes the left and right boundaries L and R of the center band. Subsequently, only need to compare the abscissa of the midpoint : If < L, it is determined that this candidate defect area pair belongs to the left partition; if If L > R, then the candidate defect region is determined to belong to the right partition; if L ≤ If the value is less than or equal to R, then the candidate defect region is determined to belong to the central partition.
[0066] This embodiment compares the midpoint coordinates of candidate defect region pairs with the image partition size information to achieve accurate determination of the partition to which the region pair belongs. This provides a clear basis for subsequent matching of the ghosting feature conditions of the corresponding partition, effectively improving the targeting and overall accuracy of ghosting detection.
[0067] In another embodiment of this disclosure, the ghosting feature conditions include ghosting angle features and angle tolerance; accordingly, the ghosting detection result is determined based on the ghosting feature conditions and the relative azimuth angle, including: determining the circumferential angular distance between the relative azimuth angle of the candidate defect region pair and the ghosting angle features; if the circumferential angular distance is less than or equal to the angle tolerance, the ghosting detection result is determined to be that the candidate defect region pair includes ghosting.
[0068] First, for candidate defect region pairs that have completed partitioning, the ghosting angle features of the corresponding image partitions are obtained. These ghosting angle features are pre-calibrated based on the ghosting imaging rules of the corresponding partitions. Taking the left, center, and right image partitions as an example, the preferred ghosting angle features are 135° for the left partition, 90° for the center partition, and 45° for the right partition. Simultaneously, the previously calculated relative azimuth angles of the region pair are retrieved. Second, the circumferential angular distance between these two angles is calculated. The calculation of the circumferential angular distance must follow the characteristics of circumferential quantities, taking the smaller value between the absolute value of the direct difference between the two angles and the value obtained by subtracting this absolute value from 360°. This accurately reflects the true difference between the two angles within the circumferential space. Finally, the calculated circumferential angular distance is compared with the angle tolerance corresponding to the image partition. This angle tolerance is a pre-set ghosting judgment threshold used to define the allowable deviation range of angle matching, between 0° and 90°, preferably 10°–25°. Specifically, if the circumferential angular distance is less than or equal to the angular tolerance, the candidate defect region is determined to contain ghosting; otherwise, it is determined that there is no ghosting.
[0069] For example, taking the application scenario of three image partitions (left, center, and right) as an example, firstly, the circumferential angular distance function is used... Calculate the circumferential angular distance. Here, α is the relative azimuth angle of the candidate defect region pair, and θ is the ghost angle feature of the corresponding image partition. Since the angle is a circumferential quantity ranging from 0° to 360°, directly calculating the difference can lead to unreasonable situations. For example, the actual difference between 5° and 355° is 10°, not the directly calculated 350°. This function obtains the true distance between the two angles within the circumferential space by taking the minimum value between the "direct difference" and the "circumferential difference". Ghost angle features are pre-defined for the left, center, and right partitions respectively. , , and the corresponding angle tolerance , , For candidate defect region pairs belonging to different partitions, their relative azimuth angles are calculated respectively. The circumferential angular distance to the corresponding partition ghost angle feature, as long as it satisfies , , Any one of the three conditions is sufficient to determine that the candidate defect region pair is a ghost pair.
[0070] The solution in this embodiment achieves accurate matching of ghost pairs by using partition-specific ghost angle features and tolerance thresholds, which significantly improves the accuracy and reliability of ghost detection.
[0071] In another embodiment of this disclosure, the method further includes: determining whether an inherent angle offset exists; and, in response to the existence of the inherent angle offset, determining the ghost angle feature based on the inherent angle offset.
[0072] The inherent angle offset is the overall angle offset that causes deviations in ghost angle determination. When this inherent angle offset exists, it will cause a discrepancy between the actual acquired defect angle and the preset theoretical ghost angle features. In this case, the original preset theoretical ghost angle features of each partition need to be superimposed with the inherent angle offset to obtain the compensated ghost angle features. Then, based on the target angle, the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the target angle are calculated. By introducing inherent angle offset compensation, the determination error caused by the overall angle offset can be offset, further improving the accuracy and consistency of ghost determination in different application scenarios.
[0073] In another embodiment of this disclosure, if the midpoint coordinates of the candidate defect region pair are detected to be close to the boundary of each image partition, and the angle tolerance threshold of a single partition is directly used for judgment, it is easy to cause false detection or missed detection due to sudden changes in the threshold. Therefore, this embodiment introduces a linear transition tolerance function to smoothly adjust the judgment threshold near the partition boundary. Taking the image partition as an example, which includes three partitions: left, middle and right, the tolerance function is defined as follows (3): (3) That is, when the x-coordinate of the midpoint of the candidate defect region pair Less than or equal to the boundary between the left partition and the center partition L Transition threshold on the left At that time, the angle tolerance of the left partition is directly adopted. ;when At the boundary Ltransition intervals on both sides Within this timeframe, the tolerance threshold is determined from the left partition tolerance. Linear transition to center partition tolerance ;when When within the center zone, the angle tolerance of the center zone is directly used. Similarly, regarding the boundary between the center partition and the right partition... R Symmetrical linear transition rules can be set to achieve smooth connection of tolerance thresholds at partition boundaries, thereby improving the robustness of ghosting detection.
[0074] In another embodiment of this disclosure, if the ghosting detection result indicates that the candidate defect region pair includes ghosting, the method further includes: performing ghosting elimination processing on the candidate defect region pair to obtain the target defect region.
[0075] After determining that a candidate defect region pair contains ghosting, ghosting removal processing is performed on that candidate defect region pair. Specifically, the ghosting regions in the candidate defect region pair can be determined based on the region coordinate relationship. Then, methods such as pixel resetting and redundant region cropping are used to remove the ghosting regions in the candidate defect region pair, ultimately obtaining the target defect region that retains only the true defect features. Figure 3 As shown, it presents the distribution of candidate defect areas before ghosting removal (the area circled in red). Each real defect area in the figure is accompanied by a redundant shadow area formed by ghosting (which is a weak spot vertically lower at the same position). Such areas will interfere with the determination of real defects. Figure 4 The image shows the distribution of the target defect area after ghosting removal. It can be seen that the original shadow-like redundant areas were not circled, and only the feature areas corresponding to the real defects (circled in green) were circled, which effectively improved the accuracy and reliability of defect detection.
[0076] In one embodiment, due to the inherent characteristics of the shooting angle and the imaging optical path, the ghosting region and the real defect region have a fixed longitudinal positional relationship. Therefore, the ghosting region can be determined based on the coordinate positions of two candidate defect regions aligned with the candidate defect region. Specifically, by comparing the ordinates of the centroids of the two candidate defect regions, if the ordinate of the centroid of candidate defect region j... The centroid ordinate of the candidate defect region i is greater than If the vertical position is lower, then the candidate defect region j is identified as a ghost and removed; otherwise, the candidate defect region i is identified as a ghost and removed.
[0077] The solution in this embodiment can effectively remove ghosting interference, improve the characterization accuracy of defect areas, and provide accurate data support for subsequent quantitative analysis and grade determination of defects.
[0078] In another embodiment of this disclosure, the method further includes: extracting connected components from the target defect regions to obtain target connected components corresponding to each target defect region; and extracting geometric feature information of the target connected components, wherein the geometric feature information includes centroid coordinates, pixel area, minimum bounding rectangle size, and edge contour point array.
[0079] First, connected component extraction is performed on the target defect region. This identifies sets of pixels in the image whose pixel values meet preset conditions and are interconnected, thus obtaining the target connected component corresponding to each target defect region. This target connected component can completely represent the spatial distribution range of a single defect. Then, the geometric feature information of the target connected component is extracted. This geometric feature information includes centroid coordinates, pixel area, minimum bounding rectangle size, and edge contour point sequence. This feature information accurately quantifies the target defect from multiple dimensions such as position, size, shape, and boundary.
[0080] The solution in this embodiment transforms the visual features of the target defect into calculable numerical parameters, providing data support for subsequent defect classification, statistical analysis, and other tasks.
[0081] In another embodiment of this disclosure, the ghosting feature conditions include ghosting angle features, angle tolerance, ghosting geometric features, and geometric tolerance. Accordingly, based on the ghosting feature conditions and the relative azimuth, the ghosting detection result is determined, including: determining the circumferential angular distance between the relative azimuth of the candidate defect region pair and the ghosting angle features; determining the angle consistency score based on the circumferential angular distance and the angle tolerance; determining the geometric similarity between the two candidate defect regions within the candidate defect region pair and the geometric matching degree of the ghosting geometric features; determining the geometric consistency score based on the geometric matching degree and the geometric tolerance; and determining the ghosting detection result based on the angle consistency score and the geometric consistency score.
[0082] The specific execution process is as follows: First, determine the circumferential angular distance between the relative azimuth of the candidate defect region pair and the ghost angle feature of its corresponding image partition. Then, based on this circumferential angular distance and a preset angular tolerance, calculate the angular consistency score; a higher score indicates a higher degree of matching between the two angles. Next, calculate the geometric similarity between the two regions within the candidate defect region pair. This geometric similarity can be quantified through geometric features such as the area and shape of the two regions, for example, by using pixel area ratio, area difference ratio, or shape similarity coefficient. Then, compare the geometric similarity with preset ghost geometric features to obtain the geometric matching degree. These ghost geometric features are pre-labeled geometric association features inherent between the ghost region and the real defect region. Finally, combine the preset geometric tolerance to determine the geometric consistency score; a higher score indicates a higher degree of geometric matching between the two regions. Finally, combine the angular consistency score and the geometric consistency score, and determine the ghost detection result of the candidate defect region pair according to a preset weight allocation rule or joint judgment rule.
[0083] The solution in this embodiment, through a dual-feature determination method, takes into account both the angular distribution pattern of the ghosting and the geometric correlation between the ghosting and the real defect, and can effectively eliminate the false detection problem caused by single-feature determination.
[0084] According to a second aspect of the embodiments of this disclosure, a ghosting detection device is provided, such as... Figure 5 As shown, the device includes: Image acquisition module 501 is used to acquire the image to be detected; The region generation module 502 is used to extract defect regions from the image to be detected and obtain a set of candidate defect regions; The partitioning module 503 is used to divide the image to be detected into multiple image partitions; Angle discrimination module 504 is used to determine the relative azimuth angle of a candidate defect region pair consisting of any two candidate defect regions in the candidate defect region set. The condition acquisition module 505 is used to determine the image partition to which the candidate defect region belongs, and to acquire the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs; The ghosting decision module 506 is used to determine the ghosting detection result based on the ghosting feature conditions and the relative azimuth angle, wherein the ghosting detection result is whether the candidate defect region includes a ghost.
[0085] In another embodiment of this disclosure, the apparatus further includes a pairwise screening module for: Obtain the pairwise distance threshold; Determine the spatial distance between any two candidate defect regions in the candidate defect region set; Two candidate defect regions whose spatial distance is less than or equal to the pair distance threshold are combined to form the candidate defect region pair.
[0086] In another embodiment of this disclosure, the angle discrimination module 504 is further configured to: Based on the centroid coordinates of the two candidate defect regions in the candidate defect region pair, the relative orientation vectors of the two candidate defect regions are determined. The relative orientation vector is transformed to obtain the initial angle value; The relative azimuth angle is obtained by applying interval constraints to the initial angle value.
[0087] In another embodiment of this disclosure, the partition construction module 503 is further configured to: Obtain the partition ratio parameter and the size parameter of the image to be detected; Based on the partition ratio parameter and the size parameter of the image to be detected, the size information of each image partition is obtained; The image to be detected is divided based on the size information of each image partition to obtain multiple image partitions.
[0088] In another embodiment of this disclosure, the condition acquisition module 505 is further configured to: Based on the midpoint coordinates of the two candidate defect regions in the candidate defect region pair and the size information of each image partition, the image partition to which the candidate defect region pair belongs is determined.
[0089] In another embodiment of this disclosure, the ghosting feature conditions include ghosting angle features and angle tolerance; the ghosting decision module 506 is further configured to: Determine the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the ghost angle feature; If the circumferential angular distance is less than or equal to the angular tolerance, then the ghosting detection result is determined to be that the candidate defect region includes ghosting.
[0090] In another embodiment of this disclosure, the device further includes a ghosting elimination module for: performing ghosting elimination processing on the candidate defect region pair to obtain the target defect region.
[0091] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.
[0092] Figure 6A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0093] like Figure 6 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.
[0094] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0095] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as ghost detection methods. For example, in some embodiments, the ghost detection method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the ghost detection method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform ghost detection methods by any other suitable means (e.g., by means of firmware).
[0096] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.
[0097] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0098] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0099] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0100] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0101] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0102] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0103] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.
[0104] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A ghost detection method, characterized by, The method includes: Acquire the image to be detected; Defect regions are extracted from the image to be detected to obtain a set of candidate defect regions; The image to be detected is divided into multiple image partitions; For any two candidate defect regions in the candidate defect region set, determine the relative azimuth angle of the candidate defect region pair. Determine the image partition to which the candidate defect region belongs, and obtain the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs; Based on the ghosting feature conditions and the relative azimuth angle, the ghosting detection result is determined, wherein the ghosting detection result is whether the candidate defect region includes a ghost.
2. The method of claim 1, wherein, The method further includes: Obtain the pairwise distance threshold; Determine the spatial distance between any two candidate defect regions in the candidate defect region set; Two candidate defect regions whose spatial distance is less than or equal to the pair distance threshold are combined to form the candidate defect region pair.
3. The method of claim 1, wherein, Determining the relative azimuth angle of the candidate defect region pair includes: Based on the centroid coordinates of the two candidate defect regions in the candidate defect region pair, the relative orientation vectors of the two candidate defect regions are determined. The relative orientation vector is transformed to obtain the initial angle value; The relative azimuth angle is obtained by applying interval constraints to the initial angle value.
4. The method of claim 1, wherein, The process of dividing the image to be detected into multiple image partitions includes: Obtain the partition ratio parameter and the size parameter of the image to be detected; Based on the partition ratio parameter and the size parameter of the image to be detected, the size information of each image partition is obtained; The image to be detected is divided based on the size information of each image partition to obtain multiple image partitions.
5. The method according to claim 4, characterized in that, Determining the image partition to which the candidate defect region belongs includes: Based on the midpoint coordinates of the two candidate defect regions in the candidate defect region pair and the size information of each image partition, the image partition to which the candidate defect region pair belongs is determined.
6. The method according to claim 1, characterized in that, The ghosting feature conditions include ghosting angle features and angle tolerance; Accordingly, determining the ghost detection result based on the ghost feature conditions and the relative azimuth angle includes: Determine the relative azimuth angle of the candidate defect region pair and the circumferential angular distance of the ghost angle feature; If the circumferential angular distance is less than or equal to the angular tolerance, then the ghosting detection result is determined to be that the candidate defect region includes ghosting.
7. The method according to claim 1, characterized in that, If the ghosting detection result indicates that the candidate defect region contains ghosting, the method further includes: The candidate defect regions are subjected to ghosting removal processing to obtain the target defect region.
8. A ghosting detection device, characterized in that, The device includes: The image acquisition module is used to acquire the image to be detected; The region generation module is used to extract defect regions from the image to be detected and obtain a set of candidate defect regions; A partitioning module is used to divide the image to be detected into multiple image partitions; An angle discrimination module is used to determine the relative azimuth angle of a candidate defect region pair consisting of any two candidate defect regions in the candidate defect region set. The condition acquisition module is used to determine the image partition to which the candidate defect region belongs, and to acquire the ghosting feature conditions corresponding to the image partition to which the candidate defect region belongs; The ghosting decision module is used to determine the ghosting detection result based on the ghosting feature conditions and the relative azimuth angle. The ghosting detection result is whether the candidate defect region includes a ghost.
9. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-7.