Visual defect detection method for precise and complex parts

By dividing the surface of precision and complex parts into multiple areas to be detected, combining image data under multiple angles and light source conditions, the surface texture complexity and defect similarity are calculated, and the fuzzy logic optimization detection algorithm is used to solve the problem of degradation of detection accuracy caused by the similarity between complex surface textures and defects, and high-precision and reliable defect detection are achieved.

CN120259312AActive Publication Date: 2025-07-04宁波意尔达五金工贸有限公司

Patent Information

Application Number
CN202510743530.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-05
Publication Date
2025-07-04
Estimated Expiration
2045-06-05

AI Technical Summary

Technical Problem

In the prior art, when the complex surface texture is similar to the defect, the visual detection system of precision and complex parts can easily lead to adaptive adjustment of the detection algorithm parameters, resulting in reduced detection accuracy and systematic deviation.

Method used

The surface of the part is divided into multiple areas to be detected, image data under multi-angle and multi-light source conditions are obtained, surface texture features are extracted through grayscale symbiosis matrix and spectrum analysis, surface texture complexity and defect similarity are calculated, and misjudgment risks are analyzed using fuzzy logic, and detection algorithms are optimized to limit the parameter adjustment range to improve detection accuracy.

Benefits of technology

It significantly reduces misjudgment and missed inspection under complex surface conditions, ensures the reliability and consistency of the inspection results, and improves the quality control efficiency of the production line.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259312A_ABST
    Figure CN120259312A_ABST
Patent Text Reader

Abstract

The invention discloses a visual defect detection method for precise and complex parts, and particularly relates to the technical field of part detection. The method comprises the following steps: dividing the surface of a precise complex part into a plurality of to-be-detected areas, calculating a gray level co-occurrence matrix characteristic value, texture characteristic distribution and a spectrum analysis result by combining image data under multi-angle and multi-light-source conditions, further comparing surface bulges and gray level difference characteristics of a normal area and the to-be-detected areas, and calculating the surface defect similarity. On the basis of surface texture complexity and defect similarity, risk misjudgment is performed through fuzzy logic analysis, a detection area is divided into high, medium and low risk areas, a detection algorithm is optimized to improve accuracy, finally, algorithm performance is verified through test data, a parameter adjustment range is limited when the misjudgment rate is increased, systematic deviation and performance reduction are avoided, and the detection accuracy is improved. Therefore, the detection stability and the overall quality control reliability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of part detection, and particularly relates to a method for visual defect detection of precision complex parts. Background Art

[0002] Visual defect detection of precision complex parts refers to the process of using vision technology to detect surface defects of precision complex parts produced during the manufacturing process through image acquisition and processing. These parts usually have complex geometric shapes and high manufacturing precision requirements, and any minor flaw or defect may affect the function and service life of the part. The vision detection system scans the part through devices such as cameras, captures its appearance image, and uses algorithms to analyze and detect defects such as surface scratches, dents, cracks, or contamination. Compared with traditional manual detection, vision detection is faster and more accurate, especially suitable for quality control in large-scale production. In addition, the visual defect detection system for precision complex parts usually combines artificial intelligence (AI) and machine learning technologies. By training on a large number of defect samples, the system is enabled to automatically identify and classify different defects. These systems can monitor the production line in real time and adjust production parameters in a timely manner according to the detected defect information, reducing the production of unqualified products.

[0003] The existing technology has the following deficiencies: When using a high-resolution industrial camera or other optical devices to scan or photograph the surface of precision complex parts to obtain image data of the parts, due to the fact that precision complex parts usually have special surface textures or complex geometric structures, these structures may be very similar to real defects visually. In some highly automated detection systems, the detection algorithm may have an adaptive adjustment function to optimize the detection of different types of parts. However, if the complex surface texture is similar to the defect, the system may wrongly adjust the parameters of the detection algorithm, resulting in a significant decrease in the subsequent detection accuracy. At the same time, if the confusion between the complex surface texture and the defect causes the system to be in the wrong adaptive adjustment mode for a long time, this will lead to systematic deviation. This long-term adaptive deviation will not only gradually deteriorate the performance of the detection system, but may also cause the detection accuracy of all subsequent production batches to continue to decline. Summary of the Invention

[0004] The purpose of the present invention is to provide a method for visual defect detection of precision complex parts to solve the deficiencies in the background art.

[0005] To achieve the above purpose, the present invention provides the following technical solution: A method for visual defect detection of precision complex parts, comprising the following steps: S1: Divide the surface of the part into S regions to be detected, and obtain the part images under several angles and light source conditions in each region to be detected, as well as the sample data of the actually marked actual defects and normal surface textures; S2: Calculate the eigenvalues of the gray-level co-occurrence matrix of each region to be detected in the part image, obtain the texture feature distribution of each region to be detected on the part surface, perform spectral analysis on the image of the entire part, calculate the main frequency distribution, and then obtain the surface texture complexity; S3: Compare the surface protrusion features and gray-level difference features between the normal texture region and the region to be detected on the part surface, and calculate the surface defect similarity value in the region to be detected; S4: According to the surface texture complexity and surface defect similarity values calculated in each region to be detected, perform comprehensive analysis on them through fuzzy logic, and determine the risk of detection misjudgment in each region to be detected; According to the risk of detection misjudgment in each region to be detected, divide each region to be detected into high-risk regions to be detected, medium-risk regions to be detected, and low-risk regions to be detected, and optimize the detection algorithm for regions to be detected with different risk levels to improve the accuracy of the detection results; S5: Verify the optimized detection algorithm through test data and actual part detection results, evaluate its performance on complex surfaces, and compare the change of the misjudgment rate. If the misjudgment rate increases, limit the adjustment range of the detection algorithm parameters.

[0006] Preferably, in S2, perform spectral analysis on the image of the entire part, calculate the main frequency distribution, and then obtain the surface texture complexity. Specifically: Perform spectral analysis on the image of the entire part, and convert the image in the spatial domain to the frequency domain. The conversion expression is: ; where f(x, y) is the pixel value of the image, F(u, v) is the Fourier coefficient in the frequency domain, M and N are the width and height of the region to be detected, u, v are the frequency coordinates, j is the imaginary unit, calculate the modulus value of the Fourier transform to obtain the spectral information of the image, and the expression is: ; where is the modulus value of the Fourier transform, are the real part and the imaginary part of the Fourier transform respectively. Calculate the logarithmic amplitude spectrum , and the expression is: ; Calculate the frequency distribution of the highest peak in the spectrum, and determine the main frequency by statistically analyzing the peak positions in the amplitude spectrum , and the expression is: ; The surface texture complexity is measured by the proportion of high-frequency components in the spectrum, and the calculation expression is: ; where represents the high-frequency components greater than the preset high-frequency threshold, is the surface texture complexity.

[0007] Preferably, in S3, calculate the surface defect similarity value within the area to be detected, specifically as follows: Use morphological operations to detect the shape features of surface protrusions, and the expression is: ; where I is the image, Dilation and Erosion respectively represent dilation and erosion operations, apply an edge detection algorithm to detect the edges of the protrusions, extract the geometric shape parameters of the protrusions, and calculate the area to be detected pixel by pixel and the normal area gray difference , and the expression is: ; then calculate the average gray difference of the entire area , and the expression is: ; where M and N are the width and height of the area to be detected, and H is the total number of pixels; use cosine similarity to compare the surface protrusion features, and the protrusion feature vectors are the normal area and the area to be detected respectively, and the expression is: ; in the formula, represents the dot product of the protrusion feature vectors, , are the norms of the protrusion feature vectors of the normal area and the area to be detected respectively; calculate the gray difference similarity , and the similarity of the gray difference is measured by cosine similarity. The gray vectors are the normal area and the area to be detected respectively, and the expression is: ; perform a weighted average calculation on the protrusion feature similarity and the gray difference similarity to obtain the surface defect similarity value.

[0008] Preferably, in S4, according to the surface texture complexity and surface defect similarity values calculated within each area to be detected, through fuzzy logic for comprehensive analysis, determine the risk of detection misjudgment in each area to be detected, specifically as follows: Use the surface texture complexity and surface defect similarity values as the input items of fuzzy logic, and use the risk level of detection misjudgment in each area to be detected as the output item of fuzzy logic; Convert the input surface texture complexity and surface defect similarity values into fuzzy sets, and calculate the membership degrees of each set; Infer according to the fuzzy rules, and combine the membership degrees of the surface texture complexity and surface defect similarity values to deduce the fuzzy output of the risk level; Calculate the definite risk level through the defuzzification method, that is, the risk of detection misjudgment in this area to be detected; Output the risk level of detection misjudgment, divide the area to be detected with a high risk level into a high-risk area to be detected, divide the area to be detected with a medium risk level into a medium-risk area to be detected, and divide the area to be detected with a low risk level into a low-risk area to be detected.

[0009] Preferably, in S5, through the test data and the actual part detection results, verify the optimized detection algorithm, evaluate its performance on complex surfaces, and compare the change of the misjudgment rate. If the misjudgment rate increases, limit the adjustment range of the detection algorithm parameters. Specifically: Collect images of various complex surface parts, including parts with actual defects and normal parts. Use the optimized detection algorithm to detect the parts in the test dataset, and record the results of each detection, including: the area TP correctly detected as a defect, the part TN correctly detected as a normal area, the normal area FP wrongly detected as a defect, and the defect area FN wrongly ignored. According to the detection results, calculate the misjudgment rate of different areas , and the expression is: ; Calculate the misjudgment rate for high-risk, medium-risk, and low-risk areas respectively , compare with the detection results of the previous unoptimized algorithm through the test data, calculate the change value of the misjudgment rate for each risk level area, and the expression is: ; In the formula, is the change value of the misjudgment rate, is the misjudgment rate after optimization, is the misjudgment rate before optimization. If ΔFPR>0, it means that the misjudgment rate of the optimized algorithm increases. If ΔFPR<0, it means that the misjudgment rate of the optimized algorithm decreases and the detection performance is improved.

[0010] Preferably, in S5, when the misjudgment rate increases, mark the parameters that need to be adjusted during the detection process as , and limit its adjustment range. The expression is: ; and are the lower and upper limits of the parameter respectively, is the currently calculated adaptive adjustment value; if exceeds the preset range, the system will correct it to between the preset upper and lower limits; When detecting complex surfaces, reduce misjudgment by restricting the algorithm parameters when processing complex textures. The adjustment expression is: ; and are the allowable texture complexity processing ranges, is the adjusted surface texture complexity, is the currently calculated surface texture complexity; When the misjudgment rate increases, it is necessary to constrain the similarity threshold, and the constraint expression is: ; In the formula, is the allowable range of the similarity threshold, is the adjusted surface defect similarity, is the surface defect similarity calculated currently; After restricting the parameter range, re-detect the test data and calculate the new misjudgment rate , and compare the change of the misjudgment rate: ; is the adjusted misjudgment rate change value. If ΔFPR′ < 0, it means that by restricting the parameter adjustment range, the misjudgment rate is reduced.

[0011] In the above technical solution, the technical effects and advantages provided by the present invention are as follows: 1. The present invention divides the surface of the part into multiple regions to be detected, combines the image data under multiple angles and multiple light sources, extracts the surface texture features by using techniques such as gray-level co-occurrence matrix and spectrum analysis, and calculates the surface texture complexity. By comparing the protrusion features and gray-scale differences between the region to be detected and the normal region, the surface defect similarity is further calculated. Based on these feature values, the misjudgment risk of each region is analyzed by using fuzzy logic, and the detection algorithm is optimized according to the risk level, so as to realize high-precision defect detection. By continuously optimizing the algorithm, the accuracy of detection is ensured, especially in complex surface conditions, misjudgment and missed detection can be significantly reduced.

[0012] 2. The present invention verifies the performance of the detection algorithm through test data and actual part detection results. If the misjudgment rate increases, the detection system is corrected by restricting the range of adaptive adjustment parameters to prevent the further decline of detection performance. By dynamically adjusting the surface texture complexity and the defect similarity threshold, the optimized system can effectively cope with complex surfaces, reduce the misjudgment rate, ensure the reliability and consistency of the detection results, and thus improve the overall quality control efficiency of the production line. Description of the Drawings

[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings.

[0014] Figure 1 is the method flow chart of the present invention. Detailed Embodiments

[0015] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0016] For the embodiments, please refer to Figure 1 As shown, a method for visual inspection of defects of precision complex parts in this embodiment includes the following steps: S1: Divide the surface of the part into S regions to be detected, and obtain part images under several angles and light source conditions in each region to be detected, as well as sample data of actual defects and normal surface textures that have been labeled; S2: Calculate the gray-level co-occurrence matrix eigenvalues of each region to be detected in the part image, obtain the texture feature distribution of each region to be detected on the part surface, perform spectral analysis on the image of the entire part, and calculate the main frequency distribution to obtain the surface texture complexity; S3: Compare the surface protrusion features and gray-level difference features between the normal texture region and the region to be detected on the part surface, and calculate the surface defect similarity value in the region to be detected; S4: According to the surface texture complexity and surface defect similarity values calculated in each region to be detected, perform comprehensive analysis on them through fuzzy logic to determine the risk of detection misjudgment in each region to be detected; according to the risk of detection misjudgment in each region to be detected, divide each region to be detected into high-risk regions to be detected, medium-risk regions to be detected, and low-risk regions to be detected, and optimize the detection algorithm for regions to be detected with different risk levels to improve the accuracy of the detection result; S5: Verify the optimized detection algorithm through test data and actual part detection results, evaluate its performance on complex surfaces, and compare the change in the misjudgment rate. If the misjudgment rate increases, limit the adjustment range of the detection algorithm parameters.

[0017] Among them, in S1, dividing the surface of the part into S regions to be detected, and obtaining part images under several angles and light source conditions in each region to be detected, as well as sample data of actual defects and normal surface textures that have been labeled, specifically: Obtain the geometric data of the part using 3D modeling software or laser scanning technology. Mark out the complex areas, such as corners, curved surfaces, or parts with significant surface variations, which are usually prone to defects. Determine the size range of each area according to the overall size of the part. Generally, the complex areas are divided more finely, and the smooth areas can be divided slightly more loosely. Determine the inspection area that should be covered within each area to ensure equal inspection importance for each area or adjust as needed. For example, the key functional areas can be divided into smaller inspection areas to increase accuracy.

[0018] Divide the part surface into S areas to be inspected, usually using regular grids or adaptive meshing. If the part surface is relatively regular, a uniform grid can be used to divide the entire surface into areas of equal area. For example, divide the surface into a rectangular or square grid, and each grid is an area to be inspected. For parts with complex geometries, use adaptive meshing to adjust the area size according to the curvature or surface feature changes. Divide finer grids where the surface curvature is large, and larger grids in flat areas. Assign a unique number to each area to be inspected so that it can be accurately located when collecting images and analyzing data.

[0019] Determine the installation positions of the camera and light source to ensure the flexibility and adjustability of the image acquisition device. Use a multi-axis robotic arm or an adjustable workbench to ensure that the camera can capture the part surface from multiple angles. Set multiple light sources (such as ring lights, oblique lights, backlights, etc.) to illuminate the part surface from different directions to highlight surface features or defects. Obtain images of each area to be inspected at different angles to ensure that no surface is missed. For each area to be inspected, set several different angles, usually including directly above, oblique angles (such as 30°, 45°, 60°), etc., to ensure that all surfaces can be completely captured by the camera. In complex geometric areas, such as grooves or curved surfaces, add additional shooting angles to ensure inspection accuracy.

[0020] Enhance the surface features using different lighting conditions to make the defects more prominent. Collect images under various light source conditions. Use oblique light to capture small surface protrusions or scratches, use ring light to eliminate shadows, and use backlight to highlight the outline. Record the specific illumination angles and intensities of each light source for subsequent analysis to optimize the inspection algorithm in combination with the light source conditions.

[0021] Obtain complete image data. For each area to be inspected, collect multiple images at different angles and light source conditions to ensure that the details of each area are completely recorded. Store the collected images and correspond them to the numbers of each area to be inspected.

[0022] Actual defective parts are obtained from the production line, and common defect types are collected, including scratches, dents, cracks, contamination, etc. The type, location, size, and severity of each defect are recorded in detail, and defect images are taken. The defect images are manually annotated using image annotation software. The specific content of the annotation includes the location, edge, shape, type, etc. of the defect. The annotation information is combined with the image data to generate a defect sample database for use by the detection algorithm.

[0023] Normal surface texture data is obtained by collecting surface images of multiple normal parts, ensuring that different texture surface data is collected under various lighting conditions and angles. For parts with different materials and surface treatment processes, corresponding normal surface texture samples are obtained, such as polished surfaces, matte surfaces, etc.

[0024] The defect images and normal surface images are classified according to categories, texture features, and surface treatment methods. Labels (defect or normal texture) are added to each image sample, and this data is integrated into the database for use by the algorithm.

[0025] In this application, first, the part surface is divided into multiple regions to be detected, ensuring that image data under different angles and light source conditions can completely capture surface features and defects. By manually annotating actual defects and normal surface textures, a rich dataset is constructed for the training and verification of subsequent detection algorithms. This process not only ensures high-precision defect recognition but also provides an important data basis for optimizing the detection algorithm.

[0026] S2: Calculate the eigenvalues of the gray-level co-occurrence matrix for each region to be detected in the part image, obtain the texture feature distribution of each region to be detected on the part surface, perform spectral analysis on the entire part image, and calculate the main frequency distribution to obtain the surface texture complexity.

[0027] The gray-level co-occurrence matrix (GLCM) is a statistical method used to describe the spatial relationship between pixel gray levels in an image. GLCM represents the frequency of occurrence of gray values between adjacent pixels in an image and can effectively describe the texture features of the image.

[0028] The gray levels of the image are labeled as G, that is, the pixel values range from 0 to G - 1. Then GLCM is a G×G matrix, and each element P(i,j) represents the number of times a pixel with pixel value i and a pixel with pixel value j appear together at a given pixel spacing and direction. Set the direction and distance: Usually, the selected directions are 0°, 45°, 90°, 135°, and the common distance is 1 pixel. The co-occurrence times of pixels at each gray level in a specific direction and distance are statistically counted to construct the gray-level co-occurrence matrix P(i,j).

[0029] The commonly used eigenvalues of the gray-level co-occurrence matrix include contrast, entropy, homogeneity, and correlation, which describe different aspects of image texture. Among them, contrast is used to measure the degree of difference between gray values in an image. The higher the value, the more drastic the pixel gray value changes in the image, and the rougher the texture. The expression is: ; In the formula, is the contrast. Entropy represents the randomness and uncertainty of an image. The larger the entropy value, the more complex the image texture. The expression is: ; is a constant used to avoid the case of zero when taking the logarithm, is the entropy; Homogeneity describes whether the gray values of adjacent pixels in an image are similar. The larger the value, the smoother the image texture. The expression is: ; is the homogeneity; Calculate the linear correlation between pixels. An image with high correlation indicates a strong linear dependence between pixels. The calculation expression of linear correlation is: ; In the formula, is the linear correlation. For each region to be detected, calculate the above eigenvalues of the gray-level co-occurrence matrix to obtain the texture feature distribution of each region. It can be calculated separately for different directions (0°, 45°, 90°, 135°), and then the average value is taken to obtain the comprehensive texture feature.

[0030] Perform spectral analysis on the image of the entire part, convert the image in the spatial domain to the frequency domain. The information in the frequency domain can reveal the periodicity and texture patterns in the image. The conversion expression is: ; In the formula, f(x,y) is the pixel value of the image, F(u,v) is the Fourier coefficient in the frequency domain, M and N are the width and height of the region to be detected, u, v are the frequency coordinates, j is the imaginary unit. Calculate the modulus value of the Fourier transform to obtain the spectral information of the image. The expression is: ; In the formula, is the modulus value of the Fourier transform, are the real part and imaginary part of the Fourier transform respectively. The amplitude spectrum reflects the frequency distribution in the image. To represent the spectrum more clearly visually, the logarithm of the amplitude spectrum can be taken, that is, calculate the logarithmic amplitude spectrum , and the expression is: ; The main frequency reflects the dominant texture periodicity and characteristic change frequency in the image. Through spectral analysis, the main frequency components of the image can be extracted. Calculate the frequency distribution of the highest peak in the spectrum, that is, determine which frequencies dominate in the image, and determine the main frequency by statistically analyzing the peak positions in the amplitude spectrum , and the expression is: ; The main frequency reflects the most prominent texture pattern in the image. Generally, high frequency means complex surface texture, while low frequency indicates smooth texture.

[0031] The surface texture complexity is measured by the proportion of high-frequency components in the spectrum. An image with more high-frequency components has complex texture, and an image with more low-frequency components has smooth texture. The calculation expression is: ; In the formula, represents the high-frequency components greater than the preset high-frequency threshold, is the surface texture complexity.

[0032] The higher the surface texture complexity, the more high-frequency details and complex variations exist on the surface, such as fine unevenness, messy textures, or tiny surface features. In this case, the detection algorithm is prone to misjudging normal complex textures as defects because it is difficult to visually distinguish normal textures from actual defects. Regions with high complexity are more likely to generate false positives, that is, the system misidentifies normal surfaces as defective, increasing the risk of detection misjudgment. Therefore, for regions with high complexity, the system needs to more strictly control the detection parameters to avoid misjudgment.

[0033] On the contrary, the lower the surface texture complexity, the smoother and more uniform the texture of the region, the smaller the pixel changes, and the more significant the difference between defect features and normal surfaces. In this case, the detection algorithm is more likely to accurately identify actual defects because surface anomaly points are more obvious. However, if the algorithm overly relies on high-sensitivity parameters, it may ignore small and weak defects, resulting in false negatives, that is, failing to detect actual existing defects. Therefore, although the risk of false positives is low in low-complexity regions, the risk of false negatives needs to be guarded against.

[0034] S3: Compare the surface protrusion features and gray-scale difference features between the normal texture region of the part surface and the region to be detected, and calculate the surface defect similarity value within the region to be detected.

[0035] Preprocess the obtained images of the region to be detected and the normal texture region, including operations such as denoising, enhancing contrast, and edge detection, to ensure the image quality for subsequent feature extraction. Common filtering methods include Gaussian filtering and median filtering to eliminate noise and ensure that protrusion and defect features are clear.

[0036] Use morphological operations (such as dilation, erosion, gradient) to detect the shape features of surface protrusions. The expression is: ; where I is the image, Dilation and Erosion represent dilation and erosion operations respectively. Apply edge detection algorithms (such as Sobel, Canny operators) to detect the edges of protrusions, extract the geometric shape parameters of protrusions, and calculate the region to be detected pixel by pixel and the normal area gray level difference , the expression is: ; then calculate the average gray level difference of the entire area , the expression is: ; where, M and N are the width and height of the area to be detected, and H is the total number of pixels; use cosine similarity to compare the surface protrusion features, and the protrusion feature vectors are the normal area and the area to be detected , the expression is: ; in the formula, represents the dot product of the protrusion feature vectors, , are the norms of the protrusion feature vectors of the normal area and the area to be detected respectively. Calculate the gray level difference similarity , the similarity of the gray level difference can also be measured by cosine similarity, and the gray level vectors are the normal area and the area to be detected , the expression is: ; perform a weighted average calculation on the protrusion feature similarity and the gray level difference similarity to obtain the surface defect similarity value.

[0037] When the surface defect similarity value is larger, it indicates that the difference between the area to be detected and the normal surface texture area is smaller, that is, the surface features of the area to be detected are very similar to the normal area. In this case, the detection algorithm is difficult to distinguish the normal surface from the actual defect, and it is easy to generate false positives, that is, misidentifying normal complex textures as defects (false alarms, False Positives). Therefore, the larger the similarity value, the higher the risk of false positives in each area to be detected. Especially in the case of complex surface textures, the detection system may be overly sensitive, resulting in an increase in the false alarm rate.

[0038] On the contrary, when the surface defect similarity value is smaller, it indicates that there are obvious differences between the area to be detected and the normal surface texture area, and the surface feature differences are significant. In this case, the detection algorithm can more accurately identify the difference between the defect and the normal area, and the risk of false positives is lower. However, if the similarity is too small, the detection system may be insensitive to relatively small or hidden defects on the surface, resulting in false negatives, that is, failing to detect actual defects. Therefore, the smaller the similarity value, the lower the risk of false positives, but attention should be paid to preventing the possibility of false negatives.

[0039] S4: Based on the surface texture complexity and surface defect similarity values calculated in each area to be detected, after comprehensively analyzing them through fuzzy logic, determine the risk of detection misjudgment in each area to be detected; according to the risk of detection misjudgment in each area to be detected, divide each area to be detected into high-risk areas to be detected, medium-risk areas to be detected, and low-risk areas to be detected, and optimize the detection algorithm for areas to be detected with different risk levels to improve the accuracy of the detection results.

[0040] Take the surface texture complexity CZ and the surface defect similarity value HG as the input items of fuzzy logic, and take the risk level L of detection misjudgment in each area to be detected as the output item of fuzzy logic; The surface texture complexity CZ describes the complexity of the surface texture in the area to be detected. The more complex the surface texture, the more high-frequency information it contains, and the detection algorithm is likely to misjudge normal texture as a defect. Fuzzification: According to different texture complexities, divide the value range of CZ into several fuzzy sets: Low complexity (Low): The surface texture is smooth and uniform, with low complexity. Medium complexity (Medium): The surface has certain texture changes but is not complex. High complexity (High): The surface texture has many changes and rich high-frequency information.

[0041] The specific fuzzification method can be set according to experience in actual applications. For example, assuming the value range of CZ is [0, 1], then: CZ ≤ 0.3 is low complexity; 0.3 < CZ ≤ 0.7 is medium complexity; CZ > 0.7 is high complexity.

[0042] The surface defect similarity HG measures the degree of similarity between the area to be detected and the normal surface area. The higher the similarity value, the more similar the area to be detected is to the normal area, and the greater the possibility of misjudgment. Fuzzification: According to the level of the similarity value, divide HG into the following fuzzy sets: Low similarity (Low): The area to be detected is significantly different from the normal surface, and the detection system can easily distinguish. Medium similarity (Medium): The area to be detected has a certain similarity to the normal area. High similarity (High): The area to be detected is extremely similar to the normal area, which is likely to cause misjudgment. For example, assuming the value range of HG is [0, 1], then: HG ≤ 0.3 is low similarity; 0.3 < HG ≤ 0.7 is medium similarity; HG > 0.7 is high similarity.

[0043] The risk level L reflects the risk of misjudgment in each area to be detected, and is divided into three levels: low, medium, and high: Low risk (Low): The risk of misjudgment is small, and the detection is relatively reliable. Medium risk (Medium): There is a certain possibility of misjudgment, and the algorithm needs to be further adjusted. High risk (High): The risk of misjudgment is high, and the detection system needs to focus on processing.

[0044] Convert the input items CZ and HG into corresponding fuzzy sets. Use membership functions to relate the input values to the membership degrees of the fuzzy sets. Common membership functions include triangular membership functions and trapezoidal membership functions.

[0045] For surface texture complexity (CZ): Low: When CZ ∈ [0, 0.3], the membership degree is 1; when CZ ∈ (0.3, 0.5], the membership degree gradually decreases. Medium: When CZ ∈ [0.3, 0.7], the membership degree is 1. High: When CZ > 0.7, the membership degree is 1.

[0046] For surface defect similarity (HG): Low: When HG ∈ [0, 0.3], the membership degree is 1; when HG ∈ (0.3, 0.5], the membership degree gradually decreases. Medium: When HG ∈ [0.3, 0.7], the membership degree is 1. High: When HG > 0.7, the membership degree is 1.

[0047] Based on the surface texture complexity (CZ) and surface defect similarity (HG), set fuzzy rules to deduce the risk level (L). These rules are usually expressed in the form of "if - then". Example rules: If CZ is low complexity and HG is low similarity, then L is low risk. If CZ is low complexity and HG is high similarity, then L is medium risk. If CZ is high complexity and HG is high similarity, then L is high risk. If CZ is high complexity and HG is low similarity, then L is medium risk. If CZ is medium complexity and HG is medium similarity, then L is medium risk. These rules can be extended according to specific applications, such as adding more fuzzy sets or more complex logical relationships.

[0048] Defuzzification converts the result of fuzzy inference into a clear output value. Commonly used defuzzification methods include the centroid method, that is, by calculating the centroid of the fuzzy set to obtain the final output value.

[0049] By outputting the detected risk level of misjudgment, divide the regions to be detected with high risk levels into high - risk regions to be detected, divide the regions to be detected with medium risk levels into medium - risk regions to be detected, and divide the regions to be detected with low risk levels into low - risk regions to be detected; and optimize the detection algorithms for regions to be detected with different risk levels to improve the accuracy of the detection results. Specifically: The surface texture of high - risk regions is complex, which is prone to confusing normal surfaces with defect regions and requires key optimization. Optimization measures include: Multi - angle and multi - light - source detection: To reduce the influence of surface texture complexity on detection, increase the shooting angles and light source conditions to ensure that surface features can be accurately captured under different conditions.

[0050] Multi-scale analysis: Use multi-scale feature extraction methods (such as Scale-Invariant Feature Transform - SIFT, HOG features) to perform image analysis at different resolutions. Multi-scale analysis can capture defect information at different scales and avoid missing small defects.

[0051] Adaptive threshold adjustment: In high-risk areas, the detection threshold should be dynamically adjusted according to the surface complexity within the area. Set an adaptive threshold to ensure that the detection sensitivity can be moderately increased in areas with high complexity while avoiding over-sensitivity.

[0052] Enhanced texture feature extraction algorithm: Introduce stronger texture analysis algorithms, such as Gabor filters, advanced features of gray-level co-occurrence matrix (such as energy, entropy), to ensure better discrimination between complex textures and real defects.

[0053] Integrate multiple detection means: Combine visual detection with other detection methods, such as ultrasonic, X-ray, etc., to perform multi-mode detection on high-risk areas to ensure the reliability of the detection results.

[0054] Detection objective: Improve the detection rate of real defects in complex areas and reduce the occurrence of false alarms and missed detections.

[0055] The risk of misjudgment in the detection of medium-risk areas is medium, and it is necessary to reduce misjudgment through appropriate optimization. The optimization measures include: Local enhancement detection: In medium-risk areas, selective local enhancement image processing (such as local contrast enhancement, edge detection) can be used to enhance surface features for more accurate discrimination between normal surfaces and potential defects.

[0056] Statistical-based classification algorithm: Use machine learning-based classification algorithms (such as Support Vector Machine - SVM or Random Forest) to analyze the features of medium-risk areas, thereby improving the classification ability for specific defect patterns. The model can be trained by using existing labeled data.

[0057] Morphological operation optimization: Further optimize the boundary recognition of defect areas through morphological dilation and erosion operations to enhance the detection effect in areas with medium complexity.

[0058] Flexible detection parameter adjustment: The algorithm optimization in medium-risk areas should be flexible, not requiring extremely high sensitivity, but should be able to adapt to the regional characteristics and improve the detection efficiency by moderately adjusting parameters.

[0059] Detection objective: Balance detection efficiency and accuracy in areas with medium complexity, reduce misjudgment while maintaining the detection speed.

[0060] Low-risk areas are relatively simple and have low detection difficulty, but it is necessary to ensure the accuracy of the basic algorithm. The optimization measures include: Standardized detection process: In low-risk areas, a relatively standardized detection process can be adopted, without the need for overly complex algorithms, but the basic defect detection accuracy must be ensured.

[0061] Threshold detection: A relatively high detection threshold can be used to reduce the sensitivity to minor noise and slight textures, thereby reducing the possibility of false alarms.

[0062] Accelerated detection algorithm: In low-risk areas, the algorithm can be more simplified, using fast detection methods (such as region-based fast edge detection or simple binarization) to improve the overall detection efficiency.

[0063] Low resource consumption: Since the detection tasks in low-risk areas are relatively simple, the consumption of computing resources can be reduced, optimizing the overall performance of the system. Ensure the detection accuracy in low-risk areas, while improving the detection efficiency and reducing resource consumption.

[0064] S5: Verify the optimized detection algorithm through test data and actual part detection results, evaluate its performance on complex surfaces, and compare the changes in the false positive rate. If the false positive rate increases, limit the adjustment range of the detection algorithm parameters.

[0065] Collect images of various complex surface parts, including parts with actual defects and normal parts. These datasets should cover high-complexity surface features (such as polishing, frosting, curved surfaces, etc.) to comprehensively evaluate the optimized detection algorithm.

[0066] Use the optimized detection algorithm to detect the parts in the test dataset, record the results of each detection, including: the area TP correctly detected as a defect, the part TN correctly detected as a normal area, the normal area FP incorrectly detected as a defect, and the defect area FN incorrectly ignored. According to the detection results, calculate the false positive rate of different areas , the expression is: ; Calculate the false positive rate for high-risk, medium-risk, and low-risk areas respectively , in order to more carefully understand the performance of each risk area; Compare the detection results of the test data with those of the previous unoptimized algorithm, calculate the change value of the false positive rate for each risk level area, and the expression is: ; In the formula, is the change value of the false positive rate, is the false positive rate after optimization, is the false positive rate before optimization. If ΔFPR > 0, it means that the false positive rate of the optimized algorithm increases. If ΔFPR < 0, it means that the false positive rate of the optimized algorithm decreases and the detection performance is improved.

[0067] When the false positive rate increases, it indicates that the parameter adjustment during the optimization process may introduce new false positive risks. At this time, the false positives can be reduced by restricting the adjustment range of certain key parameters.

[0068] The optimized detection algorithm often adaptively adjusts certain parameters (such as grayscale threshold, edge detection threshold, sensitivity of feature extraction, etc.). If these parameter adjustments are excessive, it may lead to an increase in the false positive rate. Therefore, it is necessary to limit the adjustment range of these parameters.

[0069] Mark the parameters that need to be adjusted during the detection process as , and restrict their adjustment range. The expression is: ; and are the lower and upper limits of the parameter respectively, which define the allowed adjustment range. is the currently calculated adaptive adjustment value. If exceeds the preset range, the system will correct it to between the preset upper and lower limits to avoid an increase in false alarms caused by excessive parameter adjustment. For example, in the adjustment of the grayscale threshold of an image, assume that the grayscale threshold of the initial detection algorithm is = 128, and after optimization, it is adjusted to = 150. If the false positive rate increases, the threshold range [120, 140] can be set so that the adaptive adjustment does not exceed this range, thereby preventing false positives caused by excessive adjustment.

[0070] When detecting complex surfaces, the surface texture complexity CZ has a great influence on the detection performance. The false positives can be reduced by restricting certain algorithm parameters (such as the scale of feature extraction, the window size of texture analysis, etc.) when dealing with complex textures. The adjustment expression is: ; and are the allowed texture complexity processing ranges. is the adjusted surface texture complexity. is the currently calculated surface texture complexity. By restricting the value range of the parameter CZ, it is possible to avoid overly sensitive detection in areas with too high surface texture complexity and prevent the detection system from misjudging normal surfaces as defects. The surface defect similarity HG is a key indicator for measuring the similarity between the area to be detected and the normal surface. When the false positive rate increases, it is necessary to constrain the similarity threshold to avoid the algorithm being overly sensitive to similar features. The constraint expression is: ; In the formula, is the allowed range of the similarity threshold. is the adjusted surface defect similarity. is the currently calculated surface defect similarity. By restricting the similarity threshold, it is possible to reduce false alarms in areas with similar features in the detection system, thereby reducing the false positive rate.

[0071] By restricting the adjustment range of key parameters, the risk of misjudgment introduced during the optimization process can be reduced. After restricting the parameter range, the test data is re-detected to calculate the new misjudgment rate , and compare the change in the misjudgment rate: ; Let ΔFPR′ be the change value of the misjudgment rate after adjustment. If ΔFPR′ < 0, it indicates that the misjudgment rate is effectively reduced by restricting the parameter adjustment range.

[0072] In this application, during the optimization process of the detection algorithm, evaluating the change in the misjudgment rate through test data and the detection results of actual parts is a crucial step. When it is found that the misjudgment rate increases, the adjustment range of the key parameters of the detection algorithm (such as threshold, similarity, texture complexity, etc.) can be restricted to prevent false alarms caused by excessive parameter adjustment. By adjusting and controlling the key parameters through formulas, the misjudgment rate can be effectively reduced, and the accuracy of the detection algorithm on complex surfaces can be improved.

[0073] In this embodiment, the surface of the part is divided into multiple regions to be detected, and images are collected under different angles and light source conditions. At the same time, the labeled defect and normal texture data are used as references. Then, the eigenvalues of the gray-level co-occurrence matrix of each region are calculated, its texture feature distribution is analyzed, and the surface texture complexity is obtained through spectral analysis. Next, by comparing the surface protrusion features and gray-scale differences between the regions to be detected and the normal regions, the surface defect similarity value is calculated. Based on the surface texture complexity and the defect similarity value, fuzzy logic is used to evaluate the misjudgment risk of each region and divide it into high, medium, and low risk regions. For regions with different risk levels, the detection algorithm is optimized to improve the detection accuracy. Finally, the optimization effect is verified through test data and actual detection results, the change in the misjudgment rate is evaluated, and the adjustment range of the algorithm parameters is restricted when the misjudgment rate increases to ensure the detection accuracy and system stability.

[0074] The above formulas are all dimensionless and take their numerical values for calculation. The formula is obtained by collecting a large amount of data for software simulation to get a formula closest to the real situation. The preset parameters in the formula are set by those skilled in the art according to the actual situation.

[0075] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains a collection of one or more available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state drive.

[0076] It should be understood that the term "and / or" in this document is merely a description of the association relationship between associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. Here, A and B can be singular or plural. In addition, the character " / " in this document generally represents an "or" relationship between the associated objects before and after, but it may also represent an "and / or" relationship, which can be specifically understood by referring to the context. Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in this document can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0077] As described above, the above are only the specific implementation manners of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed in this application can easily think of changes or substitutions, which should all be covered by the protection scope of this application.

Claims

1. A visual inspection method for defects of precision complex parts, characterized in that: Including the following steps; S1: Divide the surface of the part into S regions to be detected, and obtain the part images under several angles and light source conditions in each region to be detected, as well as the sample data of the actually marked actual defects and normal surface textures; S2: Calculate the gray-level co-occurrence matrix eigenvalues of each region to be detected in the part image, obtain the texture feature distribution of each region to be detected on the part surface, perform spectral analysis on the image of the entire part, and calculate the main frequency distribution to obtain the surface texture complexity; S3: Compare the surface protrusion features and gray-scale difference features between the normal texture region and the region to be detected on the part surface, and calculate the surface defect similarity value in the region to be detected; S4: According to the surface texture complexity and surface defect similarity values calculated in each region to be detected, perform comprehensive analysis on them through fuzzy logic, and determine the risk of detection misjudgment in each region to be detected; According to the risk of detection misjudgment in each region to be detected, divide each region to be detected into high-risk regions to be detected, medium-risk regions to be detected, and low-risk regions to be detected, and optimize the detection algorithm for regions to be detected with different risk levels to improve the accuracy of the detection results; S5: Verify the optimized detection algorithm through test data and actual part detection results, evaluate its performance on complex surfaces, and compare the change of the misjudgment rate. If the misjudgment rate increases, limit the adjustment range of the detection algorithm parameters.

2. The defect vision inspection method for a precision complex part according to claim 1, characterized in that: In S2, perform spectral analysis on the image of the entire part, calculate the main frequency distribution to obtain the surface texture complexity, specifically: Perform spectral analysis on the image of the entire part, converting the image in the spatial domain to the frequency domain. The conversion expression is: ; where f(x, y) is the pixel value of the image, F(u, v) is the Fourier coefficient in the frequency domain, M and N are the width and height of the area to be detected, u and v are the frequency coordinates, j is the imaginary unit. Calculate the modulus value of the Fourier transform to obtain the spectral information of the image. The expression is: ; Wherein, is the modulus value of the Fourier transform, are the real part and the imaginary part of the Fourier transform respectively, and calculate the logarithmic amplitude spectrum , and the expression is: ; Calculate the frequency distribution of the highest peak in the spectrum, and determine the main frequency by statistically counting the peak positions in the amplitude spectrum , and the expression is: ; The surface texture complexity is measured by the proportion of high-frequency components in the spectrum, and the calculation expression is: ; Wherein, represents the high-frequency components greater than the preset high-frequency threshold, is the surface texture complexity.

3. A visual defect detection method for precision complex parts according to claim 2, characterized in that: In S3, calculate the surface defect similarity value in the region to be detected, specifically: Use morphological operations to detect the shape features of surface protrusions, and the expression is: ; where I is the image, Dilation and Erosion represent dilation and erosion operations respectively. The edge detection algorithm is applied to detect the protruding edges, and the geometric shape parameters of the protrusions are extracted. By calculating pixel by pixel in the area to be detected and the normal area of the grayscale difference , the expression is: ; then the average grayscale difference of the entire area is calculated , the expression is: ; where M and N are the width and height of the area to be detected, and H is the total number of pixels; the cosine similarity is used to compare the surface protrusion features. The protrusion feature vectors are the normal area and the area to be detected respectively, and the expression is: ; in the formula, represents the dot product of the protrusion feature vectors, , are the norms of the protrusion feature vectors of the normal area and the area to be detected respectively; the grayscale difference similarity is calculated. The similarity of the grayscale difference is measured by the cosine similarity. The grayscale vectors are the normal area and the area to be detected respectively, and the expression is: ; the weighted average of the protrusion feature similarity and the grayscale difference similarity is calculated to obtain the surface defect similarity value.

4. A visual defect detection method for precision complex parts according to claim 3, characterized in that: In S4, according to the surface texture complexity and surface defect similarity values calculated in each region to be detected, perform comprehensive analysis on them through fuzzy logic, and determine the risk of detection misjudgment in each region to be detected, specifically: Take the surface texture complexity and surface defect similarity values as the input items of fuzzy logic, and take the risk level of detection misjudgment in each region to be detected as the output item of fuzzy logic; Convert the input surface texture complexity and surface defect similarity values into fuzzy sets, and calculate the membership degrees of each set; Perform reasoning according to the fuzzy rules, combine the membership degrees of the surface texture complexity and surface defect similarity values, and deduce the fuzzy output of the risk level; Calculate the clear risk level through the defuzzification method, that is, the risk of detection misjudgment in this region to be detected; Output the risk level of detection misjudgment, divide the regions to be detected with high risk levels into high-risk regions to be detected, divide the regions to be detected with medium risk levels into medium-risk regions to be detected, and divide the regions to be detected with low risk levels into low-risk regions to be detected.

5. The defect vision detection method for a precision complex part according to claim 1, characterized in that: In S5, verify the optimized detection algorithm through test data and actual part detection results, evaluate its performance on complex surfaces, and compare the change of the misjudgment rate. If the misjudgment rate increases, limit the adjustment range of the detection algorithm parameters, specifically: Collect images of various complex surface parts, including parts with actual defects and normal parts. Use the optimized detection algorithm to detect the parts in the test dataset and record the results of each detection, including: the area TP correctly detected as defective, the part TN correctly detected as a normal area, the normal area FP incorrectly detected as defective, and the defective area FN incorrectly ignored. According to the detection results, calculate the false positive rate of different areas , and the expression is: ; Calculate the false positive rate for high-risk, medium-risk, and low-risk areas respectively , compare with the detection results of the previous unoptimized algorithm through the test data, calculate the change value of the false positive rate for each risk level area, and the expression is: ; In the formula, is the change value of the false positive rate, is the false positive rate after optimization, is the false positive rate before optimization. If ΔFPR > 0, it means that the false positive rate of the optimized algorithm increases; if ΔFPR < 0, it means that the false positive rate of the optimized algorithm decreases and the detection performance is improved.

6. The defect vision detection method for a precision complex part according to claim 5, characterized in that: In S5, when the misjudgment rate increases, the parameters that need to be adjusted during the detection process are marked as , and its adjustment range is restricted. The expression is: ; and are the lower and upper limits of the parameter respectively, is the currently calculated adaptive adjustment value; If exceeds the preset range, the system will correct it to between the preset upper and lower limits; When detecting complex surfaces, misjudgment is reduced by restricting the algorithm parameters when processing complex textures, and the adjustment expression is: ; and is the allowable texture complexity processing range, is the adjusted surface texture complexity, is the surface texture complexity obtained by the current calculation; When the misjudgment rate increases, it is necessary to constrain the similarity threshold, and the constraint expression is: ; Wherein, is the range allowed by the similarity threshold, is the adjusted surface defect similarity, is the surface defect similarity calculated currently; After restricting the parameter range, re-detect the test data and calculate the new false positive rate , and compare the change in the false positive rate: ; ; where ΔFPR′ is the changed value of the false positive rate after adjustment. If ΔFPR′ < 0, it indicates that the false positive rate is reduced by restricting the parameter adjustment range.

Citation Information

Patent Citations

  • Part surface quality detection method and system based on machine vision

    CN118608504A

  • Visual inspection method for surface quality of precise injection mold base

    CN119985484A

  • Defect detection apparatus and defect detection method

    US20060067571A1

Cited By

  • Screen arc edge area defect detection system and method based on area-array camera mobile equipment

    CN120471914A

  • Screen arc edge region defect detection system and method based on area array camera mobile device

    CN120471914B

  • Micro motor surface defect quality inspection method and system based on image recognition

    CN120997654A

  • AI learning system and method for reducing AVI machine false points

    CN121214179A

  • An ai learning system and method for reducing false positives of an avi machine

    CN121214179B