A visual detection method for pinhole defects of an automobile exterior part clear coating layer

By setting up a color camera and white light illumination device at the automotive exterior parts inspection station, and combining standard whiteboard calibration and local coupling relationship analysis, the problem of stable identification of pinhole defects in the clear coat coating of automotive exterior parts was solved, achieving efficient and reliable inspection results and quantitative indicators.

CN122175922AInactive Publication Date: 2026-06-09JIANGYIN DAODA AUTO DECORATIONS CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGYIN DAODA AUTO DECORATIONS CO LTD
Filing Date
2026-03-06
Publication Date
2026-06-09
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies struggle to reliably identify pinhole defects in clear coat coatings for automotive exterior parts, especially under strong reflective surfaces, curved surfaces, and complex backgrounds. This leads to inconsistent test results and makes it difficult to meet the requirements of reproducibility, traceability, and quantification for production lines.

Method used

By setting up a color camera and white light illumination device at the inspection station, the proportional relationship between pixels and physical size is established. Color channel normalization is achieved using standard whiteboard calibration, luminance and chrominance components are constructed, and the coupling relationship between luminance and chrominance in the local neighborhood is combined to calculate the coupling residual and normalization score. Threshold segmentation and connected component analysis are then performed to screen out pinhole defects.

Benefits of technology

It achieves stable identification of pinhole defects under different conditions, reduces the false detection rate, provides quantifiable detection records and pixel-level defect masks, improves the versatility and maintainability of the detection system, and adapts to detection standards for different cameras and exterior parts sizes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122175922A_ABST
    Figure CN122175922A_ABST
Patent Text Reader

Abstract

The present application relates to the field of machine vision and industrial optical detection technology, and discloses a kind of visual detection methods for pinhole defects of automobile exterior trim varnish coating.In the detection station, color camera and white light illuminating device are arranged above, image covering the varnish area of exterior trim is collected according to production rhythm, and pixel geometric parameter is calibrated; standard white board is used to count each color channel normalization coefficient, workpiece image channel is normalized, and workpiece effective detection area is limited; based on the normalization data, brightness and color component are calculated for pixel, the relationship between brightness and color is counted, coupling model is established, and coupling break score is calculated; score field is adaptively threshold segmented, pinhole defect area is screened in combination with connected domain and pinhole geometric scale condition, and quantity characteristic is quantified, pinhole defect detection record and pixel-level defect mask are generated, so as to convert image into calculation data, distinguish pinhole and interference, and provide basis for quality judgment and control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of machine vision and industrial optical inspection technology, specifically a visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts. Background Technology

[0002] Clear coats on automotive exterior parts enhance gloss and weather resistance, but pinhole-like micro-defects are prone to occur during spraying, leveling, and curing. Pinholes typically manifest as localized brightness anomalies, color shifts, or abrupt changes in reflectivity; they are small in size, have unstable contrast, and are more difficult to reliably identify against strong reflective surfaces, curved surfaces, textures, or backgrounds with color gradients. Current production sites often employ manual visual inspection or camera-based visual inspection methods. Manual visual inspection is affected by subjective experience, fatigue, and lighting conditions, resulting in insufficient repeatability and consistency. Visual inspection also involves various implementation approaches, such as grayscale segmentation based on fixed thresholds, suspected defect extraction based on edge / morphological operators, or filtering images followed by region connectivity analysis. Some solutions utilize a single brightness channel or a single color channel for judgment, or set thresholds using global statistics to obtain candidate defect regions.

[0003] However, specular reflections and stray light from the varnish surface can cause significant differences in the appearance of the same defect at different locations, batches, or angles, making it difficult to standardize the threshold. Gradual brightness variations, shadows, and highlights caused by curved surfaces are easily misjudged as defects. Color differences in the coating, substrate patterns, and particle noise can lead to missed or over-detection issues in solutions relying solely on single-channel grayscale or simple filtering. Furthermore, some existing methods do not adequately isolate the effective detection area from the background area during local statistics, causing the statistics at the boundary to be influenced by background pixels. When local brightness variations are insufficient, judgments based on fitting or difference may become unstable or undefinable. In the defect connectivity formation and size constraint screening stages, if adjacency rules, scale conversions, and abnormal branch handling are not clearly defined, inconsistent detection results can easily occur, making it difficult to meet the production line's requirements for reproducible, traceable, and quantifiable output.

[0004] Therefore, this study aims to propose a visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts. Starting from the production line inspection station, the method standardizes the arrangement and exposure conditions of the camera and white light illumination device, establishing a proportional relationship between pixels and physical dimensions. Standard white board calibration is used to normalize different color channels, ensuring comparability of subsequent images across batches and time periods. Based on this, the clear coat surface image of the workpiece is normalized and its effective area is defined, shielding against background interference. Subsequently, instead of simply using single-channel grayscale, the method constructs luminance and chromaticity components, utilizing the relationship between luminance and chromaticity within a local neighborhood to characterize the optical properties of a normal clear coat surface. By fitting local linear coupling relationships, calculating coupling residuals, and normalizing scores, pixels deviating from this normal coupling pattern are identified. Summary of the Invention

[0005] This invention provides a visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts, which helps to solve the problems mentioned in the background art.

[0006] This invention provides the following technical solution: a visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts, comprising:

[0007] A color camera and a white light illumination device are set up above the inspection station to acquire images covering the clear coat area of ​​the target exterior parts and to establish the geometric parameters of the pixels in the images.

[0008] Standard whiteboard images were acquired using the same color camera and white light illumination device as those used for workpiece inspection. Statistical analysis was performed on the standard whiteboard images to calculate the normalization coefficients for the red, green, and blue color channels.

[0009] Images of the workpiece's clear coat surface are acquired according to the production rhythm. Based on the normalization coefficients of each color channel obtained from the standard white board calibration, the color channels of the workpiece's clear coat surface image are normalized, and the effective detection area of ​​the workpiece is set.

[0010] Based on the normalized color channel data, the pixel luminance and color components are calculated to construct the original descriptive quantities used to describe the color and luminance state of each pixel.

[0011] Within the effective detection area of ​​the workpiece, a square neighborhood is constructed with each pixel as the center. Statistical calculations are performed on the brightness and color components within the neighborhood to estimate the local coupling relationship parameters between the brightness and color components.

[0012] Based on the slope and intercept parameters estimated from the local color and brightness coupling relationship, as well as the actual color components of each pixel, the coupling residual amplitude between color and brightness is calculated. The coupling residual amplitude and brightness are statistically analyzed within a square neighborhood to obtain the coupling breakage score for each pixel.

[0013] Global statistics are performed on the coupling breakage score within the effective detection area of ​​the workpiece, a segmentation threshold is constructed, threshold segmentation and connected component analysis are performed on the score field, and connected components of pinhole defects that meet the geometric scale conditions of pinholes are selected.

[0014] The number of pinhole defects is statistically analyzed, the intensity is quantified, and the area is converted to form a pinhole defect detection record and a pixel-level defect mask.

[0015] Optionally, the step of setting up a color camera and a white light illumination device above the inspection station to acquire an image covering the clear coat area of ​​the target exterior part and establishing the geometric parameters of the pixels in the image specifically includes:

[0016] A color camera is set up above the inspection station. The position and orientation of the color camera are adjusted so that the field of view covers the clear varnish area of ​​the target exterior part.

[0017] A white light illumination device is set within the field of view of the color camera, and the relative position and illumination angle between the illumination device and the color camera are fixed.

[0018] Arrange the workpiece conveying and dwell time according to the production rhythm, so that the workpiece remains stationary during the color camera exposure time;

[0019] For each frame of image captured by the color camera, an image pixel index set is established. The position index of each pixel is represented as an ordered pair of integers consisting of row index and column index, where the row index increases vertically from the top left corner of the image matrix and the column index increases horizontally from the top left corner of the image matrix.

[0020] A calibration plate with a known width that covers the boundary of the field of view is placed in the width direction of the color camera's field of view. The actual physical width of the calibration plate is obtained in millimeters.

[0021] Acquire a calibration image containing the calibration board, and read the width of the calibration board in the calibration image (in pixels).

[0022] Divide the actual physical width of the calibration board by the corresponding number of width pixels to calculate the imaging scale coefficient. The imaging scale coefficient characterizes the size of a single pixel in the physical space in the image space.

[0023] The maximum equivalent diameter of the pinhole defect is obtained according to the inspection standard. The maximum equivalent diameter of the pinhole defect is divided by the imaging scale coefficient to obtain the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale. The upper limit value of the equivalent diameter of the pinhole defect at the pixel scale is rounded down, multiplied by two, and then added to obtain the side length of the neighborhood square window. A square neighborhood is constructed with each pixel in the image as the center and the side length of the neighborhood square window as the side length. The absolute values ​​of the difference between the row index of any pixel in the neighborhood and the row index of the center pixel, and the difference between the column index of any pixel in the neighborhood and the column index of the center pixel, do not exceed half of the side length of the neighborhood square window minus one. The geometric size constraint of the connected region of the pinhole defect is defined as the pinhole geometric scale condition. The pinhole geometric scale condition limits the equivalent diameter of the connected region of the pinhole defect to not be greater than the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale.

[0024] Optionally, the step of acquiring standard whiteboard images under the same configuration of a color camera and white light illumination device as for workpiece inspection, and performing statistical analysis on the standard whiteboard images to calculate the normalization coefficients of the red, green, and blue color channels, specifically includes:

[0025] With the same color camera and white light illumination device as for workpiece inspection, a standard white board is placed within the field of view of the color camera to acquire images of the standard white board;

[0026] For each pixel in the standard whiteboard image, the gray values ​​of the red, green and blue channels are obtained respectively, forming a set of gray values ​​for the red channel, a set of gray values ​​for the green channel and a set of gray values ​​for the blue channel.

[0027] The median operation is performed on the red channel grayscale sample set. The samples are then sorted by their grayscale values. When the number of samples is odd, the grayscale value at the middle position after sorting is selected as the red channel calibration benchmark value. When the number of samples is even, the arithmetic mean of the two middle grayscale values ​​after sorting is selected as the red channel calibration benchmark value. The same sorting and median operation method is applied to the green channel grayscale sample set and the blue channel grayscale sample set to obtain the green channel calibration benchmark value and the blue channel calibration benchmark value, respectively.

[0028] The red channel normalization coefficient is constructed based on the red channel calibration reference value. When the red channel calibration reference value is greater than zero, the red channel normalization coefficient is obtained through ratio calculation. When the red channel calibration reference value is equal to zero, the red channel normalization coefficient is set to one. The green channel normalization coefficient is set to one. The blue channel normalization coefficient is constructed based on the blue channel calibration reference value. When the blue channel calibration reference value is greater than zero, the blue channel normalization coefficient is obtained through ratio calculation. When the blue channel calibration reference value is equal to zero, the blue channel normalization coefficient is set to one.

[0029] Optionally, the step of acquiring images of the workpiece's clear coat surface according to the production cycle, performing normalization processing on each color channel of the workpiece's clear coat surface image based on the normalization coefficients of each color channel obtained from standard white board calibration, and setting the effective detection area of ​​the workpiece specifically includes:

[0030] At the inspection station, images of the workpiece varnish surface are collected sequentially according to the production rhythm, ensuring that each frame of the workpiece varnish surface image is consistent with the standard whiteboard image in terms of the configuration of the color camera and white light illumination device.

[0031] For each pixel in each frame of the workpiece varnish surface image, the original grayscale values ​​of the red channel, green channel and blue channel are obtained respectively. The range of the original grayscale values ​​is the preset digital grayscale range.

[0032] Multiply the original grayscale value of the red channel by the normalization coefficient of the red channel to obtain the normalized grayscale value of the red channel; multiply the original grayscale value of the green channel by the normalization coefficient of the green channel to obtain the normalized grayscale value of the green channel; multiply the original grayscale value of the blue channel by the normalization coefficient of the blue channel to obtain the normalized grayscale value of the blue channel.

[0033] When the offline configuration file of the detection system loads a binary mask of the effective detection area of ​​the workpiece and there is at least one pixel in the binary mask with a value of 1, the set of pixel indices with a value of 1 in the binary mask is set as the set of pixels of the effective detection area of ​​the workpiece; otherwise, the set of image pixel indices is set as the set of pixels of the effective detection area of ​​the workpiece.

[0034] Optionally, the step of calculating pixel luminance and color components based on normalized color channel data to construct an original descriptive quantity for describing the color and luminance state of each pixel specifically includes:

[0035] For each pixel in the image pixel index set, a weighted operation is performed based on the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel. The normalized gray value of the red channel is multiplied by 30, the normalized gray value of the green channel is multiplied by 59, and the normalized gray value of the blue channel is multiplied by 11. The three products are added together and then divided by 100 to obtain the brightness of the current pixel.

[0036] For each pixel in the image pixel index set, add the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel to obtain the three-channel sum of the current pixel;

[0037] For each pixel in the image pixel index set, the red channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the red component of the current pixel; the green channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the green component of the current pixel.

[0038] Optionally, within the effective detection area of ​​the workpiece, a square neighborhood is constructed centered on each pixel, and statistical calculations are performed on the luminance and color components within the neighborhood to estimate the local coupling relationship parameters between the luminance and color components. Specifically, this includes:

[0039] For each pixel in the effective detection area pixel set of the workpiece, count the number of effective pixels in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece to obtain the number of effective pixels in the neighborhood of the current pixel;

[0040] For each pixel in the effective detection area pixel set of the workpiece, the brightness values ​​of all pixels in its neighborhood intersection are summed to obtain the first-order brightness sum, and the brightness values ​​of all pixels in its neighborhood are squared and then summed to obtain the squared brightness sum.

[0041] For each pixel in the effective detection area pixel set of the workpiece, in its neighborhood intersection, the redness components of all pixels in the neighborhood are accumulated to obtain the redness sum, and the brightness and redness components of all pixels in the neighborhood are multiplied to obtain the brightness and redness product sum.

[0042] For each pixel in the effective detection area pixel set of the workpiece, the greenness components of all pixels in the neighborhood intersection are summed to obtain the greenness sum, and the brightness and greenness components of all pixels in the neighborhood are multiplied to obtain the brightness and greenness product sum.

[0043] For each pixel in the effective detection area pixel set of the workpiece, the discriminant is calculated based on the number of effective neighboring pixels, the first-order sum of brightness, and the sum of squares of brightness of the current pixel. The product of the number of effective neighboring pixels and the sum of squares of brightness is subtracted from the square of the first-order sum of brightness to obtain the discrete discriminant of the brightness sample of the current pixel.

[0044] When the discrete discriminant of the brightness sample of a certain pixel is greater than zero, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of redness, and the sum of the products of brightness and redness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the redness component are calculated. At the same time, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of greenness, and the sum of the products of brightness and greenness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the greenness component are calculated.

[0045] When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the redness component is set to zero, and the neighborhood average value of the redness component is used as the corresponding intercept parameter.

[0046] When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the greenness component is set to zero, and the neighborhood average value of the greenness component is used as the corresponding intercept parameter.

[0047] Optionally, the step of calculating the coupling residual amplitude between color and brightness based on the slope and intercept parameters estimated from the local color-brightness coupling relationship and the actual color component of each pixel, and statistically analyzing the coupling residual amplitude and brightness within a square neighborhood to obtain the coupling breakage score for each pixel, specifically includes:

[0048] For each pixel in the pixel set of the effective detection area of ​​the workpiece, a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the red component to obtain the predicted red component of the current pixel; a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the green component to obtain the predicted green component of the current pixel.

[0049] For each pixel in the effective detection area pixel set of the workpiece, subtract the predicted red component of the current pixel from the actual red component and square it; subtract the predicted green component of the current pixel from the actual green component and square it; add the previous squared result to the next squared result to obtain the coupling residual amplitude of the current pixel.

[0050] For each pixel in the effective detection area pixel set of the workpiece, in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece, sort the coupling residual magnitude of all pixels in the neighborhood, and use median operation to obtain the median of the neighborhood residual of the current pixel;

[0051] For each pixel in the effective detection area pixel set of the workpiece, sort the brightness of all pixels in its neighborhood intersection, and use median calculation to obtain the median brightness of the neighborhood of the current pixel.

[0052] For each pixel in the effective detection area pixel set of the workpiece, the coupling residual amplitude of the current pixel is used as the numerator, and the sum of the median of the neighborhood residual of the current pixel and the preset minimum positive number is used as the denominator to perform a division operation to obtain the first normalization factor; at the same time, the result of adding one to the brightness of the current pixel is used as the numerator, and the result of adding one to the brightness median of the neighborhood of the current pixel is used as the denominator to perform a division operation to obtain the second normalization factor.

[0053] For each pixel in the effective detection area pixel set of the workpiece, the first normalization factor and the second normalization factor are multiplied to obtain the coupling breakage score of the current pixel. The coupling breakage scores of all pixels in the effective detection area pixel set of the workpiece are then summarized to form the score field of the entire image.

[0054] Optionally, the step of performing global statistics on coupling breakage scores within the effective detection area of ​​the workpiece, constructing a segmentation threshold, performing threshold segmentation and connected component analysis on the score field, and filtering out connected components of pinhole defects that meet the pinhole geometric scale conditions specifically includes:

[0055] In the pixel set of the effective detection area of ​​the workpiece, the coupling breakage scores of all pixels are sorted, and the global median of the coupling breakage scores is obtained by median calculation.

[0056] In the pixel set of the effective detection area of ​​the workpiece, the absolute value of the difference between the coupling breakage score of each pixel and the global median of the coupling breakage score is calculated, and all absolute values ​​are sorted. The median absolute deviation of the coupling breakage score is obtained by median operation.

[0057] Multiply the median absolute deviation of the coupling break score by six, and add the resulting product to the global median of the coupling break score to construct a segmentation threshold for the score field.

[0058] Pixels with coupling breakage scores greater than the constructed segmentation threshold are selected from the pixel set of the effective detection area of ​​the workpiece to form a candidate pixel set;

[0059] The connectivity analysis is performed on the candidate pixel set using the eight-neighbor connectivity criterion. For any two pixels in the candidate pixel set, they are considered to be adjacent when the maximum distance between them in the row index direction and the column index direction is equal to one. The candidate pixels are grouped according to the adjacency relationship to obtain multiple connected components, and each connected component corresponds to a pixel index set.

[0060] For each connected component, the pixel area of ​​the connected component is obtained by counting each pixel in the corresponding pixel index set and summing the results.

[0061] For each connected component, substitute its pixel area into the relationship between the area and diameter of the circle, perform a square root multiplication operation to obtain the equivalent diameter of the current connected component;

[0062] Based on the pre-defined upper limit of the equivalent diameter of pinhole defects at the pixel scale, connected components with an equivalent diameter greater than zero and not greater than the upper limit of the equivalent diameter of pinhole defects at the pixel scale are selected to form a set of connected components of pinhole defects.

[0063] Optionally, the step of performing quantity statistics, intensity quantization, and area conversion on the connected regions of pinhole defects to form pinhole defect detection records and pixel-level defect masks specifically includes:

[0064] The number of pinhole defects is obtained by counting the number of connected components in the set of connected components of pinhole defects.

[0065] When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, obtain the coupling breakage score of all pixels in the current connected component on the corresponding pixel index set, sort the coupling breakage scores of all pixels in the connected component according to the numerical size and use the median operation to obtain the strength index of the current connected component.

[0066] When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, the pixel area of ​​the current connected component is multiplied by the square of the imaging scale coefficient to obtain the physical area corresponding to the current connected component, in square millimeters.

[0067] When the set of connected regions of pinhole defects is not empty, a pinhole defect detection record for the workpiece is formed by combining the workpiece identification information, the number of pinhole defects, and the physical area, strength index and equivalent diameter of each connected region of pinhole defects.

[0068] Based on the set of connected components of pinhole defects, a pixel-level defect mask is constructed on the set of image pixel indices. Pixels belonging to any set of connected component pixel indices of pinhole defects are assigned a value of one in the defect mask, and pixels not belonging to any set of connected component pixel indices of pinhole defects are assigned a value of zero in the defect mask.

[0069] When the set of connected components of pinhole defects is empty, the number of pinhole defects is set to zero, and all pixels in the pixel-level defect mask are assigned a value of zero.

[0070] The present invention has the following beneficial effects:

[0071] 1. By placing a calibration plate with a known actual width along the field of view width and combining it with the pixel width of the calibration plate in the calibration image, the size of each pixel in physical space is calculated. Further, in conjunction with production cycle scheduling, the workpiece is kept stationary during exposure, ensuring image clarity and freedom from motion blur from the source, and guaranteeing that all subsequent area and diameter parameters can be directly converted into physical quantities in millimeters. This solution provides a rigorous geometric calibration process, enabling the inspection standard for the maximum equivalent diameter of pinholes to be directly mapped to the image scale, avoiding the inconsistency issues caused by relying solely on pixel count, and providing a physical basis for constructing subsequent pinhole geometric scale conditions. This design facilitates the transfer of the same inspection standard across different cameras, installation heights, and exterior component sizes, solving the practical dilemma of "re-measuring the threshold when changing a production line" in traditional solutions, and improving the versatility and maintainability of the inspection system.

[0072] 2. By acquiring standard whiteboard images under camera and lighting configurations identical to those used for workpiece inspection, full-image statistical analysis of pixel values ​​for the three color channels is performed. The median grayscale value for each channel is calculated, and channel normalization coefficients are constructed based on this median value. Firstly, a standard whiteboard is used as a unified reference, integrating factors such as illumination spectrum, camera response curve, and lens vignetting into a calibration benchmark for each color channel. Secondly, the median value is used instead of a simple average, significantly reducing the impact of local blemishes or noise on the calibration results. The normalization coefficients, based on the whiteboard image, ensure that subsequent workpiece images, even those from different batches, under different lighting conditions, or with slight occlusion, can still be restored to a unified color and brightness benchmark through the same normalization method. This scheme establishes a repeatable color calibration process through a physical reference board, avoiding excessive assumptions about the workpiece's inherent distribution. It provides a more stable color benchmark, especially when the background color is complex and contains metallic effects or high-reflectivity coatings such as pearl paint. This directly solves the problems of color drift and threshold failure caused by lighting aging, camera replacement, and dust contamination in actual production, allowing subsequent coupled models to be built on uniformly normalized data.

[0073] 3. After acquiring the workpiece image, the original values ​​of the three color channels for each pixel are multiplied by the normalization coefficients obtained in the previous step to obtain the normalized workpiece image. Simultaneously, a binary mask for the effective detection area of ​​the workpiece is introduced to limit the detection range to the clear coat area or the area of ​​interest. Combining color channel normalization and area selection into a unified process: on the one hand, normalization eliminates differences in lighting and equipment, making subsequent brightness and chromaticity calculations comparable; on the other hand, the offline-configured binary mask excludes logos, holes, borders, clamping areas, or other structures that do not need to be detected from the effective detection area of ​​the workpiece, reducing the generation of a large number of irrelevant connected components. This mask-based effective area definition can accurately adapt to the shape contours and assembly structures of different exterior parts, avoiding the misidentification of edge reflections, clamping mechanisms, nameplates, and other areas as defect analysis objects, thus reducing the false detection rate. Especially in high-cycle production line scenarios where workpiece posture changes are small, the offline-configured mask method is low-cost and highly stable.

[0074] 4. Based on the normalized three-channel data, a luminance value and two dimensionless chromaticity components are constructed for each pixel. The luminance value is obtained by weighted summation of the three color channels with different weights, and the chromaticity components are obtained by comparing the value of a certain color channel with the sum of all channels plus one. On the one hand, the construction of the luminance value fully considers the differences in human eye sensitivity to different color channels, making the luminance value closer to perceived brightness and helping to distinguish between real brightness changes and noise. On the other hand, the chromaticity components use a normalized form, which is equivalent to comparing the relative proportions between channels within each pixel, rather than being sensitive to absolute intensity. In this way, the chromaticity components remain relatively stable when the overall brightness fluctuates. This scheme, by using the luminance value and two independent chromaticity components simultaneously, fully characterizes the brightness and color relationship of pixels, enabling the subsequent coupled model to capture the "constraint relationship between brightness and color within the normal clear varnish area". Pinhole defects typically manifest as localized exposure of the substrate or bubbles, disrupting the relationship between brightness and background color. By describing this combination of brightness and chromaticity, potential defects can be identified in areas with similar brightness but abnormal color ratios, solving the practical problem that traditional single-channel thresholding methods cannot distinguish between color differences and pinholes.

[0075] 5. Within the effective detection area of ​​the workpiece, for each pixel, the first-order sum and square sum of brightness, the sum of chromaticity components, and the sum of the products of brightness and chromaticity are statistically analyzed in a square neighborhood. Based on this, a discrete discriminant for the brightness sample is constructed. When the discriminant is greater than zero, the slope and intercept between brightness and each chromaticity component are estimated using linear regression. When the discriminant is less than or equal to zero, the method degenerates to using the neighborhood average chromaticity and setting the slope to zero. Locally within each pixel, the linear coupling relationship between brightness and color is automatically learned using the set of neighboring pixels as samples, rather than assuming a uniform brightness-color function relationship across the entire image. By determining whether the brightness sample has sufficient dispersion in the neighborhood, forced linear fitting in areas with minimal brightness variation can be avoided, thus reducing unstable regression results. This scheme allows for automatic adjustment of model parameters based on local texture, coating thickness, and lighting conditions at different locations, better reflecting the non-uniformity of the actual coating surface. In industrial settings, exterior components often have curved surfaces, broken lines, and local decorative textures, resulting in significant differences in the reflectivity of different areas in the same image. Local adaptive fitting enables the system to more accurately distinguish between normal geometric lighting changes and abnormal coating defects.

[0076] 6. Based on the existing local coupling model, the difference between the actual and predicted chromaticity of each pixel is calculated as the residual magnitude. Then, the median of the residual and luminance are calculated separately in the neighborhood. The coupling breakage score is obtained by multiplying the residual by the median residual and the luminance by the median luminance. This score considers three layers of information: first, the degree to which the pixel violates the local linear coupling relationship, i.e., the residual magnitude; second, the relative amplification of this residual relative to the surrounding residual distribution, achieved by comparing it with the median residual of the neighborhood; and third, the relative strength of the luminance itself, which avoids falsely high residuals due to noise in very dark or very bright areas by comparing it with the median luminance of the neighborhood. Using the median instead of the average value makes it difficult for extreme points and outliers to dominate the statistics, enhancing the sensitivity to local anomalies and robustness to background noise. The coupling breakage score constructed by this scheme is essentially a comprehensive anomaly index that takes into account local contrast, color anomalies, and luminance background, and can accurately highlight pinhole areas even with interference from highlights, shadows, and surface textures. For the production site, this robust score reduces false alarms caused by local reflections and spray gun transition zones, and solves the persistent problem in the existing system where background textures and reflections are mistaken for pinholes.

[0077] 7. Within the effective detection area pixel set of the workpiece, the global median and median absolute deviation are statistically analyzed for the coupling breakage scores of all pixels. A segmentation threshold adapted to the overall distribution of the current image is constructed. Threshold segmentation is then performed on the score field to obtain a candidate pixel set. Connected regions are grouped using the eight-neighborhood connectivity criterion. The pixel area and equivalent diameter of each connected region are further calculated. Finally, the set of connected regions meeting the geometric conditions for pinhole defects is selected based on the upper limit of the equivalent diameter of the pinhole defect. Robust statistics and geometric constraints are combined for defect candidate region selection: the threshold constructed using the global median and median absolute deviation automatically adapts to the overall noise level of different batches and workpieces without manual threshold adjustment; the equivalent diameter constraint precisely controls the defect size range, treating excessively large areas as other types of defects or contamination, and excessively small areas as noise, thus corresponding to the specific defect type of pinhole. The threshold of this scheme varies with the statistical characteristics of the image, making it more suitable for handling differences in lighting and background color in the production line. Simultaneously, the introduction of the concept of an equivalent diameter of a circle allows for comparison of the size of connected regions of different shapes on a uniform scale, better reflecting the physical approximate circular or localized point-like characteristics of pinholes. This design effectively reduces the misjudgment of large-area coating runs and contaminants as pinholes, making the detection results more aligned with process quality concerns.

[0078] 8. After obtaining the set of connected components for pinhole defects, the total number of pinholes is counted. The median value of the coupling breakage score within each connected component is taken as the intensity index. Then, the pixel area is converted into physical area using the imaging scaling factor, forming a detection record containing workpiece identification information, the number of pinholes, and the physical area, intensity index, and equivalent diameter of each pinhole defect. Simultaneously, a pixel-level defect mask is generated on the entire image. This not only provides a determination of the presence or absence of pinholes but also offers multi-dimensional quantifiable indicators: the number can be used to determine whether the number of pinholes exceeds the process allowance; the area and equivalent diameter can be directly compared with the size thresholds in coating standards; the intensity index reflects the degree of chromaticity and brightness coupling breakage and can serve as a quantitative reference for severity. The use of the median intensity avoids the impact of excessively high or low scores from a single extreme pixel on the overall evaluation, making the indicators more stable and reliable. This solution, through the combination of detection records and pixel-level defect masks, not only meets the needs of quality engineers for statistical analysis and trend monitoring but also provides precise location-level information for automated rework, robotic repainting, or visual traceability. Attached Figure Description

[0079] Figure 1 This is a schematic diagram of the process of the present invention. Detailed Implementation

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

[0081] Example, refer to Figure 1 A visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts, comprising:

[0082] A color camera and a white light illumination device are set up above the inspection station to acquire images covering the clear coat area of ​​the target exterior parts and to establish the geometric parameters of the pixels in the images.

[0083] Standard whiteboard images were acquired using the same color camera and white light illumination device as those used for workpiece inspection. Statistical analysis was performed on the standard whiteboard images to calculate the normalization coefficients for the red, green, and blue color channels.

[0084] Images of the workpiece's clear coat surface are acquired according to the production rhythm. Based on the normalization coefficients of each color channel obtained from the standard white board calibration, the color channels of the workpiece's clear coat surface image are normalized, and the effective detection area of ​​the workpiece is set.

[0085] Based on the normalized color channel data, the pixel luminance and color components are calculated to construct the original descriptive quantities used to describe the color and luminance state of each pixel.

[0086] Within the effective detection area of ​​the workpiece, a square neighborhood is constructed with each pixel as the center. Statistical calculations are performed on the brightness and color components within the neighborhood to estimate the local coupling relationship parameters between the brightness and color components.

[0087] Based on the slope and intercept parameters estimated from the local color and brightness coupling relationship, as well as the actual color components of each pixel, the coupling residual amplitude between color and brightness is calculated. The coupling residual amplitude and brightness are statistically analyzed within a square neighborhood to obtain the coupling breakage score for each pixel.

[0088] Global statistics are performed on the coupling breakage score within the effective detection area of ​​the workpiece, a segmentation threshold is constructed, threshold segmentation and connected component analysis are performed on the score field, and connected components of pinhole defects that meet the geometric scale conditions of pinholes are selected.

[0089] The number of pinhole defects is statistically analyzed, the intensity is quantified, and the area is converted to form a pinhole defect detection record and a pixel-level defect mask.

[0090] By setting up a color camera and white light illumination device at the inspection station and steadily acquiring images of the varnish-covered area according to the production rhythm, the physical scene of the production site is accurately converted into calculable image data, solving the problems of instability, visual fatigue, and slow pace of manual visual inspection. By acquiring standard whiteboard images under the same configuration as the workpiece inspection and calculating the color channel normalization coefficients, and then performing channel normalization processing on the workpiece image, the color shift problem caused by changes in time, equipment, and lighting conditions is solved, providing a unified data benchmark for subsequent algorithms. By calculating the luminance and color components based on the normalized channels, and constructing a square neighborhood centered on the pixel within the effective inspection area of ​​the workpiece, the relationship between luminance and color within the neighborhood is statistically analyzed to establish a local coupling model. Then, the residual is calculated based on this model and the actual color components and converted into a coupling breakdown score. This solves the problem that traditional methods only consider luminance or simple color differences, making it difficult to distinguish between real pinholes and interference such as surface texture and highlights. Finally, by performing global statistics, adaptive threshold segmentation, and connected component analysis on the scoring field, and combining the geometric scale conditions of pinholes with steps such as quantity statistics, intensity quantification, and area conversion, pixel-level marking of pinhole locations was achieved, and quantifiable indicators such as quantity, intensity, and area were formed, providing directly usable data for quality judgment and process control.

[0091] The step of setting up a color camera and a white light illumination device above the inspection station to acquire an image covering the clear coat area of ​​the target exterior part and establishing the geometric parameters of the pixels in the image specifically includes:

[0092] A color camera is set up above the inspection station. The position and orientation of the color camera are adjusted so that the field of view covers the clear varnish area of ​​the target exterior part.

[0093] A white light illumination device is set within the field of view of the color camera, and the relative position and illumination angle between the illumination device and the color camera are fixed.

[0094] Arrange the workpiece conveying and dwell time according to the production rhythm, so that the workpiece remains stationary during the color camera exposure time;

[0095] For each frame of image captured by the color camera, an image pixel index set is established. The position index of each pixel is represented as an ordered pair of integers consisting of row index and column index, where the row index increases vertically from the top left corner of the image matrix and the column index increases horizontally from the top left corner of the image matrix.

[0096] A calibration plate with a known width that covers the boundary of the field of view is placed in the width direction of the color camera's field of view. The actual physical width of the calibration plate is obtained in millimeters.

[0097] Acquire a calibration image containing the calibration board, and read the width of the calibration board in the calibration image (in pixels).

[0098] Divide the actual physical width of the calibration board by the corresponding number of width pixels to calculate the imaging scale coefficient. The imaging scale coefficient characterizes the size of a single pixel in the physical space in the image space.

[0099] The maximum equivalent diameter of the pinhole defect is obtained according to the inspection standard. The maximum equivalent diameter of the pinhole defect is divided by the imaging scale coefficient to obtain the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale. The upper limit value of the equivalent diameter of the pinhole defect at the pixel scale is rounded down, multiplied by two, and then added to obtain the side length of the neighborhood square window. A square neighborhood is constructed with each pixel in the image as the center and the side length of the neighborhood square window as the side length. The absolute values ​​of the difference between the row index of any pixel in the neighborhood and the row index of the center pixel, and the difference between the column index of any pixel in the neighborhood and the column index of the center pixel, do not exceed half of the side length of the neighborhood square window minus one. The geometric size constraint of the connected region of the pinhole defect is defined as the pinhole geometric scale condition. The pinhole geometric scale condition limits the equivalent diameter of the connected region of the pinhole defect to not be greater than the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale.

[0100] A color camera is set up above the workstation to be inspected, and the position of the color camera is adjusted so that the field of view covers the clear varnish area of ​​the target exterior part.

[0101] Set up a white light illumination within the camera's field of view, and fix the illumination angle and the relative position of the camera;

[0102] Production cycle scheduling is performed to keep the workpiece stationary during exposure;

[0103] For each frame of image captured by the camera, a pixel index set is created. The index of any pixel is denoted as And represent pixel indices as ordered pairs of integers. ;in, The set of all pixel indices for a single frame of an image; For any pixel index variable; The corresponding pixel in the top left corner of the image matrix. It is a pixel row index, and it increments downwards along the image; It is a pixel column index, and it increments to the right along the image;

[0104] A calibration plate with a known width that covers the boundary of the camera's field of view is placed along the camera's field of view width direction. The width of this calibration plate is recorded as . ;in, The actual width of the calibration plate is measured in millimeters;

[0105] Acquire a calibration image and read the width in pixels of the calibration image, denoted as . ;in, To determine the number of pixels corresponding to the width of the calibrated image;

[0106] The calculated imaging scaling factor is ;

[0107] According to the inspection standards, the maximum equivalent diameter of the pinhole is set as follows: ;

[0108] The upper limit of the equivalent diameter of the pinhole at the pixel scale is calculated as follows: ;

[0109] Calculate the side length of the neighborhood square window. ;

[0110] For any pixel The neighborhood set is constructed as follows: ;in, In pixels A set of square-shaped neighboring pixels centered on the image; It is the index variable of any pixel within the neighborhood; , Pixels Row index and column index.

[0111] The process involves acquiring standard whiteboard images using the same color camera and white light illumination device as for workpiece inspection, performing statistical analysis on the standard whiteboard images, and calculating the normalization coefficients for the red, green, and blue color channels. Specifically, this includes:

[0112] With the same color camera and white light illumination device as for workpiece inspection, a standard white board is placed within the field of view of the color camera to acquire images of the standard white board;

[0113] For each pixel in the standard whiteboard image, the gray values ​​of the red, green and blue channels are obtained respectively, forming a set of gray values ​​for the red channel, a set of gray values ​​for the green channel and a set of gray values ​​for the blue channel.

[0114] The median operation is performed on the red channel grayscale sample set. The samples are then sorted by their grayscale values. When the number of samples is odd, the grayscale value at the middle position after sorting is selected as the red channel calibration benchmark value. When the number of samples is even, the arithmetic mean of the two middle grayscale values ​​after sorting is selected as the red channel calibration benchmark value. The same sorting and median operation method is applied to the green channel grayscale sample set and the blue channel grayscale sample set to obtain the green channel calibration benchmark value and the blue channel calibration benchmark value, respectively.

[0115] The red channel normalization coefficient is constructed based on the red channel calibration reference value. When the red channel calibration reference value is greater than zero, the red channel normalization coefficient is obtained through ratio calculation. When the red channel calibration reference value is equal to zero, the red channel normalization coefficient is set to one. The green channel normalization coefficient is set to one. The blue channel normalization coefficient is constructed based on the blue channel calibration reference value. When the blue channel calibration reference value is greater than zero, the blue channel normalization coefficient is obtained through ratio calculation. When the blue channel calibration reference value is equal to zero, the blue channel normalization coefficient is set to one.

[0116] Using the same camera and lighting configuration as for workpiece inspection, a standard whiteboard is set up, and images of the whiteboard are captured.

[0117] The pixel values ​​of the three color channels of the whiteboard image are denoted as follows: , , ;in, , , The whiteboard image is in pixels. The grayscale values ​​of the red, green, and blue channels at that location;

[0118] Calculate the full-image bit value for each channel of the whiteboard: , , ;in, , , These are the calibration reference values ​​obtained by taking the median values ​​of the pixels in the red, green, and blue channels of the entire whiteboard image, respectively. For median calculation, odd-numbered samples take the median value, and even-numbered samples take the arithmetic mean of the two median values.

[0119] The normalization coefficients for the color channels are constructed as follows: , , ;in, , , These are the normalized coefficients for the red channel, green channel, and blue channel, respectively.

[0120] The process involves acquiring images of the workpiece's clear coat surface according to the production cycle, normalizing each color channel of the workpiece's clear coat surface image based on the normalization coefficients obtained from standard white board calibration, and setting the effective detection area for the workpiece. Specifically, this includes:

[0121] At the inspection station, images of the workpiece varnish surface are collected sequentially according to the production rhythm, ensuring that each frame of the workpiece varnish surface image is consistent with the standard whiteboard image in terms of the configuration of the color camera and white light illumination device.

[0122] For each pixel in each frame of the workpiece varnish surface image, the original grayscale values ​​of the red channel, green channel and blue channel are obtained respectively. The range of the original grayscale values ​​is the preset digital grayscale range.

[0123] Multiply the original grayscale value of the red channel by the normalization coefficient of the red channel to obtain the normalized grayscale value of the red channel; multiply the original grayscale value of the green channel by the normalization coefficient of the green channel to obtain the normalized grayscale value of the green channel; multiply the original grayscale value of the blue channel by the normalization coefficient of the blue channel to obtain the normalized grayscale value of the blue channel.

[0124] When the offline configuration file of the detection system loads a binary mask of the effective detection area of ​​the workpiece and there is at least one pixel in the binary mask with a value of 1, the set of pixel indices with a value of 1 in the binary mask is set as the set of pixels of the effective detection area of ​​the workpiece; otherwise, the set of image pixel indices is set as the set of pixels of the effective detection area of ​​the workpiece.

[0125] Images of the workpiece's clear coat surface are captured at the inspection station according to the production cycle.

[0126] The original pixel values ​​of the three color channels of the workpiece image are denoted as follows: , ;in, , , The workpiece image in pixels Retrieves the original grayscale values ​​of the red, green, and blue channels;

[0127] The normalized channel value of the workpiece is calculated based on the whiteboard normalization factor: , , ;in, , , These are the normalized grayscale values ​​of the red, green, and blue channels of the workpiece image, respectively.

[0128] If the offline configuration file of the detection system loads a binary mask of the effective detection area of ​​the workpiece, and at least one pixel in the mask has a value of 1, then the set of indices of pixels with a value of 1 in the mask is set as the set of pixels in the effective detection area. ;in, This is the set of pixel indices for the effective detection area of ​​the workpiece.

[0129] In other cases, let: .

[0130] Based on the normalized color channel data, the pixel luminance and color components are calculated to construct an original descriptive quantity to describe the color and luminance state of each pixel, specifically including:

[0131] For each pixel in the image pixel index set, a weighted operation is performed based on the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel. The normalized gray value of the red channel is multiplied by 30, the normalized gray value of the green channel is multiplied by 59, and the normalized gray value of the blue channel is multiplied by 11. The three products are added together and then divided by 100 to obtain the brightness of the current pixel.

[0132] For each pixel in the image pixel index set, add the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel to obtain the three-channel sum of the current pixel;

[0133] For each pixel in the image pixel index set, the red channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the red component of the current pixel; the green channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the green component of the current pixel.

[0134] For each pixel The brightness quantity is calculated as follows: ;in, For pixels Brightness level;

[0135] For each pixel The calculation of the channel sum is as follows: ;in, For pixels The three channels and;

[0136] The dimensionless chromaticity components are calculated as follows: , ;in, The redness component; This represents the greenness component.

[0137] Within the effective detection area of ​​the workpiece, a square neighborhood is constructed centered on each pixel. Statistical calculations are performed on the luminance and color components within the neighborhood to estimate the local coupling parameters between the luminance and color components. This specifically includes:

[0138] For each pixel in the effective detection area pixel set of the workpiece, count the number of effective pixels in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece to obtain the number of effective pixels in the neighborhood of the current pixel;

[0139] For each pixel in the effective detection area pixel set of the workpiece, the brightness values ​​of all pixels in its neighborhood intersection are summed to obtain the first-order brightness sum, and the brightness values ​​of all pixels in its neighborhood are squared and then summed to obtain the squared brightness sum.

[0140] For each pixel in the effective detection area pixel set of the workpiece, in its neighborhood intersection, the redness components of all pixels in the neighborhood are accumulated to obtain the redness sum, and the brightness and redness components of all pixels in the neighborhood are multiplied to obtain the brightness and redness product sum.

[0141] For each pixel in the effective detection area pixel set of the workpiece, the greenness components of all pixels in the neighborhood intersection are summed to obtain the greenness sum, and the brightness and greenness components of all pixels in the neighborhood are multiplied to obtain the brightness and greenness product sum.

[0142] For each pixel in the effective detection area pixel set of the workpiece, the discriminant is calculated based on the number of effective neighboring pixels, the first-order sum of brightness, and the sum of squares of brightness of the current pixel. The product of the number of effective neighboring pixels and the sum of squares of brightness is subtracted from the square of the first-order sum of brightness to obtain the discrete discriminant of the brightness sample of the current pixel.

[0143] When the discrete discriminant of the brightness sample of a certain pixel is greater than zero, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of redness, and the sum of the products of brightness and redness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the redness component are calculated. At the same time, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of greenness, and the sum of the products of brightness and greenness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the greenness component are calculated.

[0144] When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the redness component is set to zero, and the neighborhood average value of the redness component is used as the corresponding intercept parameter.

[0145] When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the greenness component is set to zero, and the neighborhood average value of the greenness component is used as the corresponding intercept parameter.

[0146] For each pixel In the pixel set The above execution steps S501 to S504 are as follows:

[0147] S501, ;in, This represents the number of valid pixels in the neighborhood.

[0148] S502, , ;in, The sum of the first-order brightness of the neighborhood; The sum of squares of the neighborhood brightness;

[0149] S503, , ;in, The redness of the neighboring area; The sum of the products of the neighborhood brightness and redness;

[0150] S504, , ;in, For the greenness of the neighborhood; It is the sum of the products of neighborhood brightness and greenness;

[0151] For each pixel Construct discrete discriminant for brightness samples Specifically: ;

[0152] like Then, steps S505 and S506 are executed, specifically as follows:

[0153] S505, Order: , ;in, The slope parameter is coupled with redness. The intercept parameter is coupled with redness.

[0154] S506, Order: , ;in, The slope parameter is coupled with greenness. The intercept parameter is coupled with greenness.

[0155] like Then, steps S507 and S508 are executed, specifically as follows:

[0156] S507, Order: , ;

[0157] S508, Order: , .

[0158] The process involves calculating the coupling residual amplitude between color and brightness based on the slope and intercept parameters estimated from the local color-brightness coupling relationship, as well as the actual color component of each pixel. Within a square neighborhood, the coupling residual amplitude and brightness are statistically analyzed to obtain the coupling breakage score for each pixel. Specifically, this includes:

[0159] For each pixel in the pixel set of the effective detection area of ​​the workpiece, a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the red component to obtain the predicted red component of the current pixel; a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the green component to obtain the predicted green component of the current pixel.

[0160] For each pixel in the effective detection area pixel set of the workpiece, subtract the predicted red component of the current pixel from the actual red component and square it; subtract the predicted green component of the current pixel from the actual green component and square it; add the previous squared result to the next squared result to obtain the coupling residual amplitude of the current pixel.

[0161] For each pixel in the effective detection area pixel set of the workpiece, in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece, sort the coupling residual magnitude of all pixels in the neighborhood, and use median operation to obtain the median of the neighborhood residual of the current pixel;

[0162] For each pixel in the effective detection area pixel set of the workpiece, sort the brightness of all pixels in its neighborhood intersection, and use median calculation to obtain the median brightness of the neighborhood of the current pixel.

[0163] For each pixel in the effective detection area pixel set of the workpiece, the coupling residual amplitude of the current pixel is used as the numerator, and the sum of the median of the neighborhood residual of the current pixel and the preset minimum positive number is used as the denominator to perform a division operation to obtain the first normalization factor; at the same time, the result of adding one to the brightness of the current pixel is used as the numerator, and the result of adding one to the brightness median of the neighborhood of the current pixel is used as the denominator to perform a division operation to obtain the second normalization factor.

[0164] For each pixel in the effective detection area pixel set of the workpiece, the first normalization factor and the second normalization factor are multiplied to obtain the coupling breakage score of the current pixel. The coupling breakage scores of all pixels in the effective detection area pixel set of the workpiece are then summarized to form the score field of the entire image.

[0165] For each pixel The predicted chromaticity is calculated as follows: , ;in, The predicted redness; The predicted greenness;

[0166] For each pixel Calculate the residuals, specifically as follows: ;in, This represents the amplitude of the coupling residual.

[0167] For each pixel The median of the neighborhood residuals is calculated as follows: ;in, This represents the median of the residuals within the neighborhood.

[0168] For each pixel The median brightness of the neighborhood is calculated as follows: ;in, The median brightness of the neighborhood;

[0169] For each pixel The coupling breakage score is calculated as follows: ;in, Score for coupling breakage;

[0170] Pixel set in the effective detection area Completed The calculation forms the full-map score field. .

[0171] The process of globally statistically analyzing coupling breakage scores within the effective detection area of ​​the workpiece, constructing a segmentation threshold, performing threshold segmentation and connected component analysis on the score field, and filtering out connected components of pinhole defects that meet the geometric scale conditions of pinholes specifically includes:

[0172] In the pixel set of the effective detection area of ​​the workpiece, the coupling breakage scores of all pixels are sorted, and the global median of the coupling breakage scores is obtained by median calculation.

[0173] In the pixel set of the effective detection area of ​​the workpiece, the absolute value of the difference between the coupling breakage score of each pixel and the global median of the coupling breakage score is calculated, and all absolute values ​​are sorted. The median absolute deviation of the coupling breakage score is obtained by median operation.

[0174] Multiply the median absolute deviation of the coupling break score by six, and add the resulting product to the global median of the coupling break score to construct a segmentation threshold for the score field.

[0175] Pixels with coupling breakage scores greater than the constructed segmentation threshold are selected from the pixel set of the effective detection area of ​​the workpiece to form a candidate pixel set;

[0176] The connectivity analysis is performed on the candidate pixel set using the eight-neighbor connectivity criterion. For any two pixels in the candidate pixel set, they are considered to be adjacent when the maximum distance between them in the row index direction and the column index direction is equal to one. The candidate pixels are grouped according to the adjacency relationship to obtain multiple connected components, and each connected component corresponds to a pixel index set.

[0177] For each connected component, the pixel area of ​​the connected component is obtained by counting each pixel in the corresponding pixel index set and summing the results.

[0178] For each connected component, substitute its pixel area into the relationship between the area and diameter of the circle, perform a square root multiplication operation to obtain the equivalent diameter of the current connected component;

[0179] Based on the pre-defined upper limit of the equivalent diameter of pinhole defects at the pixel scale, connected components with an equivalent diameter greater than zero and not greater than the upper limit of the equivalent diameter of pinhole defects at the pixel scale are selected to form a set of connected components of pinhole defects.

[0180] Pixel set in the effective detection area The median of the global score is calculated as follows: ;in, For scoring field exist The global median;

[0181] Pixel set in the effective detection area The calculated median absolute deviation is: ;in, The median absolute deviation of the scoring range;

[0182] Construct a segmentation threshold for the scoring field as follows: ;

[0183] Construct the candidate pixel set as ;

[0184] In the set The above uses the 8-neighborhood connectivity criterion for connectivity grouping, specifically: for any two pixels... , ,like Then determine and Adjacency; if there exists an integer With pixel sequence satisfy , And for all All and If adjacent, then determine. and They belong to the same connected component; thus, the connected component is obtained. ;in, This is the pixel sequence length parameter; Number the sequence items with indices; For the first A set of pixel indices for connected components; Number the connected components; This represents the total number of connected components.

[0185] Calculate connected components The pixel area is ;

[0186] Calculate connected components The equivalent diameter is ;

[0187] Construct a set of connected components for pinhole defects. .

[0188] The process of performing quantity statistics, intensity quantification, and area conversion on the connected regions of pinhole defects to form pinhole defect detection records and pixel-level defect masks specifically includes:

[0189] The number of pinhole defects is obtained by counting the number of connected components in the set of connected components of pinhole defects.

[0190] When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, obtain the coupling breakage score of all pixels in the current connected component on the corresponding pixel index set, sort the coupling breakage scores of all pixels in the connected component according to the numerical size and use the median operation to obtain the strength index of the current connected component.

[0191] When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, the pixel area of ​​the current connected component is multiplied by the square of the imaging scale coefficient to obtain the physical area corresponding to the current connected component, in square millimeters.

[0192] When the set of connected regions of pinhole defects is not empty, a pinhole defect detection record for the workpiece is formed by combining the workpiece identification information, the number of pinhole defects, and the physical area, strength index and equivalent diameter of each connected region of pinhole defects.

[0193] Based on the set of connected components of pinhole defects, a pixel-level defect mask is constructed on the set of image pixel indices. Pixels belonging to any set of connected component pixel indices of pinhole defects are assigned a value of one in the defect mask, and pixels not belonging to any set of connected component pixel indices of pinhole defects are assigned a value of zero in the defect mask.

[0194] When the set of connected components of pinhole defects is empty, the number of pinhole defects is set to zero, and all pixels in the pixel-level defect mask are assigned a value of zero.

[0195] The number of pinhole defects is calculated as follows: ;in, This is a set cardinality function; the input is a set, and the output is the number of elements in the set.

[0196] If the pinhole defect set If not empty, then for each The calculated strength index is as follows: ;in, For the first The median intensity index of the score within the connected region of a pinhole defect;

[0197] If the pinhole defect set If not empty, then for each The physical area is calculated as follows: ;in, To convert pixel area into physical area in square millimeters;

[0198] If the pinhole defect set If empty, it will not be calculated. ;

[0199] Create inspection records, including workpiece identification. Number of pinholes And when For each pinhole defect connected component in non-empty time parameter triples ;

[0200] Generate pixel-level defect masks, specifically: , ;in, A pixel-level defect mask;

[0201] If the pinhole defect set If it is empty, then there is ,and For all Established.

[0202] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0203] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts, characterized in that, include: A color camera and a white light illumination device are set up above the inspection station to acquire images covering the clear coat area of ​​the target exterior parts and to establish the geometric parameters of the pixels in the images. Standard whiteboard images were acquired using the same color camera and white light illumination device as those used for workpiece inspection. Statistical analysis was performed on the standard whiteboard images to calculate the normalization coefficients for the red, green, and blue color channels. Images of the workpiece's clear coat surface are acquired according to the production rhythm. Based on the normalization coefficients of each color channel obtained from the standard white board calibration, the color channels of the workpiece's clear coat surface image are normalized, and the effective detection area of ​​the workpiece is set. Based on the normalized color channel data, the pixel luminance and color components are calculated to construct the original descriptive quantities used to describe the color and luminance state of each pixel. Within the effective detection area of ​​the workpiece, a square neighborhood is constructed with each pixel as the center. Statistical calculations are performed on the brightness and color components within the neighborhood to estimate the local coupling relationship parameters between the brightness and color components. Based on the slope and intercept parameters estimated from the local color and brightness coupling relationship, as well as the actual color components of each pixel, the coupling residual amplitude between color and brightness is calculated. The coupling residual amplitude and brightness are statistically analyzed within a square neighborhood to obtain the coupling breakage score for each pixel. Global statistics are performed on the coupling breakage score within the effective detection area of ​​the workpiece, a segmentation threshold is constructed, threshold segmentation and connected component analysis are performed on the score field, and connected components of pinhole defects that meet the geometric scale conditions of pinholes are selected. The number of pinhole defects is statistically analyzed, the intensity is quantified, and the area is converted to form a pinhole defect detection record and a pixel-level defect mask.

2. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 1, characterized in that, The step of setting up a color camera and a white light illumination device above the inspection station to acquire an image covering the clear coat area of ​​the target exterior part and establishing the geometric parameters of the pixels in the image specifically includes: A color camera is set up above the inspection station. The position and orientation of the color camera are adjusted so that the field of view covers the clear varnish area of ​​the target exterior part. A white light illumination device is set within the field of view of the color camera, and the relative position and illumination angle between the illumination device and the color camera are fixed. Arrange the workpiece conveying and dwell time according to the production rhythm, so that the workpiece remains stationary during the color camera exposure time; For each frame of image captured by the color camera, an image pixel index set is established. The position index of each pixel is represented as an ordered pair of integers consisting of row index and column index, where the row index increases vertically from the top left corner of the image matrix and the column index increases horizontally from the top left corner of the image matrix. A calibration plate with a known width that covers the boundary of the field of view is placed in the width direction of the color camera's field of view. The actual physical width of the calibration plate is obtained in millimeters. Acquire a calibration image containing the calibration board, and read the width of the calibration board in the calibration image (in pixels). Divide the actual physical width of the calibration board by the corresponding number of width pixels to calculate the imaging scale coefficient. The imaging scale coefficient characterizes the size of a single pixel in the physical space in the image space. The maximum equivalent diameter of the pinhole defect is obtained according to the inspection standard. The maximum equivalent diameter of the pinhole defect is divided by the imaging scale coefficient to obtain the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale. The upper limit value of the equivalent diameter of the pinhole defect at the pixel scale is rounded down, multiplied by two, and then added to obtain the side length of the neighborhood square window. A square neighborhood is constructed with each pixel in the image as the center and the side length of the neighborhood square window as the side length. The absolute values ​​of the difference between the row index of any pixel in the neighborhood and the row index of the center pixel, and the difference between the column index of any pixel in the neighborhood and the column index of the center pixel, do not exceed half of the side length of the neighborhood square window minus one. The geometric size constraint of the connected region of the pinhole defect is defined as the pinhole geometric scale condition. The pinhole geometric scale condition limits the equivalent diameter of the connected region of the pinhole defect to not be greater than the upper limit value of the equivalent diameter of the pinhole defect at the pixel scale.

3. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 2, characterized in that, The process involves acquiring standard whiteboard images using the same color camera and white light illumination device as for workpiece inspection, performing statistical analysis on the standard whiteboard images, and calculating the normalization coefficients for the red, green, and blue color channels. Specifically, this includes: With the same color camera and white light illumination device as for workpiece inspection, a standard white board is placed within the field of view of the color camera to acquire images of the standard white board; For each pixel in the standard whiteboard image, the gray values ​​of the red, green and blue channels are obtained respectively, forming a set of gray values ​​for the red channel, a set of gray values ​​for the green channel and a set of gray values ​​for the blue channel. The median operation is performed on the red channel grayscale sample set. The samples are then sorted by their grayscale values. When the number of samples is odd, the grayscale value at the middle position after sorting is selected as the red channel calibration benchmark value. When the number of samples is even, the arithmetic mean of the two middle grayscale values ​​after sorting is selected as the red channel calibration benchmark value. The same sorting and median operation method is applied to the green channel grayscale sample set and the blue channel grayscale sample set to obtain the green channel calibration benchmark value and the blue channel calibration benchmark value, respectively. The red channel normalization coefficient is constructed based on the red channel calibration reference value. When the red channel calibration reference value is greater than zero, the red channel normalization coefficient is obtained through ratio calculation. When the red channel calibration reference value is equal to zero, the red channel normalization coefficient is set to one. The green channel normalization coefficient is set to one. The blue channel normalization coefficient is constructed based on the blue channel calibration reference value. When the blue channel calibration reference value is greater than zero, the blue channel normalization coefficient is obtained through ratio calculation. When the blue channel calibration reference value is equal to zero, the blue channel normalization coefficient is set to one.

4. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 3, characterized in that, The process involves acquiring images of the workpiece's clear coat surface according to the production cycle, normalizing each color channel of the workpiece's clear coat surface image based on the normalization coefficients obtained from standard white board calibration, and setting the effective detection area for the workpiece. Specifically, this includes: At the inspection station, images of the workpiece varnish surface are collected sequentially according to the production rhythm, ensuring that each frame of the workpiece varnish surface image is consistent with the standard whiteboard image in terms of the configuration of the color camera and white light illumination device. For each pixel in each frame of the workpiece varnish surface image, the original grayscale values ​​of the red channel, green channel and blue channel are obtained respectively. The range of the original grayscale values ​​is the preset digital grayscale range. Multiply the original grayscale value of the red channel by the normalization coefficient of the red channel to obtain the normalized grayscale value of the red channel; multiply the original grayscale value of the green channel by the normalization coefficient of the green channel to obtain the normalized grayscale value of the green channel; multiply the original grayscale value of the blue channel by the normalization coefficient of the blue channel to obtain the normalized grayscale value of the blue channel. When the offline configuration file of the detection system loads a binary mask of the effective detection area of ​​the workpiece and there is at least one pixel in the binary mask with a value of 1, the set of pixel indices with a value of 1 in the binary mask is set as the set of pixels of the effective detection area of ​​the workpiece; otherwise, the set of image pixel indices is set as the set of pixels of the effective detection area of ​​the workpiece.

5. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 4, characterized in that, Based on the normalized color channel data, the pixel luminance and color components are calculated to construct an original descriptive quantity to describe the color and luminance state of each pixel, specifically including: For each pixel in the image pixel index set, a weighted operation is performed based on the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel. The normalized gray value of the red channel is multiplied by 30, the normalized gray value of the green channel is multiplied by 59, and the normalized gray value of the blue channel is multiplied by 11. The three products are added together and then divided by 100 to obtain the brightness of the current pixel. For each pixel in the image pixel index set, add the normalized gray values ​​of the red channel, green channel, and blue channel of the current pixel to obtain the three-channel sum of the current pixel; For each pixel in the image pixel index set, the red channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the red component of the current pixel; the green channel normalized gray value of the current pixel is used as the numerator, and the sum of the three channels of the current pixel plus one is used as the denominator to perform a division operation to obtain the green component of the current pixel.

6. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 5, characterized in that, Within the effective detection area of ​​the workpiece, a square neighborhood is constructed centered on each pixel. Statistical calculations are performed on the luminance and color components within the neighborhood to estimate the local coupling parameters between the luminance and color components. This specifically includes: For each pixel in the effective detection area pixel set of the workpiece, count the number of effective pixels in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece to obtain the number of effective pixels in the neighborhood of the current pixel; For each pixel in the effective detection area pixel set of the workpiece, the brightness values ​​of all pixels in its neighborhood intersection are summed to obtain the first-order brightness sum, and the brightness values ​​of all pixels in its neighborhood are squared and then summed to obtain the squared brightness sum. For each pixel in the effective detection area pixel set of the workpiece, in its neighborhood intersection, the redness components of all pixels in the neighborhood are accumulated to obtain the redness sum, and the brightness and redness components of all pixels in the neighborhood are multiplied to obtain the brightness and redness product sum. For each pixel in the effective detection area pixel set of the workpiece, the greenness components of all pixels in the neighborhood intersection are summed to obtain the greenness sum, and the brightness and greenness components of all pixels in the neighborhood are multiplied to obtain the brightness and greenness product sum. For each pixel in the effective detection area pixel set of the workpiece, the discriminant is calculated based on the number of effective neighboring pixels, the first-order sum of brightness, and the sum of squares of brightness of the current pixel. The product of the number of effective neighboring pixels and the sum of squares of brightness is subtracted from the square of the first-order sum of brightness to obtain the discrete discriminant of the brightness sample of the current pixel. When the discrete discriminant of the brightness sample of a certain pixel is greater than zero, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of redness, and the sum of the products of brightness and redness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the redness component are calculated. At the same time, a linear regression operation is performed based on the number of effective neighboring pixels of the current pixel, the first-order sum of brightness, the sum of squares of brightness, the sum of greenness, and the sum of the products of brightness and greenness. The slope parameter and intercept parameter describing the linear coupling relationship between the brightness quantity and the greenness component are calculated. When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the redness component is set to zero, and the neighborhood average value of the redness component is used as the corresponding intercept parameter. When the discrete discriminant of the brightness sample of a certain pixel is less than or equal to zero, the slope parameter describing the linear coupling relationship between the brightness quantity and the greenness component is set to zero, and the neighborhood average value of the greenness component is used as the corresponding intercept parameter.

7. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 6, characterized in that, The process involves calculating the coupling residual amplitude between color and brightness based on the slope and intercept parameters estimated from the local color-brightness coupling relationship, as well as the actual color component of each pixel. Within a square neighborhood, the coupling residual amplitude and brightness are statistically analyzed to obtain the coupling breakage score for each pixel. Specifically, this includes: For each pixel in the pixel set of the effective detection area of ​​the workpiece, a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the red component to obtain the predicted red component of the current pixel; a univariate linear function operation is performed based on the brightness of the current pixel and the slope and intercept parameters describing the linear coupling relationship between the brightness and the green component to obtain the predicted green component of the current pixel. For each pixel in the effective detection area pixel set of the workpiece, subtract the predicted red component of the current pixel from the actual red component and square it; subtract the predicted green component of the current pixel from the actual green component and square it; add the previous squared result to the next squared result to obtain the coupling residual amplitude of the current pixel. For each pixel in the effective detection area pixel set of the workpiece, in the intersection of the square neighborhood centered on the current pixel and the effective detection area pixel set of the workpiece, sort the coupling residual magnitude of all pixels in the neighborhood, and use median operation to obtain the median of the neighborhood residual of the current pixel; For each pixel in the effective detection area pixel set of the workpiece, sort the brightness of all pixels in its neighborhood intersection, and use median calculation to obtain the median brightness of the neighborhood of the current pixel. For each pixel in the effective detection area pixel set of the workpiece, the coupling residual amplitude of the current pixel is used as the numerator, and the sum of the median of the neighborhood residual of the current pixel and the preset minimum positive number is used as the denominator to perform a division operation to obtain the first normalization factor; at the same time, the result of adding one to the brightness of the current pixel is used as the numerator, and the result of adding one to the brightness median of the neighborhood of the current pixel is used as the denominator to perform a division operation to obtain the second normalization factor. For each pixel in the effective detection area pixel set of the workpiece, the first normalization factor and the second normalization factor are multiplied to obtain the coupling breakage score of the current pixel. The coupling breakage scores of all pixels in the effective detection area pixel set of the workpiece are then summarized to form the score field of the entire image.

8. The visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 7, characterized in that, The process of globally statistically analyzing coupling breakage scores within the effective detection area of ​​the workpiece, constructing a segmentation threshold, performing threshold segmentation and connected component analysis on the score field, and filtering out connected components of pinhole defects that meet the geometric scale conditions of pinholes specifically includes: In the pixel set of the effective detection area of ​​the workpiece, the coupling breakage scores of all pixels are sorted, and the global median of the coupling breakage scores is obtained by median calculation. In the pixel set of the effective detection area of ​​the workpiece, the absolute value of the difference between the coupling breakage score of each pixel and the global median of the coupling breakage score is calculated, and all absolute values ​​are sorted. The median absolute deviation of the coupling breakage score is obtained by median operation. Multiply the median absolute deviation of the coupling break score by six, and add the resulting product to the global median of the coupling break score to construct a segmentation threshold for the score field. Pixels with coupling breakage scores greater than the constructed segmentation threshold are selected from the pixel set of the effective detection area of ​​the workpiece to form a candidate pixel set; The connectivity analysis is performed on the candidate pixel set using the eight-neighbor connectivity criterion. For any two pixels in the candidate pixel set, they are considered to be adjacent when the maximum distance between them in the row index direction and the column index direction is equal to one. The candidate pixels are grouped according to the adjacency relationship to obtain multiple connected components, and each connected component corresponds to a pixel index set. For each connected component, the pixel area of ​​the connected component is obtained by counting each pixel in the corresponding pixel index set and summing the results. For each connected component, substitute its pixel area into the relationship between the area and diameter of the circle, perform a square root multiplication operation to obtain the equivalent diameter of the current connected component; Based on the pre-defined upper limit of the equivalent diameter of pinhole defects at the pixel scale, connected components with an equivalent diameter greater than zero and not greater than the upper limit of the equivalent diameter of pinhole defects at the pixel scale are selected to form a set of connected components of pinhole defects.

9. A visual inspection method for pinhole defects in the clear coat coating of automotive exterior parts according to claim 8, characterized in that, The process of performing quantity statistics, intensity quantification, and area conversion on the connected regions of pinhole defects to form pinhole defect detection records and pixel-level defect masks specifically includes: The number of pinhole defects is obtained by counting the number of connected components in the set of connected components of pinhole defects. When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, obtain the coupling breakage score of all pixels in the current connected component on the corresponding pixel index set, sort the coupling breakage scores of all pixels in the connected component according to the numerical size and use the median operation to obtain the strength index of the current connected component. When the set of connected components of pinhole defects is not empty, for each connected component in the set of connected components of pinhole defects, the pixel area of ​​the current connected component is multiplied by the square of the imaging scale coefficient to obtain the physical area corresponding to the current connected component, in square millimeters. When the set of connected regions of pinhole defects is not empty, a pinhole defect detection record for the workpiece is formed by combining the workpiece identification information, the number of pinhole defects, and the physical area, strength index and equivalent diameter of each connected region of pinhole defects. Based on the set of connected components of pinhole defects, a pixel-level defect mask is constructed on the set of image pixel indices. Pixels belonging to any set of connected component pixel indices of pinhole defects are assigned a value of one in the defect mask, and pixels not belonging to any set of connected component pixel indices of pinhole defects are assigned a value of zero in the defect mask. When the set of connected components of pinhole defects is empty, the number of pinhole defects is set to zero, and all pixels in the pixel-level defect mask are assigned a value of zero.