Multi-defect merging method, device, computer equipment and storage medium
By constructing adjacent distance histograms and morphological expansion methods, the problem of low efficiency in multi-defect merging processing is solved, and more efficient defect merging and detection are achieved.
Patent Information
- Application Number
- CN202211430460.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-11-15
AI Technical Summary
The efficiency of multi-defect merging processing in existing technologies is low and cannot meet the real-time requirements of defect detection in industrial equipment.
By determining the initial adjacent distance data and the preset group distance, the adjacent distance histogram is constructed. After reducing the data volume, the target adjacent distance data is determined, and the candidate defect areas are merged using the morphological expansion of the structure element to achieve multi-defect merging.
It improves the processing efficiency of multi-defect merging, reduces the amount of data processing, and improves the speed and accuracy of detection.
Smart Images

Figure CN115880228B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of defect detection technology, and more specifically, to a method, apparatus, computer device, and storage medium for merging multiple defects. Background Art
[0002] In the field of industrial defect detection, defects can be divided into single defects and multiple defects based on their quantity. A single defect is a defect detected when a single area meets the characteristic specifications, and a multiple defect is a defect that exists within a certain adjacent distance and meets the characteristic specifications. Figure 1 shows a defect detection image, such as Figure 1 As shown, there are multiple defects at A and a single defect at B. The distance between B and A is too large, so the defect at B cannot be merged with the defect at A into multiple defects.
[0003] In industrial defect detection applications, the main method is to traverse each candidate defect area, determine the distance between each candidate defect area and all other candidate defect areas, and merge other candidate defect areas with a distance less than the preset adjacent distance with the candidate defect area to form multiple defects.
[0004] However, the above process of merging multiple defects is an exhaustive traversal, which results in low processing efficiency of merging multiple defects. Summary of the Invention
[0005] In order to solve the problem of low efficiency in the related multi-defect merging processing, the present application provides a multi-defect merging method, apparatus, computer equipment and storage medium.
[0006] The embodiment of the present application is implemented as follows:
[0007] A first aspect of an embodiment of the present application provides a method for merging multiple defects, comprising the following steps:
[0008] Determining initial adjacent distance data, where the initial adjacent distance data is determined from each initial candidate defect area of the image to be detected according to a preset defect rule;
[0009] Determine an adjacent distance histogram based on the initial adjacent distance data and the preset group distance;
[0010] Determine target adjacent distance data based on the adjacent distance histogram;
[0011] Based on the connectivity merging of each target candidate defect region, a multi-defect merging region is determined, wherein the target candidate defect region is determined by the morphological dilation of the initial candidate defect region, and the structure element is constructed according to each target adjacent distance value of the target adjacent distance data.
[0012] A second aspect of an embodiment of the present application provides a multi-defect merging device, comprising an acquisition module, a data update module, and a merging module;
[0013] An acquisition module is used to determine initial adjacent distance data, where the initial adjacent distance data is determined from each initial candidate defect area of the image to be detected according to a preset defect rule;
[0014] A data updating module is used to determine an adjacent distance histogram based on the initial adjacent distance data and the preset group distance; and is also used to determine target adjacent distance data based on the adjacent distance histogram;
[0015] The merging module is used to determine the multi-defect merging region based on the connectivity merging of each target candidate defect region, wherein the target candidate defect region is determined by the morphological expansion of the initial candidate defect region through the structure element, and the structure element is constructed according to each target adjacent distance value of the target adjacent distance data.
[0016] A third aspect of an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the multi-defect merging method of the first aspect of the invention are implemented.
[0017] A fourth aspect of the embodiments of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the steps of the multi-defect merging method of the first aspect of the invention.
[0018] The beneficial effects of the present application are as follows: each initial candidate defect area of the image to be detected realizes the determination of initial adjacent distance data according to preset defect rules; based on the initial adjacent distance data and the preset group distance, the adjacent distance histogram can be determined; based on the adjacent distance histogram, the target adjacent distance data can be determined; further, a structural element is constructed according to each target adjacent distance value of the target adjacent distance data, and the initial candidate defect area can be determined by morphological expansion of the structural element to determine the target candidate defect area; based on the connectivity merging of each target candidate defect area, the determination of the multi-defect merged area can be realized; each initial adjacent distance is analyzed by histogram, the data amount of the updated target adjacent distance is reduced, and the merging of multiple defect areas is realized by the expanded target candidate defect area, thereby improving the processing efficiency of the multi-defect merging. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0020] Figure 1 A defect detection image is shown;
[0021] Figure 2 A schematic diagram of a process for merging multiple defects provided by an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram of a process for determining an adjacent distance histogram according to an embodiment of the present application is shown;
[0023] Figure 4 A schematic diagram of a process for determining target adjacent distance data provided by an embodiment of the present application is shown;
[0024] Figure 5 A schematic diagram of a process for merging multiple defects according to an embodiment of the present application is shown;
[0025] Figure 6 A schematic diagram of a process for determining a multi-defect merging region is shown in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of a process for merging multiple defects according to an embodiment of the present application is shown;
[0027] Figure 8 A schematic diagram of a process for merging multiple defects according to an embodiment of the present application is shown;
[0028] Figure 9 A schematic structural diagram of a multi-defect merging device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0029] In order to make the purpose, implementation mode and advantages of the present application clearer, the exemplary implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0030] It should be noted that the brief descriptions of terms in this application are only for the purpose of facilitating the understanding of the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their ordinary and usual meanings.
[0031] In the specification and claims of this application and the accompanying drawings, the terms "first," "second," "third," etc. are used to distinguish similar or similar objects or entities, and are not necessarily intended to limit a particular order or sequence, unless otherwise noted. It should be understood that the terms used in this manner are interchangeable under appropriate circumstances.
[0032] The terms "comprise," "comprises," and "having," and any variations thereof, are intended to cover but not exclude inclusion; for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0033] In the field of industrial defect detection, the types of defects include but are not limited to point defects and line defects. Different detection requirements require different detection features. Different feature combinations are required to detect defects based on the shape and quantity of the defects. Features include but are not limited to different combinations of area, length, width, contrast, aspect ratio, angle, curvature, roundness, quantity, adjacent distance, and other features.
[0034] like Figure 1 As shown, point defects can be classified as single or multiple defects. The same applies to line defects. Different defects have different requirements for adjacent distances when determining multiple defects. Each defect detection method has independent adjacent distance data. For example, for defect A, it is necessary to determine whether there are three 100-pixel spots within a distance of 50 pixels; for defect B, it is necessary to determine whether there are five 50-pixel scratches within a distance of 80 pixels. The adjacent distances calculated for different defects may contain duplicate or similar adjacent distances.
[0035] In industrial defect detection applications, during the exhaustive traversal process, each adjacent distance is processed separately. If different adjacent distances are traversed in a nested manner, the efficiency of multi-defect processing is low and cannot meet the real-time defect detection requirements of industrial equipment.
[0036] In order to solve the problem of low efficiency in processing multiple defects, the embodiments of the present application provide a method, apparatus, computer equipment and storage medium for merging multiple defects. The initial adjacent distance data of each initial candidate defect area of the image to be detected is determined according to a preset defect rule; based on the initial adjacent distance data and the preset group distance, an adjacent distance histogram can be determined; based on the adjacent distance histogram, the target adjacent distance data can be determined; further, a structural element is constructed according to each target adjacent distance value of the target adjacent distance data, and the initial candidate defect area can be determined by morphological expansion of the structural element to determine the target candidate defect area; based on the connectivity merging of each target candidate defect area, the determination of the multiple defect merging area can be achieved; each initial adjacent distance is analyzed by histogram, the data amount of the updated target adjacent distance is reduced, and the merging of multiple defect areas is achieved through the expanded target candidate defect area, thereby improving the processing efficiency of the multiple defect merging.
[0037] The following describes in detail the multi-defect merging method, apparatus, computer equipment, and storage medium of the embodiments of the present application with reference to the accompanying drawings.
[0038] Figure 2 The flowchart of the method for merging multiple defects provided by the embodiment of the present application is shown as follows: Figure 2 As shown, an embodiment of the present application provides a method for merging multiple defects.
[0039] The multi-defect merging method comprises the following steps:
[0040] S110 , determining initial adjacent distance data, where the initial adjacent distance data is determined from each initial candidate defect area of the image to be detected according to a preset defect rule.
[0041] For the image to be detected, the initial candidate defect area is extracted through a defect extraction algorithm. Due to the differences in factors such as the type, shape, brightness and darkness polarity, image position, and image background of the defects, the corresponding defect extraction algorithms are also diverse. The defect extraction algorithms include but are not limited to: fixed threshold extraction algorithm, dynamic threshold extraction algorithm, edge gradient extraction algorithm, weak contrast defect extraction algorithm, deep learning segmentation algorithm, etc., which are not limited in the embodiments of the present application.
[0042] Quality inspection specifications set specific detection requirements for different defects. Different defects have different requirements for adjacent distances, meaning each defect's detection rule has its own independent adjacent distance data. For example, for a C defect, the detection rule must determine whether there are four 100-pixel spots within an adjacent distance of 80 pixels. For a D defect, the detection rule must determine whether there are three 60-pixel scratches within an adjacent distance of 100 pixels.
[0043] For each defect, the corresponding initial adjacent distance data can be determined by pre-setting defect rules. This initial adjacent distance data may contain duplicate data or data with small differences. Direct traversal processing will result in duplicate processing. Therefore, the initial adjacent distance data can be further reduced by constructing a histogram to reduce the data volume.
[0044] S120: Determine an adjacent distance histogram based on the initial adjacent distance data and the preset group distance.
[0045] A histogram, also known as a quality distribution graph, is a statistical report graph that represents the distribution of data by a series of vertical stripes or line segments of varying heights. The horizontal axis generally represents data grouping, and the vertical axis represents the distribution.
[0046] By determining the adjacent distance histogram, repeated data can be integrated; the preset group distance of the histogram can also be set to cluster the data with smaller differences between different data in the initial adjacent distance data through the preset group distance.
[0047] The preset class interval can be 1 or not. When the preset class interval is 1, no clustering will be performed; when the preset class interval is not 1, different data differences in the initial adjacent distance data that are within the preset class interval can be clustered, which can effectively reduce the number of initial adjacent distance data that need to be calculated. For example, the preset class interval is 3, which is equivalent to clustering different initial adjacent distance data with differences within 3. For example, the initial adjacent distance data includes L-1, L, and L+1. After clustering with the preset class interval, only L exists.
[0048] Figure 3 FIG. 4 shows a flow chart of determining an adjacent distance histogram provided by an embodiment of the present application, such as Figure 3 As shown, step 120 determines the adjacent distance histogram based on the initial adjacent distance data and the preset group distance, including the following steps:
[0049] S201 : Determine the maximum distance interval of the initial adjacent distance data based on the difference between the maximum adjacent distance value and the minimum adjacent distance value in the initial adjacent distance data.
[0050] Determine the maximum adjacent distance value and the minimum adjacent distance value in the initial adjacent distance data, and determine whether the maximum adjacent distance value and the minimum adjacent distance value are equal.
[0051] If the maximum adjacent distance value is equal to the minimum adjacent distance value, there is only one initial adjacent distance in the initial adjacent distance data. At this time, the capacity of the histogram is 1, and only one initial adjacent distance is considered in the subsequent process.
[0052] If the maximum adjacent distance value and the minimum adjacent distance value are not equal, determine the difference between the maximum adjacent distance value and the minimum adjacent distance value in the initial adjacent distance data, that is, the maximum interval of the initial adjacent distance data. The maximum interval (the difference between the maximum adjacent distance value and the minimum adjacent distance value) can be calculated by the following formula:
[0053] D=d max -d min
[0054] Where D is the maximum interval, d max is the maximum adjacent distance value in the initial adjacent distance data, d min is the minimum adjacent distance value in the initial adjacent distance data.
[0055] For example, the maximum adjacent distance value in the initial adjacent distance data is 100, and the minimum adjacent distance value is 38, then the maximum interval (the difference between the maximum adjacent distance value and the minimum adjacent distance value) is 62.
[0056] S202: Determine the capacity of the adjacent distance histogram based on the maximum distance interval and the preset group distance.
[0057] The capacity of the neighbor distance histogram can be calculated as follows:
[0058] H n =ceil(D / L)+1
[0059] Where H n is the capacity of the adjacent distance histogram, L is the preset class interval, and ceil is the smallest integer greater than or equal to the specified expression.
[0060] For example, the preset bin distance is 5, and the capacity of the adjacent distance histogram is ceil(62 / 5)=13.
[0061] S203 : Determine an adjacent distance histogram based on the initial adjacent distance data, the preset group distance, and the capacity of the adjacent distance histogram.
[0062] For each initial adjacent distance value in the initial adjacent distance data, the abscissa of the adjacent distance histogram to which it belongs can be calculated by the following formula:
[0063] X k =ceil((d k -d min ) / L)
[0064] Where, X k is the initial adjacent distance value d in the initial adjacent distance data k The corresponding horizontal axis.
[0065] According to each X k Determine the adjacent distance histogram, that is, when the X k Update the data of the horizontal coordinate corresponding to the adjacent distance histogram. The update of the horizontal coordinate data can be calculated by the following formula:
[0066]
[0067] Where, X is the horizontal coordinate k Corresponding data after data update, X k The data before the corresponding data is updated.
[0068] For example, the first initial adjacent distance value in the initial adjacent distance data is 45, and its corresponding horizontal coordinate is determined to be ceil((45-38) / 5)=2. That is, the initial adjacent distance value 45 belongs to the data corresponding to the second horizontal coordinate in the adjacent distance histogram. At this time, the data is accumulated from 0 to 1 to achieve the update of the data.
[0069] The adjacent distance histogram is statistically calculated through the above process, and the adjacent distance histogram can be expressed in a list form. For example, the adjacent distance histogram H = [1, 2, 2, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1] determined by the above process is arranged from the smallest horizontal coordinate to the largest horizontal coordinate.
[0070] like Figure 2 As shown, the method further includes: S130, determining target adjacent distance data based on the adjacent distance histogram.
[0071] The adjacent distance values restored by the valid elements in the adjacent distance histogram can constitute the target adjacent distance data. The valid elements here refer to the data whose vertical coordinates in the adjacent distance histogram are not 0 and are irrelevant to the size of the data.
[0072] Figure 4 FIG. 4 shows a flow chart of determining target adjacent distance data provided by an embodiment of the present application, such as Figure 4 As shown, step 130 determines the adjacent distance histogram based on the initial adjacent distance data and the preset group distance, including the following steps:
[0073] S301 : Determine a target adjacent distance value based on the index value of each valid element in the adjacent distance histogram, a preset group distance, and a small adjacent distance value in the initial adjacent distance data; wherein a valid element is a non-zero element.
[0074] The index value of each valid element in the adjacent distance histogram can be understood as the index value of each valid element in the corresponding list of the adjacent distance histogram.
[0075] The target adjacent distance value can be calculated by the following formula:
[0076] d′ k =M k ×L+d min
[0077] Where d′ k is the target adjacent distance value, L is the preset group distance, M k is the index value of the valid element in the adjacent distance histogram, and L is the preset group distance.
[0078] It should be noted that the index values of valid elements in the adjacent distance histogram start from 0 according to the general habit of indexing data. For the adjacent distance histogram H = [1, 2, 2, 3, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1] in the above example, the corresponding index values include 0, 1, 2, 3, 5, 9, and 13.
[0079] For example, for the first index value 0, the determined target adjacent distance value is 38=0*5+38, and for the second index value 1, the determined target adjacent distance value is 43=1*5+38.
[0080] S302: Determine target adjacent distance data based on each target adjacent distance value.
[0081] Through step 120 and step 130 , the target adjacent distance data after being reduced in number and clustered is obtained, and the target adjacent distance data is reduced in number compared with the initial adjacent distance data.
[0082] Figure 5 FIG. 1 shows a flow chart of another multi-defect merging method provided by an embodiment of the present application, such as Figure 5 As shown, before step 140, the following steps are included:
[0083] S131. Determine a candidate defect feature value mapping table for each initial candidate defect area based on preset defect rules.
[0084] The features of each initial candidate defect region are unchanged. Therefore, in the subsequent merging process, there is no need to repeatedly calculate the features of each initial candidate defect region.
[0085] In order to clearly grasp the characteristics of each multi-defect merged region after subsequent merging, a candidate defect feature value mapping table of each initial candidate defect region is determined according to preset defect rules.
[0086] Defect features include but are not limited to: area, contrast, length, width, aspect ratio, roundness, curvature, etc. After determining the features of each initial candidate defect region, a candidate defect feature value mapping table may be established based on the order of the initial candidate defect regions.
[0087] For example, there are 10 initial candidate defect regions (A1, A2, ..., A 10 ), the order of each initial candidate defect region is fixed. Taking initial candidate defect region A1 as an example, its feature values, such as area, contrast, and length, are determined. Similarly, for other initial candidate defect regions, a candidate defect feature value mapping table is constructed. When determining feature rules later, only the index value is needed to query the candidate defect feature value mapping table for the corresponding initial candidate defect region, reducing the repeated processing of various regional features.
[0088] like Figure 2 As shown, it also includes: S140, determining a multi-defect merged area based on the connectivity merging of each target candidate defect area, wherein the target candidate defect area is determined by the morphological expansion of the initial candidate defect area through the structure element, and the structure element is constructed according to each target adjacent distance value of the target adjacent distance data.
[0089] Taking into account the local information of the target candidate defect region, the connectivity feature is used to quickly merge multiple defect regions (i.e., determine the multiple defect merging region). Local information refers to whether there are other candidate regions near the target candidate defect region. During connectivity merging, the initial candidate defect region is morphologically expanded by the structural element, causing the adjacent regions to merge. Therefore, connectivity merging can also improve the efficiency of multiple defect merging.
[0090] Figure 6 FIG. 1 shows a flow chart of determining a multi-defect merging region according to an embodiment of the present application. Figure 6 As shown, step 140 determines a multi-defect merging region based on the connectivity merging of each target candidate defect region, and includes the following steps:
[0091] S401: Construct a structure element based on each target adjacent distance value in the target adjacent distance data.
[0092] When using morphological methods for image processing, structural element auxiliary tools are required. The so-called structural element is a set of pixel points with known shape and size.
[0093] A structural element is constructed by using each target adjacent distance value in the target adjacent distance data. The structural element can be a circle, a rectangle, a hexagon, an octagon, etc.
[0094] The position of the initial candidate defect area is arbitrary. When constructing the structural element, the circular structural element is relatively fine, ensuring that the search direction of the determined target candidate defect area is arbitrary; when the rectangular structural element is used to expand the initial candidate defect area, the efficiency can be about 8 times that of the circular structural element.
[0095] When constructing a circular structure element, its radius is half of the target adjacent distance value; when constructing a rectangular structure element, its rectangular side length is the target adjacent distance value.
[0096] S402 : The initial candidate defect regions are expanded by morphological means to determine the target candidate defect regions.
[0097] Each initial candidate defect region is traversed, and the structure element constructed in step 401 of each initial candidate defect region is morphologically expanded to obtain an expanded target candidate defect region.
[0098] In some embodiments, the dilation operation is performed on a binary image, that is, both the initial candidate defect region and the target candidate defect region are binary image regions, which also improves the processing speed.
[0099] The target candidate defect region has a candidate defect feature value mapping table of the initial candidate defect region. The candidate defect feature value mapping table of the corresponding initial candidate defect region is recorded for the expanded target candidate defect region, that is, the index value of the initial candidate defect region in the candidate defect feature value mapping table is recorded.
[0100] S403: Determine a multi-defect merging region based on the connectivity merging of each target candidate defect region.
[0101] Traverse each target candidate defect area and merge them through connectivity. At this time, determine which initial candidate defect areas exist within the target adjacent distance value range, which realizes the merging of initial candidate defect areas within a certain adjacent distance (target adjacent distance data).
[0102] After the traversal is completed, the multiple defect merged regions and the index values of the candidate defect feature value mapping table of the initial candidate defect regions corresponding to the multiple defect merged regions are obtained.
[0103] For example, the obtained multi-defect merged region is recorded as U, and the index value of the candidate defect feature value mapping table of the initial candidate defect region corresponding to one of the multi-defect merged regions is recorded as Uk can be expressed as: [A a-1 , A b-1 , A c-1 ], that is, in the k-th multi-defect merged region, there is an initial candidate defect region A a , A b , A c .
[0104] The multi-defect merged region includes a candidate defect feature value mapping table of the initial candidate defect region corresponding to the target candidate defect region.
[0105] During the merging process, the index value corresponding to the candidate defect feature value mapping table of the initial candidate defect area can be stored through the associative container (Map) of the Standard Template Library (STL), or through other containers such as a single-ended array (Vector), a linked list (List), etc.
[0106] In some embodiments, the target candidate defect region is merged based on binary connectivity. In this case, the initial candidate defect region, the target candidate defect region and the multi-defect merged region are all binary image regions, which further improves the processing speed.
[0107] In an embodiment of the present application, a candidate defect feature value mapping table of the initial candidate defect area is established, so that the multi-defect merging method is applicable to defect determination according to different rules, thereby improving the applicability of the method; at the same time, repeated calculation of features in each area is avoided.
[0108] Figure 7 FIG. 1 shows a flow chart of another multi-defect merging method provided by an embodiment of the present application, such as Figure 7 As shown, after step 140, the following steps are further included:
[0109] S150 , based on a candidate defect feature value mapping table and a preset defect feature threshold in the multi-defect merged region, screening out a target multi-defect region from the multi-defect merged region.
[0110] When the candidate defect feature value mapping table in the multi-defect merged area is stored through a Map, each element in the Map is traversed. Each element represents a merged set, which contains one or more initial candidate defect area indexes. The initial candidate defect area feature value is obtained from the candidate defect feature value mapping table based on the initial candidate defect area index value. It is compared with the preset defect feature threshold to detect the multi-defect areas that meet the conditions, that is, to screen out the target multi-defect areas.
[0111] Figure 8 FIG. 1 shows a flow chart of another multi-defect merging method provided by an embodiment of the present application, such as Figure 8 As shown, the multi-defect merging method includes the following steps:
[0112] S210, adjacent distance histogram.
[0113] S220: Based on the adjacent distance histogram, update the initial adjacent distance data to target adjacent distance data.
[0114] S230 : Determine a candidate defect feature value mapping table for each initial candidate defect region based on a preset defect rule.
[0115] The target adjacent distance data is traversed to determine whether there are any unused target adjacent distance values in the target adjacent distance data.
[0116] If the target adjacent distance value exists, S240 , construct a structure element based on the target adjacent distance value.
[0117] S250 , traversing each initial candidate defect region, and determining a target candidate defect region by morphological dilation of the structure element on each initial candidate defect region.
[0118] S260 , determining a multi-defect merged region based on the binary connectivity merging of each target candidate defect region, which includes a candidate defect feature value mapping table of the initial candidate defect region corresponding to the target candidate defect region.
[0119] S270 , based on the candidate defect feature value mapping table in the multi-defect merged region and a preset defect feature threshold, screen out a target multi-defect region from the multi-defect merged region.
[0120] The implementation principle and technical effect of the above process are similar to Figures 2 to 8 The method embodiments described are similar and will not be described again here.
[0121] An embodiment of the present application provides a multi-defect merging method; initial adjacent distance data is determined for each initial candidate defect area of an image to be detected according to a preset defect rule; an adjacent distance histogram can be determined based on the initial adjacent distance data and a preset group distance; target adjacent distance data can be determined based on the adjacent distance histogram; further, a structural element is constructed based on each target adjacent distance value of the target adjacent distance data, and the initial candidate defect area can be determined by morphological expansion of the structural element to determine the target candidate defect area; based on the connectivity merging of each target candidate defect area, the determination of the multi-defect merging area can be achieved; each initial adjacent distance is analyzed by a histogram, the data amount of the updated target adjacent distance is reduced, and the merging of multiple defect areas is achieved through the expanded target candidate defect area, thereby improving the processing efficiency of the multi-defect merging.
[0122] Figure 9 A schematic diagram of the structure of a multi-defect merging device provided in an embodiment of the present application is shown. Figure 9 As shown, the multi-defect merging apparatus 900 includes an acquisition module 910 , a data updating module 920 and a merging module 930 .
[0123] An acquisition module is used to determine initial adjacent distance data, where the initial adjacent distance data is determined from each initial candidate defect area of the image to be detected according to a preset defect rule;
[0124] A data updating module is used to determine an adjacent distance histogram based on the initial adjacent distance data and the preset group distance; and is also used to determine target adjacent distance data based on the adjacent distance histogram;
[0125] The merging module is used to determine the multi-defect merging region based on the connectivity merging of each target candidate defect region, wherein the target candidate defect region is determined by the morphological expansion of the initial candidate defect region through the structure element, and the structure element is constructed according to each target adjacent distance value of the target adjacent distance data.
[0126] In some embodiments, the data update module includes a histogram construction unit, wherein:
[0127] a histogram construction unit, configured to determine a maximum distance interval of the initial adjacent distance data based on a difference between a maximum adjacent distance value and a minimum adjacent distance value in the initial adjacent distance data;
[0128] The histogram construction unit is further used to determine the capacity of the adjacent distance histogram based on the maximum distance interval and the preset group distance;
[0129] The histogram construction unit is further configured to determine the adjacent distance histogram based on the initial adjacent distance data, the preset group distance and the capacity of the adjacent distance histogram.
[0130] In some embodiments, the data update module further includes a data update unit, wherein:
[0131] A data updating unit, configured to determine a target adjacent distance value based on an index value of each valid element in the adjacent distance histogram, a preset group distance, and a small adjacent distance value in the initial adjacent distance data; wherein a valid element is a non-zero element;
[0132] It is also used to determine target adjacent distance data based on each target adjacent distance value.
[0133] In some embodiments, the initial candidate defect region, the target candidate defect region, and the multi-defect merged region are all binarized image regions.
[0134] In some embodiments, the multi-defect merging apparatus further includes a mapping module, which is configured to determine a candidate defect feature value mapping table for each initial candidate defect region based on a preset defect rule.
[0135] The determination of the multiple defect merging area includes:
[0136] The initial candidate defect region is determined by morphological expansion of the structural element to determine the target candidate defect region, and the target candidate defect region has a candidate defect feature value mapping table of the initial candidate defect region;
[0137] Based on the connectivity merging of each target candidate defect region, a multi-defect merging region is determined, and the multi-defect merging region includes a candidate defect feature value mapping table of the initial candidate defect region corresponding to the target candidate defect region.
[0138] In some embodiments, the multi-defect merging apparatus further includes a screening module configured to screen out a target multi-defect region from the multi-defect merging region based on a candidate defect feature value mapping table and a preset defect feature threshold in the multi-defect merging region.
[0139] An embodiment of the present application provides a multi-defect merging device, including an acquisition module, a data updating module and a merging module; initial adjacent distance data of each initial candidate defect area of the image to be detected is determined according to a preset defect rule; an adjacent distance histogram can be determined based on the initial adjacent distance data and the preset group distance; based on the adjacent distance histogram, target adjacent distance data can be determined; further, a structural element is constructed according to each target adjacent distance value of the target adjacent distance data, and the initial candidate defect area can be determined by morphological expansion of the structural element to determine the target candidate defect area; based on the connectivity merging of each target candidate defect area, the determination of the multi-defect merging area can be achieved; each initial adjacent distance is analyzed by a histogram, the data amount of the updated target adjacent distance is reduced, and the merging of multiple defect areas is achieved through the expanded target candidate defect area, thereby improving the processing efficiency of the multi-defect merging.
[0140] The computer device also provided in the embodiment of the present application includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program. The computer program is used to implement the above-mentioned multi-defect merging method. The implementation principle and technical effects are similar to those of the above-mentioned method embodiment and will not be repeated here.
[0141] An embodiment of the present application also provides a computer storage medium, on which a computer program is stored. The computer program is executed by a processor to execute the above-mentioned multi-defect merging method. Its implementation principle and technical effects are similar to those of the above-mentioned method embodiment and will not be repeated here.
[0142] The following paragraphs will compare and list the Chinese terms involved in this application specification and their corresponding English terms to facilitate reading and understanding.
[0143] For ease of explanation, the above description has been made in conjunction with specific embodiments. However, the above discussion of some embodiments is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Based on the above teachings, various modifications and variations can be obtained. The selection and description of the above embodiments are intended to better explain the principles and practical applications, so that those skilled in the art can better use the embodiments and various different variations of the embodiments suitable for specific use considerations.
Claims
1. A method for merging multiple defects, characterized in that: include: Determining initial adjacent distance data, wherein the initial adjacent distance data is determined from each initial candidate defect area of the image to be detected according to a preset defect rule; Determining an adjacent distance histogram based on the initial adjacent distance data and the preset group distance includes: Determining a maximum distance interval of the initial adjacent distance data based on a difference between a maximum adjacent distance value and a minimum adjacent distance value in the initial adjacent distance data; Determining the capacity of the adjacent distance histogram based on the maximum distance interval and the preset group distance; Determining the adjacent distance histogram based on the initial adjacent distance data, the preset group distance and the capacity of the adjacent distance histogram; Determining target adjacent distance data based on the adjacent distance histogram; Determining a multi-defect merged region based on connectivity merging of each target candidate defect region, wherein the target candidate defect region is determined by morphological dilation of the initial candidate defect region through a structure element constructed based on each target adjacent distance value of the target adjacent distance data; Before determining the multiple defect merged region based on the connectivity merging of the target candidate defect regions, the method further includes: Based on the preset defect rules, a candidate defect feature value mapping table for each of the initial candidate defect regions is determined.
2. The multi-defect merging method according to claim 1, characterized in that: Determining target adjacent distance data based on the adjacent distance histogram includes: Determining a target adjacent distance value based on the index value of each valid element in the adjacent distance histogram, the preset group distance, and the small adjacent distance value in the initial adjacent distance data; wherein the valid element is a non-zero element; Target adjacent distance data are determined based on each of the target adjacent distance values.
3. The multi-defect merging method according to claim 1, characterized in that: The initial candidate defect region, the target candidate defect region and the multi-defect merged region are all binarized image regions.
4. The multi-defect merging method according to claim 1, characterized in that: The determination of the multiple defect merging area includes: The initial candidate defect region is determined by morphological dilation of the structure element to determine the target candidate defect region, wherein the target candidate defect region has a candidate defect feature value mapping table of the initial candidate defect region; Based on the connectivity merging of the target candidate defect regions, the multi-defect merged region is determined, and the multi-defect merged region includes a candidate defect feature value mapping table of the initial candidate defect region corresponding to the target candidate defect region.
5. The multi-defect merging method according to claim 4, characterized in that: After determining the multi-defect merging area, the method further includes: Based on the candidate defect feature value mapping table and a preset defect feature threshold in the multi-defect merged region, a target multi-defect region is screened out from the multi-defect merged region.
6. A multi-defect merging device, characterized in that: include: An acquisition module, configured to determine initial adjacent distance data, wherein the initial adjacent distance data is determined from each initial candidate defect region of the image to be detected according to a preset defect rule; A data updating module, configured to determine an adjacent distance histogram based on the initial adjacent distance data and a preset group distance; It is also used to determine target adjacent distance data based on the adjacent distance histogram, including: Determining a maximum distance interval of the initial adjacent distance data based on a difference between a maximum adjacent distance value and a minimum adjacent distance value in the initial adjacent distance data; Determining the capacity of the adjacent distance histogram based on the maximum distance interval and the preset group distance; Determining the adjacent distance histogram based on the initial adjacent distance data, the preset group distance and the capacity of the adjacent distance histogram; a merging module, configured to determine a multi-defect merged region based on connectivity merging of target candidate defect regions, wherein the target candidate defect regions are determined by morphological dilation of the initial candidate defect regions through a structuring element constructed based on target adjacent distance values of the target adjacent distance data; Before determining the multiple defect merged region based on the connectivity merging of the target candidate defect regions, the method further includes: Based on the preset defect rules, a candidate defect feature value mapping table for each of the initial candidate defect regions is determined.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the multi-defect merging method according to any one of claims 1 to 5 are implemented.
8. A computer storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to perform the steps of the multi-defect merging method according to any one of claims 1 to 5.
Citation Information
Patent Citations
A floor defect image automatic detection method based on morphological characteristics
CN109685788A