Automobile part surface defect detection method and system based on machine vision
By using virtual modeling and multi-scale signal decoupling techniques, combined with optical distortion correction and wavelet transform, the collaborative segmentation and determination of high and low frequency defects on the surface of automotive outer panels were achieved. This solved the problem of chain failures in traditional detection systems and enabled efficient and accurate defect detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-13
- Publication Date
- 2026-03-27
AI Technical Summary
Existing machine vision inspection systems cannot reliably and completely detect both high-frequency texture defects and low-frequency morphological defects on the surface of automotive exterior panels. They are susceptible to cascading failures due to uneven lighting and geometric distortion.
An ideal reflection spectrum is generated by loading a CAD 3D model, an optical distortion correction matrix is calculated, a programmable light source is driven to project a compensation pattern, a multi-scale wavelet transform is performed to decouple the signal, homomorphic filtering and Hessian matrix analysis are applied to generate a cooperative segmentation mask, and defect determination is achieved by combining geometric attribute analysis.
It achieves robust and complete detection of high-frequency texture and low-frequency morphological defects on the surface of automotive exterior panels, eliminating interference from uneven lighting and geometric distortion, and improving the accuracy and completeness of the detection.
Smart Images

Figure CN121746291A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial vision technology, specifically to a method and system for detecting surface defects in automotive parts based on machine vision. Background Technology
[0002] In automobile manufacturing, quality inspection of "car exterior panels" (such as doors) is crucial. Existing machine vision inspection systems typically employ a single, cascaded processing pipeline, which sequentially performs image acquisition, image enhancement, defect segmentation, and geometric analysis.
[0003] However, this single-pipeline method faces an intractable core technical problem when applied to "automotive outer panels." This problem stems from the simultaneous presence of two key defects on the surface of automotive outer panels: the first type is high-frequency texture defects, such as "hairline scratches" or "pinholes," which manifest as sharp, high-spatial-frequency signal abrupt changes; the second type is low-frequency morphological defects, such as "orange peel texture" or "gentle depressions," which manifest as gentle, low-spatial-frequency signal gradients with "weak boundary information."
[0004] For traditional single-processing pipelines, this signal contradiction leads to a "preprocessing dilemma" and a "chain reaction of failures." Image sharpening or high-pass filters designed to detect "hairline scratches" greatly amplify background noise and completely drown out the weak signal of "orange peel texture." Conversely, smoothing or low-pass filters designed to detect "orange peel texture" inevitably erase "hairline scratches" as noise. This conflict makes it impossible for any single segmentation algorithm (such as adaptive thresholding) to find a standard that applies to both defects simultaneously, ultimately resulting in detection results filled with false positives or a large number of false negatives. In addition, the high reflectivity and complex curved surface characteristics of automotive exterior panels produce severe uneven lighting and geometric distortion under "factory ambient light."
[0005] In summary, the core technical problem of existing technologies is the lack of a mechanism to decouple the contradictory signals of "high-frequency texture defects" and "low-frequency morphological defects" when dealing with images of "car exterior panels" that suffer from "uneven illumination" and "geometric distortion." This deficiency leads to a "chain reaction of failures" in the enhancement and segmentation steps of traditional single-processing pipelines, making it impossible to reliably and completely detect both types of defects simultaneously.
[0006] To address this, a machine vision-based method and system for detecting surface defects in automotive parts are proposed. Summary of the Invention
[0007] The purpose of this invention is to provide a method and system for detecting surface defects in automotive parts based on machine vision. This invention relates to the field of industrial vision technology, specifically a method and system for detecting surface defects in automotive parts based on machine vision, comprising: First, loading a CAD 3D model and rendering an ideal stripe reflection pattern in a virtual environment; calculating an optical distortion correction matrix by comparing the phase distortion with the actual initial reflection pattern, driving a programmable light source to project a compensation pattern, and generating a normalized reflection intensity map; using multi-scale wavelet transform to achieve physical decoupling of the signal and separate high- and low-frequency components; applying homomorphic filtering to the low-frequency components to construct a uniform background model, inversely correcting the high-frequency components, and outputting a high signal-to-noise ratio defect signal image; generating a coarse segmentation mask from the high-frequency signal through adaptive local thresholding, and generating a morphological anomaly mask from the low-frequency signal through Hessian matrix morphological analysis, and fusing them to form a collaborative segmentation mask; extracting the multidimensional geometric attributes of the connected components within the mask, and inputting them into a decision tree to achieve accurate defect classification and confidence output. This system overcomes the limitations of traditional single pipelines by using virtual modeling closed-loop correction, multi-scale signal decoupling, dual-channel information complementarity and geometric decision coupling, to achieve robust, complete and industrially traceable detection of all types of defects on complex curved surfaces.
[0008] To achieve the above objectives, the present invention provides the following technical solution: Machine vision-based methods for detecting surface defects in automotive parts include: Load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, render and generate an ideal reflection spectrum; The initial physical reflection map of the outer plate is captured and spatially compared with the ideal reflection map to calculate the optical distortion correction matrix; the optical distortion correction matrix is used to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, and a normalized reflection intensity map is generated. A multi-scale wavelet transform is performed on the normalized reflection intensity map to achieve signal decoupling, decomposing it into a high-frequency component containing high-frequency defect information and a low-frequency component containing low-frequency defect information; homomorphic filtering is applied to the low-frequency component to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency component based on the homogenized background model to generate a defect signal image. The defect signal image is segmented using an adaptive local thresholding algorithm to generate a coarse segmentation defect mask. Local morphological analysis is performed on the low-frequency components to generate a shape anomaly mask. The coarse segmentation defect mask and the shape anomaly mask are fused to generate a co-segmentation mask. Geometric attribute analysis is then performed on the regions within the co-segmentation mask to determine the defects.
[0009] Preferably, the specific process for obtaining the ideal reflection spectrum is as follows: import the CAD 3D model of the car's outer panel into the virtual rendering environment, set the virtual light source parameters and camera parameters consistent with the actual inspection, and simulate the projection behavior of sinusoidal fringe light on an ideal defect-free surface; use the physical rendering pipeline to simulate the specular reflection and diffuse reflection of light on the curved surface to generate an ideal reflection spectrum without optical distortion and without ambient light interference; the virtual light source parameters include fringe period, wavelength, and projection angle, and the camera parameters include resolution, focal length, and principal point coordinates.
[0010] Preferably, the specific calculation process of the optical distortion correction matrix is as follows: using an industrial camera to capture the initial physical reflection map of the actual outer panel under standard stripe light projection; performing phase demodulation on the initial physical reflection map and the ideal reflection map respectively, and extracting their respective wrapping phase maps; calculating the phase distortion field between the two phase maps; establishing the mapping relationship between phase distortion and pixel coordinates through polynomial fitting; and obtaining the optical distortion correction matrix by inverse solution.
[0011] Preferably, the specific generation process of the normalized reflection intensity map is as follows: inputting the optical distortion correction matrix into the programmable light source controller, performing inverse distortion pre-distortion processing on the original stripe pattern to generate a compensated projection pattern; projecting the compensated projection pattern onto the actual outer panel surface in real time through the programmable light source; synchronously capturing the compensated reflection image using an industrial camera; performing intensity normalization and phase weighted fusion on the captured image to output the normalized reflection intensity map.
[0012] Preferably, the specific generation process of the defect signal image is as follows: performing multi-level discrete wavelet transform on the normalized reflection intensity map to separate high-frequency components and low-frequency components; applying homomorphic filtering to the low-frequency components to suppress uneven illumination and extract slowly changing background trends to generate a homogenized background model; to eliminate the residual, slowly varying baseline drift introduced by the surface morphology of the original image in the high-frequency components, the homogenized background model is magnified to the same resolution as the high-frequency components by interpolation upsampling to obtain a baseline background image; subtracting the baseline background image from the high-frequency components to eliminate the interference of the low-frequency background baseline on the high-frequency defect signal; performing contrast enhancement and noise suppression on the result to output a high signal-to-noise ratio defect signal image containing only defect features.
[0013] Preferably, the specific generation process of the collaborative segmentation mask is as follows: applying an adaptive local thresholding algorithm to the defect signal image for pixel-level segmentation to generate a coarse segmentation defect mask; calculating the Hessian matrix of the low-frequency component image, and analyzing the local gray-level morphology based on the eigenvalues of the Hessian matrix, setting a morphological anomaly threshold to generate a shape anomaly mask; performing a weighted fusion of the coarse segmentation defect mask and the shape anomaly mask; performing a morphological closing operation on the fusion result to remove isolated noise and fill in small gaps, finally generating a collaborative segmentation mask.
[0014] Preferably, the specific process for determining defects is as follows: extracting the geometric attributes of each connected region within the collaborative segmentation mask, including area, perimeter, ratio of major axis to minor axis, circularity, and average intensity; constructing a classification decision tree based on multiple feature thresholds to determine the defect type of the region; the defect types include scratches, pits, bumps, coating peeling, and foreign object indentations; and outputting the pixel-level mask, bounding box coordinates, type label, and confidence level of the defect.
[0015] A machine vision-based automotive parts surface defect detection system, the system being used to execute the aforementioned machine vision-based automotive parts surface defect detection method, including: The ideal reflection spectrum generation module is used to load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, and render and generate the ideal reflection spectrum. The normalized reflection intensity map generation module is used to capture the initial physical reflection map of the outer plate, compare it spatially with the ideal reflection spectrum, calculate the optical distortion correction matrix, and use the optical distortion correction matrix to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, thereby generating a normalized reflection intensity map. The signal decoupling and background separation module performs multi-scale wavelet transform on the normalized reflection intensity map to achieve signal decoupling, decomposing it into a high-frequency component containing high-frequency defect information and a low-frequency component containing low-frequency defect information; homomorphic filtering is applied to the low-frequency component to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency component based on the homogenized background model to generate a defect signal image. The collaborative segmentation module segments the defect signal image using an adaptive local thresholding algorithm to generate a coarse segmentation defect mask; performs local morphological analysis on low-frequency components to generate a shape anomaly mask; and fuses the coarse segmentation defect mask with the shape anomaly mask to generate a collaborative segmentation mask. The defect determination module performs geometric attribute analysis on the region within the collaborative segmentation mask to determine defects.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention achieves high-precision normalized reflectance intensity map generation by coupling a virtual ideal reflectance spectrum with real-time distortion correction, completely eliminating interference from curved surface geometry and uneven illumination. The spatial phase of the ideal reflectance spectrum (virtual CAD rendering) is compared with the initial physical reflectance map to generate an optical distortion correction matrix. This matrix then drives a programmable light source to project a compensation pattern, forming a closed-loop correction. The normalized reflectance intensity map thus possesses high-fidelity input without distortion or ambient light interference, providing a consistent foundation for subsequent wavelet decoupling and background separation, avoiding the "chain failures" caused by input distortion in traditional methods.
[0017] 2. This invention decouples the normalized reflectance image into high-frequency (texture defects) and low-frequency (morphological defects) components through multi-scale wavelet transform. The low-frequency component is homomorphically filtered to construct a uniform background model, which is then back-projected onto the high-frequency component to perform baseline correction. This decoupling-filtering-correction coupling mechanism preserves both the sharp edges of hairline scratches and the gradual change trend of orange peel texture, overcoming the contradiction that a single pipeline cannot simultaneously handle high and low frequency signals. Through the synergistic effect of wavelet multi-scale decoupling and homomorphic filtering, the physical separation and independent enhancement of high and low frequency defect signals are achieved.
[0018] 3. This invention constructs a collaborative segmentation mask by weighted fusion of a coarse segmentation mask (high frequency) and a shape anomaly mask (low frequency), improving the robustness and completeness of defect localization. The defect signal image generates a coarse segmentation mask (capturing high-frequency abrupt changes) through adaptive local thresholding; the low-frequency component generates a shape anomaly mask (capturing gradually changing boundaries) through Hessian matrix morphological analysis. After weighted fusion, the two are subjected to morphological closing operations to form a collaborative mask with complementary high and low frequency information, effectively filling the gaps in single-channel segmentation and achieving complete coverage of complex defects such as scratches, dents, and ripples.
[0019] 4. This invention achieves physical-level decoupling and information-level complementary fusion of contradictory signals of "high-frequency texture defects" and "low-frequency morphology defects" under the highly reflective curved surface of automobile exterior panels through an end-to-end coupling system of "virtual-physical closed-loop correction → multi-scale signal decoupling → high- and low-frequency dual-channel collaborative segmentation → multi-dimensional geometric decision-making". It completely breaks the "preprocessing dilemma" and "chain failure" dilemma of traditional single processing pipelines, and builds an adaptive, illumination-robust, and defect-complete industrial-grade surface quality inspection paradigm. Finally, it achieves unified detection of all types of defects such as scratches, pits, ripples, and peeling with zero-parameter optimization, pixel-level accuracy, and type traceability. Attached Figure Description
[0020] Figure 1 A schematic flowchart of a machine vision-based method for detecting surface defects in automotive parts, provided in an embodiment of the present invention; Figure 2 A schematic diagram of a machine vision-based automotive parts surface defect detection system provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the overall logic flow of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] Example 1: The example tested a painted rear door panel (approximately 1.2m x 1.0m, a highly reflective curved metallic surface). This panel surface exhibits both sharp, high-frequency texture defects such as hairline scratches and pinholes, and gradually changing low-frequency morphological defects such as orange peel texture and gentle indentations. Traditional single-processing methods cannot address both simultaneously. To achieve reliable and comprehensive detection of both, a machine vision-based method for detecting surface defects in automotive parts was applied. Figure 1 A flowchart illustrating a machine vision-based method for detecting surface defects in automotive parts, as provided in this embodiment of the invention, includes: Load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, render and generate an ideal reflection spectrum; The initial physical reflection map of the outer plate is captured and spatially compared with the ideal reflection map to calculate the optical distortion correction matrix; the optical distortion correction matrix is used to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, and a normalized reflection intensity map is generated. A multi-scale wavelet transform is performed on the normalized reflection intensity map to achieve signal decoupling, decomposing it into a high-frequency component containing high-frequency defect information and a low-frequency component containing low-frequency defect information; homomorphic filtering is applied to the low-frequency component to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency component based on the homogenized background model to generate a defect signal image. The defect signal image is segmented using an adaptive local thresholding algorithm to generate a coarse segmentation defect mask. Local morphological analysis is performed on the low-frequency components to generate a shape anomaly mask. The coarse segmentation defect mask and the shape anomaly mask are fused to generate a co-segmentation mask. Geometric attribute analysis is then performed on the regions within the co-segmentation mask to determine the defects.
[0023] Furthermore, the specific process for obtaining the ideal reflection spectrum is as follows: import the CAD 3D model of the car's outer panel into the virtual rendering environment, set the virtual light source parameters and camera parameters consistent with the actual inspection, and simulate the projection behavior of sinusoidal fringe light on an ideal defect-free surface; use the physical rendering pipeline to simulate the specular reflection and diffuse reflection of light on the curved surface to generate an ideal reflection spectrum without optical distortion and without ambient light interference; the virtual light source parameters include fringe period, wavelength, and projection angle, and the camera parameters include resolution, focal length, and principal point coordinates.
[0024] Specifically, Unreal Engine 5.3 was used as the virtual rendering engine, with path tracing enabled. The CAD model was in STEP format, containing complete surface normals and material properties (specular reflectivity 0.78, roughness 0.04). Light source parameters were set as follows: 32-pixel stripe period, 450nm blue light wavelength, and a projection angle of 30° (relative to the normal). Camera parameters were identical to those on the production line: 4096×3000 resolution, 25mm focal length, and principal point (2048, 1500). The rendering output was a single-channel 32-bit floating-point grayscale image with a dynamic range of 0-65535, stored in uncompressed TIFF format. This image only contains the specular and diffuse components of the sinusoidal striped light, serving as the absolute reference standard for subsequent phase demodulation.
[0025] Furthermore, the specific calculation process of the optical distortion correction matrix is as follows: using an industrial camera to capture the initial physical reflection map of the actual outer panel under standard stripe light projection; performing phase demodulation on the initial physical reflection map and the ideal reflection map respectively, and extracting their respective wrapping phase maps; calculating the phase distortion field between the two phase maps; establishing the mapping relationship between phase distortion and pixel coordinates through polynomial fitting; and obtaining the optical distortion correction matrix by inverse solution.
[0026] Specifically, phase demodulation employs a four-step phase-shifting method, projecting four sinusoidal fringe patterns (I1, I2, I3, I4) with a 90° phase difference, which are simultaneously acquired by the camera. After demodulation, a pyramid-shaped quality-guided phase unfolding algorithm is used, unfolding at four levels to avoid fringe jump errors. The phase distortion field is calculated to sub-pixel accuracy, and the polynomial fitting order is 5th-order bivariate (x... 5 y 0 ~x 0 y 5 The fitted residual RMS is less than 0.02 pixels. The final correction matrix is a two-dimensional offset field (4096×3000×2), storing the inverse distortion offset (dx, dy) per pixel in pixels with a precision of 0.01. This matrix is input to the DLP controller in real time as a binary floating-point array with a generation delay of less than 15ms.
[0027] Furthermore, the specific generation process of the normalized reflection intensity map is as follows: the optical distortion correction matrix is input into the programmable light source controller, the original stripe pattern is subjected to inverse distortion pre-distortion processing to generate a compensated projection pattern; the compensated projection pattern is projected onto the actual outer panel surface in real time through the programmable light source; the compensated reflection image is captured synchronously using an industrial camera; the captured image is subjected to intensity normalization and phase weighted fusion to output the normalized reflection intensity map.
[0028] Specifically, the programmable light source controller has a refresh rate of 60Hz and compensates for pattern generation delay of <15ms. Intensity normalization is achieved by linear stretching to [0,1], and the phase weighting function is based on the inverse of the gradient (0.3 weight for high gradient regions and 0.9 weight for low gradient regions). After weighted fusion, the image signal-to-noise ratio is improved to 4.2 times that of the original image. The output image is an 8-bit grayscale image (0-255), but 32-bit floating-point intermediate results are retained for subsequent wavelet processing.
[0029] By coupling a virtual ideal reflection spectrum with real-time distortion correction, a high-precision normalized reflection intensity map is generated, completely eliminating interference from curved surface geometry and uneven illumination. The spatial phase of the ideal reflection spectrum (virtual CAD rendering) is compared with the initial physical reflection map to generate an optical distortion correction matrix. This matrix then drives a programmable light source to project a compensation pattern, forming a closed-loop correction. The normalized reflection intensity map thus possesses a high-fidelity input free from distortion and ambient light interference, providing a consistent foundation for subsequent wavelet decoupling and background separation, avoiding the "chain failures" caused by input distortion in traditional methods.
[0030] Furthermore, the specific generation process of the defect signal image is as follows: A multi-level discrete wavelet transform is performed on the normalized reflection intensity map to separate the high-frequency and low-frequency components; homomorphic filtering is applied to the low-frequency components to suppress uneven illumination and extract slowly changing background trends, generating a homogenized background model; to eliminate the residual, slowly varying baseline drift introduced by the surface morphology of the original image in the high-frequency components, the homogenized background model is magnified to the same resolution as the high-frequency components through interpolation upsampling to obtain a baseline background image; this baseline background image is subtracted from the high-frequency components to eliminate the interference of the low-frequency background baseline on the high-frequency defect signal; contrast enhancement and noise suppression are performed on the result to output a high signal-to-noise ratio defect signal image containing only defect features.
[0031] Specifically, the wavelet transform is performed using the Daubechies 4 wavelet basis for a 4-level decomposition. High-frequency components are reconstructed from the inverse wavelet transform of the level 1 to 4 detail coefficients, while low-frequency components are approximation coefficients from the level 4. Homomorphic filtering is performed in the logarithmic domain using a Butterworth high-pass filter with a cutoff frequency 0.05 times the Nyquist frequency. The baseline background image is corrected by subtracting pixel-by-pixel amplification of the homogenized background model (i.e., the filtered level 4 approximation coefficients) to the size of the high-frequency components using bilinear interpolation. Adaptive histogram equalization (CLAHE) is then performed after subtraction, with a window size of 64×64. Noise suppression uses a 3×3 median filter, resulting in a 3.8-fold increase in the sharpness of hairline scratches and a 62% increase in contrast in the orange peel texture area of the final defect signal image.
[0032] The normalized reflectance image is decoupled into high-frequency (texture defects) and low-frequency (morphological defects) components through multi-scale wavelet transform. The low-frequency component is homomorphically filtered to construct a uniform background model, which is then back-projected onto the high-frequency component to perform baseline correction. This decoupling-filtering-correction coupling mechanism preserves the sharp edges of hairline scratches while protecting the gradual change trend of orange peel texture. It overcomes the contradiction that a single pipeline cannot simultaneously handle high and low frequency signals. Through the synergistic effect of wavelet multi-scale decoupling and homomorphic filtering, the physical separation and independent enhancement of high and low frequency defect signals are achieved.
[0033] Furthermore, the specific generation process of the collaborative segmentation mask is as follows: applying an adaptive local thresholding algorithm to the defect signal image for pixel-level segmentation to generate a coarse segmentation defect mask; calculating the Hessian matrix of the low-frequency component image, and analyzing the local gray-level morphology based on the eigenvalues of the Hessian matrix, setting a morphological anomaly threshold to generate a shape anomaly mask; performing a weighted fusion of the coarse segmentation defect mask and the shape anomaly mask; performing a morphological closing operation on the fusion result to remove isolated noise and fill in small gaps, finally generating a collaborative segmentation mask.
[0034] The specific generation process of the coarse segmentation defect mask is as follows: Specifically, the Sauvola adaptive thresholding algorithm is used. The local calculation window size is set to 65×65 pixels, which is larger than the typical width of a hairline scratch but smaller than the scale of an orange peel pattern; the sensitivity parameter k is set to 0.2, and the expected dynamic range R of the standard deviation is set to 128. For each pixel in the defect signal image, a local threshold is calculated based on the mean and standard deviation of its 65×65 neighborhood to complete pixel-level segmentation. The specific process for generating the morphological anomaly mask is as follows: 1. The low-frequency component image is denoted as The second-order partial derivatives are calculated using the Sobel operator: ; ; ; Construct the Hessian matrix: ; in, Represents the Hessian matrix; Calculate the Frobenius norm as a criterion for local topographic intensity: ; right Perform global normalization to the range [0,1]: ; in, This represents the value after global normalization; and Distribution represents the current image The minimum and maximum values; ; in, Indicates a shape anomaly mask; Indicates the threshold for morphological abnormalities; 1 represents the defect area, and 0 represents the background area; The morphological anomaly threshold was statistically optimized using 1000 labeled samples. Based on the ROC curve analysis of convex / wavy defects on the normalized Frobenius norm distribution, the maximum point of the Youden exponent (i.e., the maximum value after recall minus false alarm rate) was selected. Recall rate represents the proportion of defects detected; false alarm rate represents the background that is mistakenly identified as a defect. ; in, Indicates the Yoden Index; This represents the true instance (pixels in the statistical sample that are marked with a mask of 1 and labeled as raised / wavy). This indicates a false positive, representing a pixel labeled as background but with a mask value of 1; Indicates a true counterexample (a pixel marked as background with a mask of 0); Indicates a false negative (a pixel marked as a defect but with a mask of 0); The coarse segmentation mask and the anomaly mask are linearly fused with a weighted ratio of 70%:30% to generate a multi-valued fused image. Thresholding is then applied to this fused image, setting all non-zero pixel values (i.e., pixels greater than 0) to 1 and the remaining pixels to 0, resulting in a binary co-segmentation mask. Morphological closing operations are then performed on this binary mask using circular structuring elements with a diameter of 5 pixels. After processing, the mask boundary continuity is improved by 91%, and isolated noise points are reduced by 99.3%.
[0035] A collaborative segmentation mask is constructed by weighted fusion of a coarse segmentation mask (high frequency) and a shape anomaly mask (low frequency), improving the robustness and completeness of defect localization. The defect signal image is used to generate a coarse segmentation mask (capturing high-frequency abrupt changes) through adaptive local thresholding; the low-frequency components are used to generate a shape anomaly mask (capturing gradually changing boundaries) through Hessian matrix morphological analysis. After weighted fusion and morphological closing operations, a collaborative mask with complementary high and low frequency information is formed, effectively filling the gaps in single-channel segmentation and achieving complete coverage of complex defects such as scratches, dents, and ripples.
[0036] Furthermore, the specific process for determining defects is as follows: extract the geometric attributes of each connected region within the collaborative segmentation mask, including area, perimeter, ratio of major axis to minor axis, circularity, and average intensity; construct a classification decision tree based on multiple feature thresholds to determine the defect type of the region; the defect types include scratches, pits, bumps, coating peeling, and foreign object indentations; output the pixel-level mask, bounding box coordinates, type label, and confidence level of the defect.
[0037] Specifically, in this embodiment, 8-connected components are used for extraction, with an area threshold of 50 pixels. Geometric features are calculated as follows: Area: Total number of pixels within the mask; Perimeter: Number of pixels at the boundary; Major-to-minor axis ratio: the ratio of the major axis to the minor axis of the fitted ellipse; Circularity: 4× ×Area / (Perimeter) 2 ); Average intensity: The average gray level of the region in the defect signal image; The decision tree is based on the C4.5 algorithm and trained with 1000 labeled samples. The complete classification logic is as follows: If the ratio of major to minor axis is > 5.2 → scratch (confidence level 0.96); Otherwise, if the area > 1200 → bulge / ripple (confidence level 0.93); Otherwise, if roundness > 0.7 and average strength < 80 → pitting (confidence level 0.91); otherwise, if perimeter / area > 0.15 and average strength > 200 → coating peeling (confidence level 0.89). Otherwise → Foreign object indentation (confidence level 0.94).
[0038] Figure 3 This is a schematic diagram of the overall logic flow of the present invention. Through an end-to-end coupling system of "virtual-physical closed-loop correction → multi-scale signal decoupling → high- and low-frequency dual-channel collaborative segmentation → multi-dimensional geometric decision-making", the physical-level decoupling and information-level complementary fusion of contradictory signals of "high-frequency texture defects" and "low-frequency morphology defects" under the highly reflective curved surface of automobile outer panels are realized. This completely breaks the "preprocessing dilemma" and "chain failure" dilemma of traditional single processing pipelines, and builds an adaptive, illumination-robust, and defect-complete industrial-grade surface quality inspection paradigm. Ultimately, it achieves unified detection of all types of defects such as scratches, pits, ripples, and peeling with zero-parameter optimization, pixel-level accuracy, and type traceability.
[0039] Example 2: The example tested a painted rear door panel (approximately 1.2m x 1.0m, a highly reflective curved metallic surface). This panel surface exhibits both sharp, high-frequency texture defects such as hairline scratches and pinholes, and gradually changing low-frequency morphological defects such as orange peel texture and gentle indentations. Traditional single-processing methods cannot address both simultaneously. To achieve reliable and comprehensive detection of both, a machine vision-based method for detecting surface defects in automotive parts was applied. Figure 2 A schematic diagram of a machine vision-based automotive parts surface defect detection system provided in this embodiment of the invention includes: The ideal reflection spectrum generation module is used to load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, and render and generate the ideal reflection spectrum. The normalized reflection intensity map generation module is used to capture the initial physical reflection map of the outer plate, compare it spatially with the ideal reflection spectrum, calculate the optical distortion correction matrix, and use the optical distortion correction matrix to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, thereby generating a normalized reflection intensity map. The signal decoupling and background separation module performs multi-scale wavelet transform on the normalized reflection intensity map to achieve signal decoupling, decomposing it into a high-frequency component containing high-frequency defect information and a low-frequency component containing low-frequency defect information; homomorphic filtering is applied to the low-frequency component to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency component based on the homogenized background model to generate a defect signal image. The collaborative segmentation module segments the defect signal image using an adaptive local thresholding algorithm to generate a coarse segmentation defect mask; performs local morphological analysis on low-frequency components to generate a shape anomaly mask; and fuses the coarse segmentation defect mask with the shape anomaly mask to generate a collaborative segmentation mask. The defect determination module performs geometric attribute analysis on the region within the collaborative segmentation mask to determine defects.
[0040] Furthermore, the specific process for obtaining the ideal reflection spectrum is as follows: import the CAD 3D model of the car's outer panel into the virtual rendering environment, set the virtual light source parameters and camera parameters consistent with the actual inspection, and simulate the projection behavior of sinusoidal fringe light on an ideal defect-free surface; use the physical rendering pipeline to simulate the specular reflection and diffuse reflection of light on the curved surface to generate an ideal reflection spectrum without optical distortion and without ambient light interference; the virtual light source parameters include fringe period, wavelength, and projection angle, and the camera parameters include resolution, focal length, and principal point coordinates.
[0041] Furthermore, the specific calculation process of the optical distortion correction matrix is as follows: using an industrial camera to capture the initial physical reflection map of the actual outer panel under standard stripe light projection; performing phase demodulation on the initial physical reflection map and the ideal reflection map respectively, and extracting their respective wrapping phase maps; calculating the phase distortion field between the two phase maps; establishing the mapping relationship between phase distortion and pixel coordinates through polynomial fitting; and obtaining the optical distortion correction matrix by inverse solution.
[0042] Furthermore, the specific generation process of the normalized reflection intensity map is as follows: the optical distortion correction matrix is input into the programmable light source controller, the original stripe pattern is subjected to inverse distortion pre-distortion processing to generate a compensated projection pattern; the compensated projection pattern is projected onto the actual outer panel surface in real time through the programmable light source; the compensated reflection image is captured synchronously using an industrial camera; the captured image is subjected to intensity normalization and phase weighted fusion to output the normalized reflection intensity map.
[0043] Furthermore, the specific generation process of the defect signal image is as follows: A multi-level discrete wavelet transform is performed on the normalized reflection intensity map to separate the high-frequency and low-frequency components; homomorphic filtering is applied to the low-frequency components to suppress uneven illumination and extract slowly changing background trends, generating a homogenized background model; to eliminate the residual, slowly varying baseline drift introduced by the surface morphology of the original image in the high-frequency components, the homogenized background model is magnified to the same resolution as the high-frequency components through interpolation upsampling to obtain a baseline background image; this baseline background image is subtracted from the high-frequency components to eliminate the interference of the low-frequency background baseline on the high-frequency defect signal; contrast enhancement and noise suppression are performed on the result to output a high signal-to-noise ratio defect signal image containing only defect features.
[0044] Furthermore, the specific generation process of the collaborative segmentation mask is as follows: applying an adaptive local thresholding algorithm to the defect signal image for pixel-level segmentation to generate a coarse segmentation defect mask; calculating the Hessian matrix of the low-frequency component image, and analyzing the local gray-level morphology based on the eigenvalues of the Hessian matrix, setting a morphological anomaly threshold to generate a shape anomaly mask; performing a weighted fusion of the coarse segmentation defect mask and the shape anomaly mask; performing a morphological closing operation on the fusion result to remove isolated noise and fill in small gaps, finally generating a collaborative segmentation mask.
[0045] Furthermore, the specific process for determining defects is as follows: extract the geometric attributes of each connected region within the collaborative segmentation mask, including area, perimeter, ratio of major axis to minor axis, circularity, and average intensity; construct a classification decision tree based on multiple feature thresholds to determine the defect type of the region; the defect types include scratches, pits, bumps, coating peeling, and foreign object indentations; output the pixel-level mask, bounding box coordinates, type label, and confidence level of the defect.
[0046] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A machine vision-based method for detecting surface defects in automotive parts, characterized in that, include: Load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, render and generate an ideal reflection spectrum; The initial physical reflection map of the outer plate is captured and spatially compared with the ideal reflection map to calculate the optical distortion correction matrix; An optical distortion correction matrix is used to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, thereby generating a normalized reflection intensity map. Multi-scale wavelet transform is performed on the normalized reflection intensity map to achieve signal decoupling, decomposing it into high-frequency components containing high-frequency defect information and low-frequency components containing low-frequency defect information. Homomorphic filtering is applied to the low-frequency components to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency components based on the homogenized background model to generate a defect signal image; The defect signal image is segmented using an adaptive local thresholding algorithm to generate a coarsely segmented defect mask; Local morphological analysis is performed on the low-frequency components to generate a shape anomaly mask; the coarse segmentation defect mask and the shape anomaly mask are fused to generate a co-segmentation mask; and geometric attribute analysis is performed on the regions within the co-segmentation mask to determine defects.
2. The method for detecting surface defects in automotive parts based on machine vision according to claim 1, characterized in that: The specific process for obtaining the ideal reflection spectrum is as follows: import the CAD 3D model of the car's outer panel into the virtual rendering environment, set the virtual light source parameters and camera parameters consistent with the actual inspection, and simulate the projection behavior of sinusoidal fringe light on an ideal defect-free surface; use the physical rendering pipeline to simulate the specular reflection and diffuse reflection of light on the curved surface to generate an ideal reflection spectrum without optical distortion and ambient light interference; the virtual light source parameters include fringe period, wavelength, and projection angle, and the camera parameters include resolution, focal length, and principal point coordinates.
3. The machine vision-based method for detecting surface defects in automotive parts according to claim 1, characterized in that: The specific calculation process of the optical distortion correction matrix is as follows: use an industrial camera to capture the initial physical reflection map of the actual outer panel under standard stripe light projection; perform phase demodulation on the initial physical reflection map and the ideal reflection map respectively, and extract their respective wrapping phase maps; calculate the phase distortion field between the two phase maps; establish the mapping relationship between phase distortion and pixel coordinates through polynomial fitting; and obtain the optical distortion correction matrix by inverse solution.
4. The machine vision-based method for detecting surface defects in automotive parts according to claim 1, characterized in that: The specific process of generating the normalized reflection intensity map is as follows: input the optical distortion correction matrix into the programmable light source controller, perform inverse distortion pre-twisting processing on the original stripe pattern, and generate a compensated projection pattern; project the compensated projection pattern onto the actual outer panel surface in real time through the programmable light source. The compensated reflection image is captured synchronously using an industrial camera; The captured image is normalized in intensity and fused with phase weighting to output a normalized reflectance intensity map.
5. The method for detecting surface defects in automotive parts based on machine vision according to claim 1, characterized in that: The specific process for generating the defect signal image is as follows: A multi-level discrete wavelet transform is performed on the normalized reflectance intensity map to separate high-frequency and low-frequency components. Homomorphic filtering is applied to the low-frequency components to suppress illumination inhomogeneity and extract slowly changing background trends, generating a homogenized background model. To eliminate the residual, slowly varying baseline drift introduced by the surface morphology of the original image in the high-frequency components, the homogenized background model is upsampled to the same resolution as the high-frequency components to obtain a baseline background map. This baseline background map is subtracted from the high-frequency components to eliminate the interference of the low-frequency background baseline on the high-frequency defect signal. The results are enhanced for contrast and suppressed for noise, and the output is a high signal-to-noise ratio defect signal image containing only defect features.
6. The method for detecting surface defects in automotive parts based on machine vision according to claim 1, characterized in that: The specific generation process of the collaborative segmentation mask is as follows: applying an adaptive local threshold algorithm to the defect signal image for pixel-level segmentation to generate a coarse segmentation defect mask; The Hessian matrix of the low-frequency component image is calculated, and the local gray-level morphology is analyzed based on the eigenvalues of the Hessian matrix. A morphological anomaly threshold is set to generate a morphological anomaly mask. The coarse segmentation defect mask and the morphological anomaly mask are weighted and fused; morphological closing operation is performed on the fusion result to remove isolated noise and fill small gaps, and finally a collaborative segmentation mask is generated.
7. The machine vision-based method for detecting surface defects in automotive parts according to claim 1, characterized in that: The specific process for determining defects is as follows: extract the geometric attributes of each connected region within the collaborative segmentation mask, including area, perimeter, ratio of major axis to minor axis, circularity, and average intensity; construct a classification decision tree based on multiple feature thresholds to determine the defect type of the region; the defect types include scratches, pits, bumps, coating peeling, and foreign object indentations; output the pixel-level mask, bounding box coordinates, type label, and confidence level of the defect.
8. A machine vision-based system for detecting surface defects in automotive parts, the system being used to execute the machine vision-based method for detecting surface defects in automotive parts as described in any one of claims 1 to 7, characterized in that, include: The ideal reflection spectrum generation module is used to load the CAD 3D model of the car's outer panel, simulate the projection of striped light onto the model in a virtual environment, and render and generate the ideal reflection spectrum. The normalized reflection intensity map generation module is used to capture the initial physical reflection map of the outer plate, compare it spatially with the ideal reflection map, and calculate the optical distortion correction matrix. An optical distortion correction matrix is used to drive a programmable light source to project a compensated projection pattern that has been corrected in real time, thereby generating a normalized reflection intensity map. The signal decoupling and background separation module performs multi-scale wavelet transform on the normalized reflection intensity map to achieve signal decoupling, decomposing it into high-frequency components containing high-frequency defect information and low-frequency components containing low-frequency defect information. Homomorphic filtering is applied to the low-frequency components to calculate and separate a homogenized background model; baseline correction is performed on the high-frequency components based on the homogenized background model to generate a defect signal image; The collaborative segmentation module segments the defect signal image using an adaptive local thresholding algorithm to generate a coarsely segmented defect mask. Local morphological analysis is performed on the low-frequency components to generate a morphological anomaly mask; the coarse segmentation defect mask and the morphological anomaly mask are fused to generate a co-segmentation mask. The defect determination module performs geometric attribute analysis on the region within the collaborative segmentation mask to determine defects.
Citation Information
Cited By
Mobile phone appearance multi-angle automatic detection system and method based on multi-surface reflection structure
CN122016820A
Machine vision-based mobile phone lens mount quality detection system
CN122199537A