Enameled plate surface defect detection method based on machine vision

By combining machine vision and the improved PaDiM algorithm with scale attention feature extraction, a normal texture reference model for enamel was constructed, which solved the problem of misjudgment of texture fluctuation in the surface defect detection of enamel panels, and achieved accurate defect detection and scoring, adapting to multiple working environments.

CN121708003APending Publication Date: 2026-03-20HUBEI SANXING TECH CO LTD

Patent Information

Application Number
CN202512013955.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing methods for detecting defects on enamel-coated panels cannot differentiate the weights of defects based on the sensitivity of features, making it difficult to accurately distinguish between normal texture fluctuations and real defects. This results in insufficient detection accuracy and fails to meet the demand for refined detection under complex working conditions.

Method used

A machine vision-based detection method is adopted, which generates real-time reflection suppression images by point-by-point optimal gray-level fusion. Combined with the improved PaDiM algorithm and scale attention feature extraction method, a normal texture reference model of enamel is constructed to perform differential texture region matching and defect detection, and calculate the comprehensive defect score.

Benefits of technology

It enables accurate detection of surface defects in enamel panels, reduces misjudgments of normal texture fluctuations, improves the practicality and stability of the detection system, adapts to detection scenarios of multiple types and scales of defects, and reduces the misjudgment rate under complex backgrounds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121708003A_ABST
    Figure CN121708003A_ABST
Patent Text Reader

Abstract

The invention discloses an enamel plate surface defect detection method based on machine vision, and relates to the technical field of enamel plate surface defect detection. The method comprises the following steps: acquiring an original image of an enamel plate, and fusing the original image through a point-by-point optimal gray fusion method to obtain a real-time reflection suppression image; a defect-free reflection suppression image of the enamel plate is collected, matching analysis is conducted on the defect-free reflection suppression image and the real-time reflection suppression image through an improved PaDiM algorithm, a difference texture area is obtained, and coordinates of the difference texture area are recorded; in the difference texture area, two types of image features are extracted through a scale attention feature extraction method and fused, a real-time and standard fusion matrix is obtained, and a defect detection result is obtained through similarity matching; and converting the coordinates of the difference region to obtain a defect positioning result, calculating a defect comprehensive score based on a defect detection result, and grading to complete the surface defect detection of the enamel plate.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of enamel plate surface defect detection, in particular to an enamel plate surface defect detection method based on machine vision. BACKGROUND

[0002] Enamel plates are widely used in building decoration, home appliance manufacturing and other fields due to their excellent corrosion resistance, heat resistance and aesthetic appearance. Surface defects of the enamel plates not only affect the appearance quality of the products, but also may reduce the structural stability and cause safety hazards. Therefore, accurate and efficient detection of the surface defects of the enamel plates is a key link to ensure product quality and improve production efficiency.

[0003] Due to the influence of multiple factors such as glaze color formula, firing process and cooling conditions, the normal texture of the enamel plate itself has a large inherent fluctuation. The differences between various defects such as bubbles, cracks and black spots and the normal texture fluctuation are often local and subtle. The main shortcomings of the existing enamel plate surface defect detection scheme are that the sensitivity of the features to the defects cannot be differentiated and weighted, the contribution of the defect sensitive features cannot be targetedly strengthened, the irrelevant features and the normal texture fluctuation cannot be effectively weakened, the normal fluctuation such as glaze color difference and uneven firing is easily misjudged as a defect, the subtle differences between the defects and the background texture are difficult to capture, and finally the detection accuracy is affected, which cannot meet the fine detection requirements of the enamel plate surface defects under complex working conditions.

[0004] Therefore, it has become a technical problem to be solved in the field to develop an enamel plate surface defect detection method that can accurately distinguish between normal texture fluctuation and real defects through differentiated feature weight optimization. SUMMARY

[0005] In view of the deficiencies of the prior art, the present application provides an enamel plate surface defect detection method based on machine vision to solve the problems in the background art.

[0006] To achieve the above purpose, the present application is implemented by the following technical scheme: an enamel plate surface defect detection method based on machine vision, comprising the following steps: Step S1: acquiring an original image of the enamel plate, fusing the original image by a point-by-point optimal gray fusion method to obtain a real-time reflection suppression image; Step S2: acquiring a defect-free reflection suppression image of the enamel plate, performing matching analysis on the defect-free reflection suppression image and the real-time reflection suppression image by an improved PaDiM algorithm to obtain a difference texture area and record the coordinates of the difference texture area; Step S3: In the difference texture region, the real-time reflection suppression image is subjected to feature extraction and fusion by the scale attention feature extraction method to obtain a real-time fusion matrix, the defect-free reflection suppression image is subjected to feature extraction and fusion by the scale attention feature extraction method to obtain a standard fusion matrix, the real-time fusion matrix and the standard fusion matrix are subjected to similarity matching to obtain a defect detection result; Step S4: The coordinates of the difference texture region are subjected to coordinate conversion to obtain a defect positioning result, a defect comprehensive score is calculated based on the defect detection result, the defect comprehensive score is used to divide defect levels to realize surface defect detection of the enamel plate.

[0007] Preferably, the original image of the enamel plate is collected, including the following specific steps: A linearly polarized LED light source is selected as a light source array, the light source array includes 4 groups of independently controllable linearly polarized light source units, the polarization directions θ of each group of light sources are set to 0°, 45°, 90° and 135° respectively, the light source array is symmetrically arranged on both sides of the conveying mechanism with the conveying path of the enamel plate as the center, when the enamel plate passes through the light source array, the PLC controller lights up each group of light sources in a preset time sequence, the preset time sequence is 0°, 45°, 90° and 135° in turn, the lighting time of each group of light sources is synchronized with the camera exposure time, the camera is installed above the enamel plate, the lens optical axis is perpendicular to the surface of the enamel plate, when the enamel plate enters the detection area through the conveying mechanism, the edge signal of the enamel plate is detected through the photoelectric sensor, when the edge signal of the enamel plate is detected, the original image of the enamel plate is collected to obtain an original image sequence {I1(x,y), I2(x,y), I3(x,y), I4(x,y)}.

[0008] Preferably, the original image is fused by the point-by-point optimal gray fusion method to obtain a real-time reflection suppression image, and the specific steps are as follows: Based on the original image sequence {I1(x,y), I2(x,y), I3(x,y), I4(x,y)}, the comprehensive evaluation score of each pixel point is calculated in turn The calculation formula of the comprehensive evaluation score

[0009] Among them, and are weight coefficients, is the maximum effective contrast value, is the comprehensive evaluation score, is the pixel point in the local variance in the corresponding neighborhood under the oth working condition, is the pixel point in the oth working condition ​The reflection intensity under the group of working conditions, where o is the working condition index; Real-time reflection suppression image The formula for generating it is:

[0010]

[0011] in, The working condition number that yields the highest overall evaluation score. For the optimal working condition of the pixel grayscale value, For real-time reflection suppression images, This indicates taking the maximum value.

[0012] Preferably, the acquisition of the defect-free reflection suppression image of the enamel panel, and the matching analysis of the defect-free reflection suppression image and the real-time reflection suppression image using the improved PaDiM algorithm to obtain the differential texture region and record the coordinates of the differential texture region, includes the following steps: Defect-free enamel plate samples were collected and fused using a point-by-point optimal gray-level fusion method to obtain a defect-free reflection suppression image. A normal enamel texture reference model was constructed, and semantic layer optimization was performed on the WideResNet-50 in the improved PaDiM algorithm, using only layer 2 semantic features to obtain the optimized WideResNet-50. The real-time reflection suppression image was then generated. The region is divided into texture analysis sub-regions. For each texture analysis sub-region, a real-time texture feature vector is extracted using the optimized Wide ResNet-50. Call the corresponding spatial coordinates The reference model for normal enamel texture is used to calculate the weighted Mahalanobis distance value. Weighted Mahalanobis distance value The calculation formula is:

[0013] in, Coordinates in the image to be detected Feature vectors of texture blocks It is a diagonal weight matrix. It is the inverse of the covariance matrix. The weighted Mahalanobis distance value; Calculate the weighted Mahalanobis distance values ​​for the texture analysis sub-regions of defect-free enamel panels and enamel panels with minor defects, and use the 99.5th percentile as the base threshold. Introduce operating condition correction coefficient final threshold ; When the weighted Mahalanobis distance value of the texture analysis sub-region When the texture analysis sub-region is determined to be a difference texture region, adjacent difference texture sub-regions are merged to form a continuous difference texture region, and the coordinates of the difference texture region are recorded.

[0014] Preferably, the construction of the porcelain normal texture reference model comprises the following steps: The defect-free reflection suppression image is divided into defect-free reflection suppression image blocks that do not overlap each other, and the normal texture feature vector of the defect-free reflection suppression image block is extracted by Wide ResNet-50 , wherein (p, q) represents the index coordinates of the defect-free reflection suppression image block in the sample image, k represents the data set serial number, and the porcelain normal texture reference model is constructed ; The calculation formula of the mean vector is:

[0015] , wherein is the total number of training samples, is the mean value of the feature dimension corresponding to each element, is the normal texture feature vector; The calculation formula of the covariance matrix is:

[0016] , wherein is a regularization term, is a 64-order unit matrix, is the covariance matrix, is the transpose of the deviation of the normal texture feature vector and the mean vector.

[0017] Preferably, in the difference texture region, the scale attention feature extraction method is used to extract and fuse the features of the real-time reflection suppression image to obtain a real-time fusion matrix, and the scale attention feature extraction method is used to construct the porcelain normal texture reference model, comprising the following steps: The difference texture region is divided into small-scale regions, medium-scale regions, and large-scale regions according to the area size, and the calculation formula of the actual physical area of the difference region is:

[0018] , wherein is the total number of pixels in the difference region, and are the physical dimensions of the pixels, is the actual physical area of the difference region; ​The scale channel space attention module is used to extract features of the real-time reflection suppression image to obtain a real-time fusion matrix, and the difference area image block is output through four hollow convolution branches of the scale feature extraction module 、 、 、 The feature maps of the four branches are spliced by channels to obtain an aggregated feature map, a channel statistical vector is generated through global average pooling, and after being mapped through two layers of MLP, a channel weight vector is generated through a Sigmoid function. The channel weight vector and the aggregated feature map are multiplied by channels to obtain a channel-weighted feature map. The channel-weighted feature map is split by branch, and each branch feature map is compressed to a spatial encoding map through 1x1 convolution. The spatial encoding maps of each branch are spliced to obtain an aggregated spatial map. The aggregated spatial map is generated through 7x7 convolution to generate a spatial weight map, which is multiplied by the split branch feature map pixel by pixel to obtain four branch feature maps. The four branch feature maps are spliced by channels, and are compressed into a fusion feature map through 1x1 convolution ; The structural feature parameters are extracted from the fusion feature map , and the structural feature parameters are standardized, and the formula is:

[0019] wherein, is the original feature parameter, i is the core feature parameter index, and are the minimum value and the maximum value of the feature in the standard defect sample set, is the standardized feature value; The six standardized feature values are arranged in a fixed order to construct a 2x3-dimensional real-time fusion matrix , ; Select standard samples of five typical defects of enamel plate, extract features and construct fusion matrix for each sample according to the above process to obtain standard fusion matrix of each defect , is the defect category index.

[0020] Preferably, the structural feature parameters are extracted from the fusion feature map, and the calculation formula of the aspect ratio R is as follows: , wherein is the length of the longest side of the circumscribed rectangle, is the length of the shortest side; The calculation formula of the edge sharpness E is:

[0021] wherein: ​a set of defect edge pixels, a total number of edge pixels, and a Sobel gradient amplitude of pixel (x, y) in x, y direction, an edge sharpness; an internal gray transition smoothness The calculation formula is:

[0022] wherein, a set of defect region pixels, a total number of defect region pixels, a gray value of pixel , wherein, an average gray value of the defect region, an internal gray transition smoothness; The calculation formula of the contour connectivity C is wherein, a number of contour connected domains; a gray contrast The calculation formula is:

[0023] wherein, an average gray value of the defect region, an average gray value of a 5-pixel-wide normal region around the defect, a gray contrast.

[0024] Preferably, the similarity matching of the real-time fusion matrix and the standard fusion matrix to obtain the defect detection result includes the following specific steps: The calculation formula of the cosine similarity of the real-time fusion matrix and the standard fusion matrix is:

[0025] wherein, a matrix vectorization operation, a real-time fusion matrix, a standard fusion matrix of the i-th standard defect, denotes a vector dot product, denotes a L2 norm of a vector, a cosine similarity of the real-time fusion matrix and the standard fusion matrix; The similarity of the real-time fusion matrix to the 5 standard fusion matrices is calculated , and the similarity threshold is set through a mixed defect sample , and when there is only one ≥ , then the to-be-detected region is determined as a first type defect; when there are multiple , so that ≥ , the defect type corresponding to the maximum similarity is taken, and when all < , the defect is determined as a suspected defect, and finally a defect detection result is obtained, the defect detection result including a defect type and a structural feature parameter corresponding to the defect type.

[0026] Preferably, the difference texture region coordinates are subjected to coordinate conversion to obtain a defect positioning result, specifically as follows. A four-level coordinate conversion system of an image pixel coordinate system, a camera coordinate system, a world coordinate system and an enamel plate physical coordinate system is constructed, the image pixel coordinate system : taking the upper left corner of a real-time reflection suppression image as an origin, a u-axis along a horizontal direction of the image to the right, and a v-axis along a vertical direction of the image downward; The camera coordinate system : taking a lens optical center of an industrial camera as an origin, an x-axis parallel to the u-axis of the image, a y-axis parallel to the v-axis of the image, and a z-axis along a lens optical axis vertically forward; The world coordinate system : taking a center point of an enamel plate inlet of a conveying line detection station as an origin, an X-axis along a conveying line motion direction, a Y-axis perpendicular to the conveying line horizontally to the right, and a Z-axis vertically upward relative to the conveying line; The enamel plate physical coordinate system : taking a left upper corner vertex of a single enamel plate as an origin, an A-axis along a plate length direction, and a B-axis along a plate width direction; The pixel coordinate system to camera coordinate system conversion formula is as follows:

[0027] wherein (u, v) is a center point coordinate of a defect in the image pixel coordinate system, is an inverse matrix of an intrinsic matrix, is a fixed working distance from the camera to the enamel plate surface, , , are three-dimensional coordinates of the defect in the camera coordinate system; The camera coordinate system to world coordinate system formula is as follows:

[0028] wherein is a 3x3 rotation matrix, is a 3x1 translation matrix, , , ) is the three-dimensional coordinate of the defect in the world coordinate system; Finally, a defect positioning result is obtained, the defect positioning result being final coordinates of the defect in a physical coordinate system of the enamel plate, and a conversion calculation formula from the world coordinate system to the physical coordinate system of the enamel plate is as follows:

[0029] wherein, (x, y) is the coordinate of the top left corner vertex of the current enamel plate in the world coordinate system, (x', y') is the final coordinate of the defect in the physical coordinate system of the enamel plate, and R is a rotation matrix of the enamel plate relative to the world coordinate system. Preferably, the defect comprehensive score is calculated based on the defect detection result, and specifically, the defect comprehensive score is calculated based on the defect detection result. The calculation formula of the defect comprehensive score is as follows:

[0030] Preferably, the defect comprehensive score is calculated based on the defect detection result, and specifically, the defect comprehensive score is calculated based on the defect detection result. The calculation formula of the defect comprehensive score is as follows:

[0031] wherein, f is a normalization function of the defect core parameter, S is the defect comprehensive score, D is a defect density correction term, W is a defect type weight, P is a position weight, and D is a defect density.

[0032] The application provides a machine vision-based enamel plate surface defect detection method, relates to machine learning and deep learning technology, and has the following beneficial effects: (1) The PaDiM algorithm is introduced into enamel normal texture modeling, the texture features of a defect-free enamel plate are probabilistically modeled through a multivariate Gaussian distribution, normal texture fluctuations under different glaze colors and firing processes are fully adapted, this mode can effectively filter natural color differences of glaze, slight unevenness during firing and the like, avoids misjudgment of normal texture as defects, and establishes a precise and universal reference benchmark for initial screening of difference areas.

[0033] (2) The improved PaDiM algorithm is introduced, the weighted Mahalanobis distance is introduced, and the semantic layer selection is optimized, on the basis of texture modeling, the weight of a defect sensitive feature is further strengthened, redundant noise is filtered, the feature dimension is simplified, and the calculation efficiency is improved, the improvement ensures the accuracy of initial screening of difference areas, adapts to real-time detection requirements of an industrial production line, fully plays the advantages of texture modeling, and significantly improves the practicability and stability of the detection system.

[0034] ​​​​​​​​​(3) A defect classification algorithm fusing multi-scale attention and feature matrix similarity, which is suitable for detecting scenes of multiple types and multiple scales of defects such as bubbles, cracks, and black spots on enamel plates, breaks through the limitation of single feature recognition by multi-dimensional feature extraction and standardized matching, can accurately capture the morphology and gray difference of different defects, reduces misjudgment under complex background interference, and provides reliable technical support for fine discrimination of defect types. BRIEF DESCRIPTION OF DRAWINGS

[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0036] Fig. 1 A step flow chart of an enamel plate surface defect detection method based on machine vision is provided for the present application. Fig. 2 A step level chart for obtaining defect positioning results in an enamel plate surface defect detection method based on machine vision is provided for the present application. Fig. 3 A step level chart for obtaining defect comprehensive score in an enamel plate surface defect detection method based on machine vision is provided for the present application. DETAILED DESCRIPTION

[0037] The technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0038] Please refer to Figs. 1-3 The present application provides a technical solution: an enamel plate surface defect detection method based on machine vision.

[0039] Step S1: Collecting the original image of the enamel plate, fusing the original image by the point-by-point optimal gray fusion method to obtain a real-time reflection suppression image; This step targets the core characteristics of enamel panels, namely high gloss and strong specular reflection. By constructing a controllable multi-polarized light source illumination environment and a precise image fusion strategy, a real-time reflection suppression image is generated. This real-time reflection suppression image can minimize high-brightness interference from ambient light, equipment reflections, etc., so that the enamel panel surface is in a stable visual state close to diffuse reflection. This provides a clear and balanced image foundation for subsequent texture analysis and defect identification, ensuring the visibility and detection stability of minute defects such as bubbles, micro-cracks, and black spots.

[0040] Linearly polarized LED light source is selected as the core component of the array. The linearly polarized light can be controlled by adjusting the polarization direction to specifically filter the specular reflection component on the enamel plate surface. The LED light source has the characteristics of stable brightness, fast response speed (≤1ms) and long service life.

[0041] The light source array contains four independently controllable linearly polarized light source units. The polarization direction θ of each light source is set to 0°, 45°, 90°, and 135°, respectively. The values ​​are based on the fact that, through previous experimental verification, these four polarization directions can cover the specular reflection angles of different orientations on the enamel plate surface, and can capture image information under different reflection states to the maximum extent. Compared with two or three polarization directions, the reflection suppression rate can be improved by more than 30%.

[0042] The illumination angle α of each light source is designed to be adjustable from 30° to 60° with an adjustment accuracy of ±1°. The adaptation logic is as follows: for enamel panels with different glaze colors (glossy glaze, matte glaze) and firing processes, the incident direction of light is changed by adjusting the illumination angle to avoid the problem of local reflections that cannot be suppressed under a fixed angle. For example, for glossy glaze enamel panels, an illumination angle of 30° to 40° is selected to reduce specular reflection; for matte glaze enamel panels, an illumination angle of 45° to 60° is selected to ensure uniform brightness of surface details.

[0043] The light source array is installed symmetrically on both sides of the conveying mechanism with the enamel plate conveying path as the center. The vertical distance between each light source and the surface of the enamel plate is fixed at 200mm, and the horizontal distance can be finely adjusted according to the width of the conveying line (range 50~80mm) to ensure that the light uniformly covers the surface of the enamel plate without any blind spots.

[0044] The enamel plate conveying mechanism adopts a constant-speed through-type structure, with the conveying speed v set at 0.5m / s and speed fluctuation ≤ ±0.02m / s. At this speed, it can ensure that the illumination time of each group of light sources on the same position of the enamel plate is ≥10ms, meeting the requirements of synchronous imaging by the camera. A new high-precision encoder (resolution <0.1mm / pulse) is added to record the displacement of the enamel plate in real time, and the displacement is stored synchronously when each image is acquired. (o=1~4 corresponds to 4 groups of polarization conditions), misalignment is compensated through image registration algorithm to adapt to high-speed production scenarios, coordinate registration formula. ,in, , The registered pixel coordinates of the o-th image group This represents the cumulative displacement during the acquisition of the o-th image group. Using pixel physical dimensions, a lightweight ORB image registration algorithm is adopted to improve real-time performance, and the registration error is controlled to <1 pixel.

[0045] By synchronously linking the light source switching, camera light, and encoder counting through the PLC controller, coordinated control is achieved: when a certain spatial position on the enamel plate passes through the light source array, the PLC triggers each group of light sources to light up in sequence according to the preset timing (0°→45°→90°→135°). The lighting time of each group of light sources is strictly synchronized with the camera exposure time, ensuring that the camera can acquire a complete original image of the same position under different polarization conditions.

[0046] A CMOS industrial camera with a resolution of 2448×2048 pixels, a pixel size of 3.45μm, and a frame rate of ≥30fps was selected. This resolution allows the smallest defect (diameter ≥0.1mm) on the enamel plate surface to correspond to ≥3 pixels, meeting the pixel accuracy requirements for defect identification. The high frame rate characteristics of the CMOS sensor can adapt to the synchronous acquisition requirements of multiple light source switching.

[0047] The camera is installed directly above the enamel panel, with the lens optical axis perpendicular to the enamel panel surface. The lens focal length is f=25mm, and the working distance (distance from the lens to the enamel panel surface) is 300mm. Based on the lens parameters, the camera's field of view is calculated to be 101mm×85mm. Since a single image cannot cover a standard enamel panel (1200mmx600mm), a line-by-line stitching mode is adopted. The camera moves with the conveyor mechanism, and the overlap rate of adjacent frames is set to 10% to ensure that the entire panel surface is captured without omission.

[0048] Images of defect-free enamel plates were acquired using four sets of polarized light sources. The actual light intensity of each light source was measured, and the light intensity ratio was calculated. , ( (Light intensity in the 0° polarization direction), exposure time adjustment formula: ,in The reference exposure time for the 0° polarization direction (initially set to 10ms). To adapt the exposure time for the o-th polarization condition, keep the camera's ISO sensitivity constant at 800 to ensure consistent exposure across all image groups (exposure = 100). Exposure time Light intensity); White balance is set to "Custom". Based on the global grayscale mean calibration of the defect-free enamel panel, 1000 random sample points of the defect-free enamel panel are collected, and the global grayscale mean is calculated. White balance gain = global grayscale mean / average grayscale value of the RGB channels of the sample points. It is adjusted through independent white balance gain of the three RGB channels to ensure the grayscale consistency of enamel panels of different colors and avoid the distortion of reflection intensity calculation caused by color interference; a global shutter mode is adopted to avoid image distortion caused by rolling shutter and ensure that the acquisition coordinates of the same pixel position under different light sources are accurately aligned.

[0049] When the enamel plate enters the detection area via the conveyor mechanism, the PLC detects the edge signal of the enamel plate through a photoelectric sensor, triggering the image acquisition process. The first group of light sources with a polarization direction of θ=0° is turned on, and the camera is exposed synchronously to acquire the first original image I1(x,y), where (x,y) are the image pixel coordinates; the first group of light sources is turned off, and the second group of light sources with a polarization direction of θ=45° is turned on, and the camera is exposed synchronously to acquire the second original image I2(x,y); the above logic is followed to acquire the original images I3(x,y) and I4(x,y) corresponding to the light sources with polarization directions of θ=90° and θ=135° respectively. The enamel panel continues to move, and the above steps are repeated until the entire panel surface is captured, ultimately forming an original image sequence {I1(x,y),I2(x,y),I3(x,y),I4(x,y)} for each spatial location of the enamel panel. Each image in the original image sequence corresponds to a combination of different polarization directions and illumination angles, and there are significant differences in reflection intensity and highlight area distribution.

[0050] It should be noted that the specific relationship between the irradiation angle and polarization direction is as follows: For glossy glazes, the irradiation angle range is 30°~40°, with the optimal irradiation angle for each polarization direction being: 0° / 90° adjusted to 30°, 45° / 135° adjusted to 35°, and a reflection suppression rate of ≥75% required; For matte glazes, the irradiation angle range is 45°~60°, with the optimal irradiation angle for each polarization direction being: 0° / 90° adjusted to 50°, 45° / 135° adjusted to 55°, and a reflection suppression rate of ≥70% required; For colored glazes, the irradiation angle range is... The optimal illumination angle for each polarization direction is 35° to 55°: 0° / 90° is adjusted to 40°, 45° / 135° is adjusted to 45°, and the reflection suppression rate is required to be greater than or equal to 72%. After adjusting the illumination angle, four sets of polarization images of the defect-free enamel plate are acquired, and the reflection suppression rate of each set of images is calculated (reflection suppression rate = (number of reflective pixels before adjustment - number of reflective pixels after adjustment) / number of reflective pixels before adjustment x 100%). If the reflection suppression rate of a certain polarization direction is lower than the adaptation matrix requirement, the illumination angle is finely adjusted (step size + 1°) until all polarization directions meet the requirements.

[0051] The original image is fused using a point-by-point optimal gray-level fusion method to obtain a real-time reflection-suppressed image. The steps are as follows: For the same pixel position (x, y) in the original image sequence, the gray value with the weakest reflection and the most favorable contrast for defect observation is selected from the gray values ​​corresponding to the four polarization conditions. This gray value is used as the final gray value of the pixel in the real-time reflection suppression image. This method can eliminate the specular reflection component of each pixel in a targeted manner, rather than processing it uniformly worldwide, thus avoiding the loss of local details caused by global processing.

[0052] Before testing, 100 sample points (covering different areas of the board surface) were collected from the current batch of defect-free enamel panels. The minimum gray value under diffuse reflection and the maximum gray value under specular reflection saturation were statistically analyzed. First, the pixel points were defined. In the Reflection intensity under operating conditions The calculation formula is:

[0053] in, For polarization condition group index, For the first Pixel under group working conditions grayscale value, The lowest grayscale value under diffuse reflection state of a defect-free enamel panel. This represents the highest grayscale value when the specular reflection of the enamel panel reaches saturation. For pixels In the The reflection intensity under the working conditions is such that the closer the value is to 0, the weaker the reflection, and the closer the value is to 1, the stronger the reflection.

[0054] It should be noted that the parameter values ​​in the formula are based on the calibration results of the diffuse / specular reflection state of the defect-free enamel plate. Take the minimum gray value of the 100 sample points in the current batch. Take the maximum grayscale value of the 100 sample points in the current batch. If after calculation... <0, take =0; if >1, take =1, ensuring the reflection intensity is within the [0,1] range to avoid distortion. The calibration is repeated before testing each batch of enamel panels. If the glaze color and process remain unchanged within a batch, the calibration value can be checked every 100 panels to ensure stability. This formula converts pixel grayscale values ​​under different working conditions into a unified reflection intensity index, facilitating comparison of pixel reflectivity across working conditions and avoiding grayscale contrast distortion caused by slight differences in light source brightness.

[0055] Preset three-level neighborhood: For small-scale defects (area S < 0.25 mm), a 3x3 neighborhood is used; for medium-scale defects (0.25 mm < S ≤ 4 mm), a 5x5 neighborhood is used; for large-scale defects (S > 4 mm), a 7x7 neighborhood is used. First, estimate the defect area through the total number of pixels N in the difference region , and then automatically match the corresponding neighborhood according to S. The pixel The local variance within the corresponding neighborhood under the o-th group of working conditions The calculation formula is:

[0056] Among them, is the pixel [[ID=1×5]]The corresponding neighborhood pixel coordinates, M and N are the neighborhood sizes, is the [[ID=1×9]]group of working conditions, the average gray value of the pixel within the neighborhood, is the pixel The local variance within the corresponding neighborhood under the o-th group of working conditions, K is the neighborhood half-width, and are the neighborhood pixel indices.

[0057] This formula is used to quantify the local detail contrast of pixels, avoid the local detail blur caused by screening only based on reflection intensity, and ensure that the selected gray value has no strong specular reflection interference and can clearly present the surface texture and defect details.

[0058] For each pixel , the comprehensive evaluation score The calculation formula is:

[0059] Among them, and are the weight coefficients, is the reflection suppression contribution term, the larger the value, the better the reflection suppression effect, is the normalized contrast contribution term, the larger the value, the better the contrast, is the maximum effective contrast value, taking the value of 120, is the comprehensive evaluation score, and the gray value corresponding to the working condition with the highest score is the optimal gray value of this pixel.

[0060] It should be noted that the weight coefficients are selected according to the enamel color type of the enamel plate: for bright glaze: = 0.7, = 0.3, for matte glaze: = 0.4, = 0.6, for colored glaze: = 0.5, =0.5, allowing users to adjust the weights within ±0.1 based on actual detection results (such as false detection rate and false negative rate), improving the flexibility of the method and adapting to special process enamel plates.

[0061] Ultimately, real-time reflection suppression image The formula for generating it is:

[0062]

[0063] in, The working condition number that yields the highest overall evaluation score. For the optimal working condition of the pixel grayscale value, This is for real-time reflection suppression images.

[0064] It should be noted that the score difference threshold ΔF = 0.05 is set for multiple working conditions. If the difference is less than ΔF, the average of these grayscale values ​​is calculated as the final grayscale value of the pixel to avoid texture inconsistency caused by selecting a single condition.

[0065] First, read the original image sequence {I1(x,y),I2(x,y),I3(x,y),I4(x,y)}, and calculate the value for each pixel sequentially. The optimal operating condition is selected using the argmax function. Extract the corresponding grayscale value as The pixel values ​​are used to traverse all pixels to obtain a complete real-time reflection suppression image. After point-by-point fusion, the real-time reflection suppression image is smoothed by 3x3 Gaussian (standard deviation = 0.5) to eliminate gray-level abrupt changes between adjacent pixels while preserving defect details. The gray-level variance of the fused image is calculated. If the gray-level variance > 50 (indicating excessive image brightness fluctuation), the weights or neighborhood parameters are readjusted, and the reflection suppression image is regenerated to ensure uniform overall image brightness and provide a stable image foundation for subsequent steps.

[0066] Step S2: Acquire a defect-free reflection suppression image of the enamel panel, and perform matching analysis between the defect-free reflection suppression image and the real-time reflection suppression image using the improved PaDiM algorithm to obtain the differential texture region and record the coordinates of the differential texture region; This step addresses the core issue of the wide range of normal texture variations in enamel panels caused by different glaze colors and firing processes, and the difficulty of traditional detection methods in distinguishing natural texture differences from actual defects. It constructs a reference model of normal enamel texture covering multiple working conditions and optimizes the texture matching mechanism to achieve precise block-by-block matching of the reflection-suppressed image. Its core purpose is to filter out normal texture fluctuations such as natural color differences in the glaze and slight firing unevenness, selecting only texture areas that significantly deviate from the normal texture distribution. This allows for focused targeting in subsequent fine-grained defect identification, reducing false positives and false negatives, and ensuring the adaptability and stability of the detection system under complex working conditions.

[0067] Fifty defect-free enamel plate samples were selected, covering mainstream glaze colors (glossy and matte), firing temperatures (850℃~950℃), and cooling processes (natural and forced cooling) used in industrial production. Each sample measures 1200mm × 600mm (standard industrial specifications). For each sample, a corresponding defect-free reflection suppression image was generated using the multi-polarization light source array and image fusion process in step S1, ensuring that all sample images are in a diffuse reflection state without specular reflection interference.

[0068] The defect-free reflection suppression images were divided into non-overlapping texture image patches of size 100×100 pixels, resulting in a dataset containing 144,000 defect-free reflection suppression image patches, covering typical normal texture features under different working conditions, providing sufficient and comprehensive sample support for model training.

[0069] Wide ResNet-50 was selected as the feature extraction network. By widening the number of channels in the residual module, this network can extract richer mid-to-low-level texture features while maintaining computational efficiency. Compared with networks such as ResNet-18 and VGG-16, it improves the representation ability of fine textures of enamel panels by more than 20%, and is adapted to the complex characteristics of enamel textures.

[0070] Network parameter configuration: Transfer learning is performed using weights pre-trained on the ImageNet dataset. The parameters of the first 10 layers are frozen to retain general feature extraction capabilities, and the parameters of the last 20 layers are fine-tuned to adapt to enamel texture features. The input image patch size is 100×100 pixels, the output feature vector dimension is 64, and the feature extraction step size is set to 1 to ensure that each defect-free reflection-suppressed image patch can obtain complete feature representation.

[0071] For each defect-free reflection suppression image patch in the dataset, Wide ResNet-50 is selected as the feature extraction network. A 100x100 pixel defect-free reflection suppression image patch is input into the network. From the feature map output by its layer 2 stage, the feature map of each channel is compressed into a scalar value through global average pooling, thus obtaining an initial feature vector of 512 dimensions.

[0072] To reduce subsequent computational complexity and model storage overhead, and to avoid the curse of dimensionality, principal component analysis was used to reduce the dimensionality of the initial 512-dimensional feature vector, retaining the 64 most important principal components, ultimately generating a 64-dimensional normal texture feature vector for constructing the texture model. Where (p, q) represents the index coordinates of the texture image patch, p represents the row index (increasing from top to bottom), q represents the column index (increasing from left to right), and k represents the dataset sequence number. For image patches located at the same index position (p, q) in all sample images, their 64-dimensional normal texture feature vectors are extracted. Based on the feature vectors of K defect-free training samples at (p,q), a set containing K 64-dimensional feature vectors is formed, and a normal enamel texture reference model at position (p,q) is constructed. The specific steps are as follows: Mean vector This represents the average level of texture features of all normal samples at position (p, q). The formula for calculating the mean vector is:

[0073] in, The total number of training samples. The mean of the feature dimension corresponding to each element reflects the normal distribution center of that feature dimension.

[0074] covariance matrix The covariance matrix, representing the correlation and dispersion of texture features across all dimensions of all normal samples at position (p,q), is calculated using the following formula:

[0075] in, The deviation between a single feature vector and the mean vector is used to construct the outer product matrix, reflecting the correlation between feature dimensions. For regularization terms, the value is... Its purpose is to avoid singular (non-invertible) covariance matrices. It is a 64th order identity matrix. Let be the covariance matrix.

[0076] To ensure the normal texture model has broad adaptability, this method employs a fusion calculation strategy: when constructing the reference model at position (p, q), the feature vectors of all defect-free samples with different glaze colors and firing processes at that position are treated as a whole for statistical calculation. This strategy enables the model to learn and cover various compliant normal texture fluctuations during the production process (such as natural color differences in glazes and slight uneven firing), thereby avoiding misjudging normal fluctuations as defects.

[0077] For specific application scenarios with special high-precision requirements (such as producing only a single glaze color), a separate calculation strategy can be adopted, that is, to build an independent normal texture model library for each major glaze color type and select it during detection.

[0078] Weighted Mahalanobis distance is used for anomaly measurement. The weight matrix is ​​set based on the contribution of different feature dimensions to the discrimination of defects in enamel tiles. This allows for targeted enhancement of the contribution of defect-sensitive features and weakening of interference from irrelevant features or noise when calculating the deviation of the detected features from the normal model. Differentiated weights are assigned to different feature dimensions, and the calculation formula is as follows:

[0079] in, Coordinates in the image to be detected Feature vectors of texture blocks The weights are diagonal, ensuring independent weighting across feature dimensions. This is the inverse of the covariance matrix, used to eliminate the influence of correlation between feature dimensions. The weighted Mahalanobis distance value reflects the degree of deviation between the texture block to be detected and the normal texture model. The larger the value, the more significant the deviation, and the more likely it is to be a defect area.

[0080] It should be noted that the weights in the diagonal weight matrix are determined based on experiments conducted using 100 enamel panel samples containing minor defects. The contribution of each feature dimension to defect identification was calculated (measured using information gain). The formula for calculating information gain is as follows: , The initial entropy for defect identification, Let A be the conditional entropy given a feature dimension A, and D be the set of defective / normal sample labels. The larger the value, the stronger the discriminative power of that feature dimension. The data is sorted as follows: the top 30% are high-contribution dimensions (weight 1.8~2.0), the middle 40% are medium-contribution dimensions (weight 1.0~1.5), and the bottom 30% are low-contribution dimensions (weight 0.5~0.8). The specific form of the weight matrix is ​​as follows: ,in The weight of the i-th feature is given by the weight matrix. This formula strengthens the contribution of defect-sensitive features and weakens the interference of irrelevant features, making the distance calculation more suitable for the needs of enamel defect detection.

[0081] The original PaDiM algorithm typically integrates three layers of semantic features: layer 1, layer 2, and layer 3. This results in redundant feature dimensions, with lower-level features (layer 1) containing excessive noise and higher-level features (layer 3) being overly abstract, leading to a loss of detail. To address the characteristic of enamel panel textures being primarily composed of low-to-mid-level features (texture details and local structure), the semantic layer selection is optimized, using only layer 2 semantic features for modeling.

[0082] Layer 2 semantic layer can preserve the key details of enamel texture (such as tiny bumps and fine lines) while filtering out high-frequency noise from layer 1. At the same time, it reduces the feature dimension from the traditional 128 dimensions to 64 dimensions, reducing the model's storage and computational load. Comparative experiments have verified that on 1000 samples, the normal texture coverage of layer 2 features reaches 98.7%, while the coverage of the fused features of layer 1 and laver3 is 99.0%, but the computational load increases by 3 times. Therefore, to balance accuracy and efficiency, only laver2 features are used.

[0083] The real-time reflection suppression image generated in step S1 Following the same rules as training the defect-free reflection suppression image, the image is divided into 100×100 pixel texture analysis sub-regions, with the spatial coordinates of each sub-region as follows: For each sub-region, a 64-dimensional real-time texture feature vector is extracted using the optimized Wide ResNet-50 (extracting only layer 2 features). .

[0084] By matching and analyzing defect-free reflection suppression images and real-time reflection suppression images using an improved PaDiM algorithm, the differential texture regions are obtained and their coordinates are recorded. The steps are as follows: Real-time texture feature vectors for each texture analysis sub-region Call the corresponding spatial coordinates Enamel normal texture reference model This reference model is constructed based on a multivariate Gaussian distribution, where the mean vector... Distribution centers representing normal texture features, covariance matrix The correlation and dispersion of each dimension of the characterization feature together constitute the probability distribution boundary of the defect-free texture, realizing a quantitative description of normal texture fluctuations. The deviation is calculated using the weighted Mahalanobis distance formula. .

[0085] It should be noted that, in order to ensure the compatibility of the matching working conditions, before testing, the corresponding mean vector and covariance matrix should be called from the model library according to the glaze color and firing process information of the enamel plate to be tested. If there is no completely matching model for the working condition to be tested, the nearest working condition model (such as the glossy glaze close working condition) should be used, and the difference should be adapted by fine-tuning the weight matrix (the deviation should not exceed ±0.2). At this time, a low confidence level should be given and manual verification should be recommended.

[0086] Calculate the weighted Mahalanobis distance values ​​for all normal texture sub-regions based on the current batch of defect-free samples, and use the 99.9th percentile as the threshold. At the same time, a working condition correction factor is introduced. Operating condition correction factor Based on the reflective properties of the glaze: Brightness axis =1.0 (strong reflection, threshold needs to be strict), matte finish =0.9 (the weak reflection threshold can be relaxed), colored glaze =1.0, and optimized through cross-validation, the final threshold is... The threshold is determined based on the following criteria: the false positive rate for normal texture areas is ≤0.5%, and the recall rate for slightly defective areas is ≥95%.

[0087] When the deviation of a certain sub-region > When the region is identified as a region with different textures, its spatial coordinates are marked. And pixel-level contours (obtained by mapping the coordinates of sub-region boundaries).

[0088] Adjacent differential texture sub-regions are merged using an 8-neighborhood merging strategy to form continuous differential texture regions, avoiding fragmented markings caused by defects crossing sub-regions. A minimum area threshold of 0.01 square millimeters is set (corresponding to a pixel count greater than or equal to 3 after correction in step S1), and false differential regions with an area smaller than this threshold are removed. After merging, the minimum bounding rectangle and area of ​​each differential texture region are recorded, as well as spatial information such as the coordinates of the differential texture regions. The contour information (polygon vertex coordinates) and grayscale distribution features of the differential regions are supplemented by recording, providing target region data for subsequent defect type identification.

[0089] Step S3: Within the differential texture region, feature extraction and fusion of the real-time reflection suppression image are performed using the scale attention feature extraction method to obtain a real-time fusion matrix. Feature extraction and fusion of the defect-free reflection suppression image are performed using the scale attention feature extraction method to obtain a standard fusion matrix. Similarity matching is performed between the real-time fusion matrix and the standard fusion matrix to obtain the defect detection result. This step targets the differential texture regions identified in step S2, focusing on common defects in enamel panels such as bubbles, cracks, black spots, glaze loss, and exposed substrate. It addresses the core issues of traditional methods—poor adaptability and low classification accuracy for multi-scale and multi-morphological defects—through multi-scale structural feature analysis and cross-dimensional feature fusion classification. Its core objective is to extract multi-scale features that combine global structure and local details from the differential regions, construct a standardized feature representation system, and achieve automated and refined defect type identification through precise similarity matching. This provides clear type criteria for subsequent defect grading and feedback, ensuring the relevance and reliability of the detection results.

[0090] It should be noted that the scale attention feature in step S3 and the 64-dimensional texture feature in step S2, which are progressive correlation features from basic screening to precise classification, are not the same features. The 64-dimensional texture feature in step S2 is extracted based on the defect-free area of ​​the entire board surface, focusing on the global fluctuations of normal texture (such as glaze uniformity and basic roughness). Its core purpose is to screen out the difference areas that deviate significantly from normal texture. The feature has universality and broad coverage. The scale attention feature of step S3 is extracted only from the difference region output by step S2, focusing on the multi-scale structured characteristics specific to defects. It is a local deepening of the general texture features of S2 and a focus on the defect dimension. Its core purpose is to distinguish the defect type.

[0091] The feature extraction in step S3 uses the coordinates, contours, and areas of the difference region output in step S2 as input boundaries. Multi-scale feature extraction is performed only within this local area to avoid redundant calculations caused by full-plane processing. At the same time, it ensures that feature extraction focuses on the core defect region and improves classification accuracy.

[0092] Within the differential texture region, feature extraction and fusion are performed on the real-time reflection suppression image using the scale attention feature extraction method to obtain a real-time fusion matrix. Similarly, feature extraction and fusion are performed on the defect-free reflection suppression image using the scale attention feature extraction method to obtain a standard fusion matrix. The steps are as follows: Based on the industrial inspection needs and common size ranges of enamel panel defects, areas with different textures are divided into three scale levels according to their area. The classification standard is based on statistical data from 1000 enamel panels with defects (defect area 0.0025mm²). 2 ~25mm 2 ), as detailed below: Small-scale region: Area S < 0.25 mm 2 This corresponds to small defects such as black spots and microbubbles (diameter ≤ 0.5mm); the medium-scale area is 0.25mm. 2 ≤S≤4mm 2 This corresponds to medium-sized cracks, localized glaze loss, and other defects (length 0.5~2mm); large-scale areas: S>4mm2 This corresponds to defects such as large areas of exposed substrate and long cracks (length > 2mm).

[0093] The structural characteristics of defects at different scales differ significantly (e.g., small-scale defects are mainly characterized by abrupt changes in grayscale, while large-scale defects are mainly characterized by contour morphology). Scale-based analysis can extract features in a targeted manner, avoiding the loss of details or redundant interference caused by single-scale analysis.

[0094] First, the actual physical area of ​​the difference region is obtained through pixel coordinate transformation. The calculation formula is as follows:

[0095] in, The total number of pixels in the difference region is obtained by counting the foreground pixels after binarization. and The pixel physical size is calculated from the camera resolution and the camera's field of view. This represents the actual physical area of ​​the region of difference.

[0096] Feature extraction is performed using a multi-scale channel spatial attention module (MCSAM). This module captures features at different scales through multi-branch dilated convolution and enhances defect features by combining channel-space dual-dimensional attention, thus adapting to the multi-morphological characteristics of enamel defects. The specific parameter configuration of the module is as follows: The input is a reflection suppression image patch of the difference region (adaptively cropped by scale, with small-scale regions cropped to 32×32 pixels, medium-scale regions to 64×64 pixels, and large-scale regions to 128×128 pixels). The Multi-Scale Feature Extraction (MFEM) module contains four parallel dilated convolutional branches with dilation rates of 1, 2, 4, and 8, respectively. The kernel size of each branch is 3×3, and the number of output channels is 64. The dilation rate is determined as follows: dilation rate 1 captures an 11×11 receptive field (suitable for small-scale defects), and dilation rate 8 captures a 25×25 receptive field (suitable for large-scale defects). The four branches can fully cover the scale range of enamel defects. The Group Normalization (GN) module normalizes the output features of each branch by dividing them into 8 groups according to the channel, avoiding statistical bias caused by small batch data and adapting to the small batch characteristics of real-time processing in industrial inspection. The activation function used is the SiLU function, and the formula is as follows: ( The Sigmoid function, compared to the ReLU function, can better preserve the nonlinear expression of features and improve the discriminative power of small-scale defect features.

[0097] The multi-scale feature extraction process is as follows: The image patches representing the differences are processed by four dilated convolution branches of MFEM, which output multi-scale feature maps respectively. , , , (The dimensions are all (H×W×64), where (H and W) are the size of the input image patch). Each branch feature corresponds to the structural information under different receptive fields (e.g., branch 1 focuses on edge details, and branch 4 focuses on the global contour). The feature maps of the four branches are concatenated by channel to obtain an aggregated feature map of (H×W×256). A 256-dimensional channel statistical vector is generated by global average pooling. After mapping through two layers of MLP (128-dimensional hidden layer), a channel weight vector is generated by the Sigmoid function. The channel weight vector is multiplied by the aggregated feature map by channel to obtain a channel-weighted feature map. The weighted feature map strengthens the defect-sensitive channels (e.g., the channel weight corresponding to the crack edge is increased, and the channel weight corresponding to the background texture is suppressed). The channel-weighted feature map is split into branches. Each branch feature map is compressed into a (H×W×1) spatial encoding map by 1×1 convolution. After concatenation, an aggregated spatial map of (H×W×4) is obtained. A spatial weight map is generated by 7×7 convolution and multiplied pixel by pixel with the split branch feature map to highlight the key spatial positions of the defect area (such as the center of the bubble and the end of the crack). The four branch feature maps, after channel-spatial weighting, are concatenated by channel and compressed into a (H×W×128) multi-scale fused feature map through a 1×1 convolution. This feature map combines structural information at different scales with feature enhancement of key regions, providing high-quality input for subsequent feature parsing.

[0098] From the fused feature map Six core structural feature parameters are extracted, covering three dimensions: shape, grayscale, and edge, to meet the needs of distinguishing different types of defects. The calculation methods and significance of each parameter are as follows: The area S reflects the overall size of the defect; the aspect ratio R: the minimum bounding rectangle of the defect is obtained using OpenCV's minAreaRect function, and the ratio of the length to the width of the minimum bounding rectangle is calculated using the following formula: ,in This is the length of the longest side of the circumscribed rectangle. The shortest side length is denoted by R; for crack-type defects, R>5, and for bubble-type defects, R≈1, which are key parameters for morphological differentiation. Edge sharpness E characterizes the degree of grayscale abrupt change between the defect edge and the background, and is calculated using the following formula:

[0099] in: The set of defect edge pixels is extracted using the Canny operator. This represents the total number of edge pixels. and Let be the Sobel gradient values ​​of pixel (x, y) in the x and y directions. The value represents edge sharpness. A larger value indicates a sharper edge (such as cracks or glaze defects), while a smaller value indicates a more blurred edge.

[0100] Internal grayscale transition smoothness The formula reflecting the uniformity of grayscale within a defect is as follows:

[0101] in, For the set of pixels in the defect area, This represents the total number of pixels in the defect area. For pixels grayscale value, The average gray value of the defect area. This refers to the smoothness of the internal grayscale transition. The smaller the value, the more uniform the grayscale (such as bubbles or black spots), while the larger the value, the greater the grayscale fluctuation (such as areas with glaze loss).

[0102] Contour connectivity C: Measured by the number of connected components in the defect contour, calculated using the following formula: ,in The number of connected components in the contour directly reflects the degree of defect dispersion. For crack-type defects, C≈1 (single connected component), and for black dot cluster defects, C>1 (multiple connected component). Grayscale contrast The grayscale difference between the defective area and the surrounding normal area is calculated using the following formula:

[0103] in, The average gray value of the defect area. The average grayscale value of the normal area 5 pixels wide surrounding the defect. For grayscale contrast, defects such as exposed base and glaze loss have a grayscale value of C_g > 0.3 (significant difference in grayscale from the substrate), while defects such as black spots have a grayscale value of C_g < -0.2.

[0104] To eliminate the dimensional differences between different feature dimensions, the six core feature parameters are first standardized using the following formula:

[0105] in, Here, represents the original feature parameters, and 'i' represents the index of the core feature parameter. , The standard deviation of this feature in the standard defect sample set. The standardized feature values ​​ensure that the weights of each feature are balanced.

[0106] A 2×3D real-time fusion matrix is ​​constructed using six standardized feature values ​​in a fixed order (area, aspect ratio, edge sharpness, internal grayscale transition smoothness, contour connectivity, and grayscale contrast). The format is as follows: The first row of the matrix focuses on morphological and edge features, while the second row focuses on grayscale and connectivity features. This ensures both the structured representation of features and facilitates subsequent similarity calculations.

[0107] 100 standard samples of each of the five typical defects in enamel panels (bubbles, cracks, black spots, glaze peeling, and exposed substrate) were selected. Features of each sample were extracted and a fusion matrix was constructed according to the above process to obtain the standard fusion matrix for each type of defect. ( =1~5 correspond to 5 types of defects).

[0108] Cosine similarity is used to measure the degree of matching between the real-time fusion matrix and the standard fusion matrix. The calculation formula is as follows:

[0109] in, This is a matrix vectorization operation that converts a 2×3 matrix into a 6-dimensional column vector. For real-time fusion matrix, For the first The standard fusion matrix of class-standard defects Represents the vector dot product. Describes the L2 norm of a vector. The value is cosine similarity; the closer the value is to 1, the higher the feature matching degree between the area to be detected and the standard defect of this type.

[0110] Calculate the real-time fusion matrix Similarity with 5 standard fusion matrices Set the national value for similarity difference. T=0.05, Mixing threshold =0.65 (Based on ROC curve analysis of 1000 mixed defect samples, the accuracy rate of single defect identification is >94%, and the false negative rate of mixed defects is ≤3%); Defect priorities are set (based on the industry standard "Enamel Plate Quality Grading Specification"): cracks and exposed base directly affect structural strength (weight 1.0), glaze peeling affects corrosion resistance and aesthetics (weight 0.9), bubbles affect appearance (weight 0.8), and black spots only slightly affect appearance (weight 0.5). Calculate the difference between the highest similarity and the second highest similarity. SIM, if SIM> T is then determined to be the single defect type corresponding to the highest similarity. SIM≤ If the similarity score is T, the process proceeds to priority determination. Based on the preset defect type priority, the defect type with the higher priority is selected as the primary classification, and the defect type with the second highest similarity is marked as an "associated defect" and included in the detection results. If the similarity of two or more types of defects is higher than the mixed threshold, the process continues. If the core parameters of the defect area simultaneously meet the typical range of the corresponding defect, it is determined to be a mixed defect. The two defect types and their corresponding core parameters are recorded, and a manual review confirmation is prompted.

[0111] The final defect detection results include the defect type and the corresponding structural feature parameters. The structural feature parameters corresponding to the defect type are: crack length L, bubble diameter D, black spot area S, and glaze loss / exposed base area S.

[0112] Step S4: Perform coordinate transformation on the coordinates of the differential texture area to obtain the defect location result. Calculate the comprehensive defect score based on the defect detection result. Classify the defect level according to the comprehensive defect score to realize the surface defect detection of the enamel plate.

[0113] The coordinates of the differential texture regions are transformed to obtain the defect location results. The steps are as follows: The defect center point pixel coordinates (u, v) are obtained based on the difference texture region information output in step S2, and further pixel-level analysis is performed. Their relationship with the image block index (p, q) is as follows: The output of step S2 is a series of coordinates of differential texture regions, including image patch indices (p, q). Each (p, q) corresponds to a 100x100 pixel image region. For each differential region identified by (p, q), a corresponding image patch is extracted from the original high-resolution image based on the pixel range mapped by (p, q). Within this image patch, an adaptive threshold segmentation algorithm or activation region analysis based on the S2 feature map is used to obtain a precise binary mask of the defect (where the defect pixel value is 1 and the background is 0). The minimum bounding rectangle of the defect mask is calculated, and the pixel coordinates of its center point are (u, v), calculated using the following formula:

[0114] in, , , and These are the boundary coordinates of the smallest bounding rectangle.

[0115] A four-level coordinate transformation system is constructed: image pixel coordinate system, camera coordinate system, world coordinate system, and enamel plate physical coordinate system. This system enables precise mapping of defects from their image pixel positions to their actual physical positions on the plate surface. The coordinate systems are defined as follows: Image pixel coordinate system The origin is the upper left corner of the reflection suppression image generated in step S1. The u-axis extends horizontally to the right along the image, and the v-axis extends vertically downwards along the image. The unit is pixels. Camera coordinate system With the optical center of the industrial camera lens as the origin, the x-axis is parallel to the image u-axis, the y-axis is parallel to the image v-axis, and the z-axis is perpendicular to the lens optical axis forward. The unit is millimeters. World coordinate system The origin is the center point of the enamel plate inlet at the inspection station of the conveyor line. The X-axis is along the direction of the conveyor line, the Y-axis is perpendicular to the conveyor line and moves horizontally to the right, and the Z-axis is perpendicular to the conveyor line and moves upward. The unit is millimeters. Enamel plate physical coordinate system The origin is the top left corner of a single enamel panel. The A-axis runs along the length of the panel (parallel to the X-axis of the world coordinate system), and the B-axis runs along the width of the panel (parallel to the Y-axis of the world coordinate system). The unit is millimeters.

[0116] The transformation from pixel coordinates to camera coordinates eliminates image distortion and converts the image to 3D camera coordinates. The formula is as follows:

[0117] Where (u,v) are the coordinates of the center point of the defect in the image pixel coordinate system. The camera intrinsic parameter matrix was obtained using Zhang Zhengyou's calibration method. This is the inverse of the intrinsic parameter matrix, used to eliminate the effects of camera lens distortion. The fixed working distance from the camera to the enamel plate surface, ( , , ) represents the three-dimensional coordinates of the defect in the camera coordinate system.

[0118] The formula for transforming from camera coordinate system to world coordinate system is:

[0119] in, It is a 3×3 rotation matrix, representing the pose of the camera coordinate system relative to the world coordinate system. The translation matrix is ​​3×1, representing the position of the camera's optical center in the world coordinate system. , , ) represents the three-dimensional coordinates of the defect in the world coordinate system.

[0120] The final defect location result is obtained, which is the final coordinate of the defect in the physical coordinate system of the enamel plate. The conversion formula from the world coordinate system to the physical coordinate system of the enamel plate is as follows:

[0121] in,( , ) represents the coordinates of the top-left corner vertex of the current enamel panel in the world coordinate system. B) represents the final coordinates of the defect in the physical coordinate system of the enamel plate. Let be the rotation matrix of the enamel plate relative to the world coordinate system.

[0122] To address the coordinate offset issue caused by the movement of the enamel plate, a PLC controller is used to synchronously link defect acquisition with conveyor line coding. When the photoelectric sensor detects that the enamel plate has entered the inspection station, it triggers the code counter to start counting and records the initial code value of the plate. When the camera acquires defect images, it simultaneously records the current encoded value. Calculate the displacement of the plate at the time of data acquisition. (Encoding accuracy 1mm / pulse); displacement By incorporating world coordinate system coordinate calculations, the accuracy of defect location mapping under motion conditions is ensured.

[0123] The following steps are taken to calculate a comprehensive defect score based on the defect detection results and classify the defect level according to the comprehensive defect score: A three-dimensional hierarchical index system based on defect type, core parameters, and location weight is constructed. The index selection is based on industrial quality standards and enterprise management needs, as detailed below: Defect type weight : Assign values ​​based on the degree of impact of defects on product performance, bubbles =0.8, crack =1.0 (affects structural strength, highest weight), black dot =0.5, glaze peeling =0.9, Exposed bottom =1.0, the above weight values ​​are set based on industry standards and a large amount of experimental data.

[0124] Core parameter quantization value For different defect types, select key parameters: for cracks, select length L; for bubbles, select diameter D; for black spots, select area S; and for glaze loss / exposed base, select area S.

[0125] Position weight The value is assigned based on the distance between the defect and the edge / hole of the plate. The distance is ≤50mm (edge ​​area, where defects are prone to be magnified). =1.2, distance >50mm and ≤200mm (middle area) =1.0, distance >200mm (center area) =0.8.

[0126] A comprehensive defect score is obtained through weighted calculation. The calculation formula is:

[0127] in, This is a normalization function for the core parameters of the defect, set according to different defect types. For the comprehensive score of defects, This is a defect density correction term. The correction factor is 0.2 when the number of defects is ≥3 and 0 when it is ≤2, to avoid a small number of defects excessively affecting the score. For defect type weights, For positional weights, Defect density.

[0128] It should be noted that, , The maximum allowable parameter value for this type of defect is given by the formula for calculating defect density. , This represents the number of defects. The standard deviation of the defect location. The distribution influence coefficient is set to 0.1.

[0129] Industrial verification using 1000 defective enamel panel samples (covering different defect types, parameters, and locations) was conducted to classify defect levels: Acceptable level: <0.6, the defect has no impact on product performance and requires no action; re-inspection required: 0.6≤ ≤1.2 indicates a potential risk and requires manual review and confirmation; must be removed. >1.2, defects that seriously affect product quality or performance must be removed from the production line.

[0130] For each defect identified in step S3, extract the type weight. Core parameter P, position weight and defect density Substitute into the grading scoring formula to calculate the comprehensive score. The defect classification level is determined based on the relationship between the score and the threshold. When a single board has multiple defects, the highest grade is used as the final quality grade of the board (for example, if a board has one acceptable defect and one defect that must be rejected, the board is graded as defective).

[0131] Furthermore, based on the above method embodiments, the present invention also provides an apparatus, including a memory, a processor, and a computer program stored in the memory, which is adapted to be loaded and executed by the processor to implement the above-described machine vision-based method for detecting defects on the surface of enamel plates.

[0132] It should be noted that, in this document, relational terms such as "first" and "second" are used merely 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 a process, method, article, or apparatus. Without further limitations, the phrase "comprising an element defined as..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0133] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting surface defects in enamel plates based on machine vision, characterized in that: Includes the following steps: Step S1: Acquire the original image of the enamel panel, and fuse the original image using the point-by-point optimal grayscale fusion method to obtain a real-time reflection suppression image; Step S2: Acquire a defect-free reflection suppression image of the enamel panel, and perform matching analysis between the defect-free reflection suppression image and the real-time reflection suppression image using the improved PaDiM algorithm to obtain the differential texture region and record the coordinates of the differential texture region; Step S3: Within the differential texture region, feature extraction and fusion of the real-time reflection suppression image are performed using the scale attention feature extraction method to obtain a real-time fusion matrix. Feature extraction and fusion of the defect-free reflection suppression image are performed using the scale attention feature extraction method to obtain a standard fusion matrix. Similarity matching is performed between the real-time fusion matrix and the standard fusion matrix to obtain the defect detection result. Step S4: Perform coordinate transformation on the coordinates of the differential texture area to obtain the defect location result. Calculate the comprehensive defect score based on the defect detection result. Classify the defect level according to the comprehensive defect score to realize the surface defect detection of the enamel plate.

2. The method for detecting surface defects of enamel plates based on machine vision according to claim 1, characterized in that: The process of acquiring the original image of the enamel panel includes the following specific steps: Linearly polarized LED light sources are selected as the light source array. The light source array contains four independently controllable linearly polarized light source units. The polarization direction θ of each light source is set to 0°, 45°, 90°, and 135°, respectively. The light source array is symmetrically arranged on both sides of the conveying mechanism with the enamel plate conveying path as the center. When the enamel plate passes through the light source array, the PLC controller illuminates each light source in sequence according to a preset timing sequence of 0°, 45°, 90°, and 135°. The illumination time of each light source is synchronized with the camera exposure time. The camera is installed directly above the enamel plate, and the lens optical axis is perpendicular to the surface of the enamel plate. When the enamel plate enters the detection area through the conveying mechanism, the edge signal of the enamel plate is detected by a photoelectric sensor. When the edge signal of the enamel plate is detected, the original image of the enamel plate is acquired, resulting in the original image sequence {I1(x,y),I2(x,y),I3(x,y),I4(x,y)}.

3. The method for detecting surface defects of enamel plates based on machine vision according to claim 2, characterized in that: The process of fusing the original image using a point-by-point optimal grayscale fusion method to obtain a real-time reflection-suppressed image involves the following steps: Based on the original image sequence {I1(x,y),I2(x,y),I3(x,y),I4(x,y)}, a comprehensive evaluation score is calculated for each pixel in sequence. Overall evaluation score The calculation formula is: ; in, and These are the weighting coefficients. The maximum effective contrast value. To evaluate the overall score, For pixels The local variance in the corresponding neighborhood under the o-th working condition For pixels In the The reflection intensity under the group of working conditions, where o is the working condition index; Real-time reflection suppression image The formula for generating it is: ; ; in, The working condition number that yields the highest overall evaluation score. For the optimal working condition of the pixel grayscale value, For real-time reflection suppression images, This indicates taking the maximum value.

4. The method for detecting surface defects of enamel plates based on machine vision according to claim 3, characterized in that: The process of acquiring a defect-free reflection suppression image of an enamel panel, matching and analyzing the defect-free reflection suppression image and the real-time reflection suppression image using an improved PaDiM algorithm to obtain the differential texture regions and record their coordinates, includes the following steps: Defect-free enamel plate samples were collected and fused using a point-by-point optimal gray-level fusion method to obtain a defect-free reflection suppression image. A normal enamel texture reference model was constructed, and semantic layer optimization was performed on the Wide ResNet-50 in the improved PaDiM algorithm, using only layer 2 semantic features to obtain the optimized Wide ResNet-50. The real-time reflection suppression image was then generated. The region is divided into texture analysis sub-regions. For each texture analysis sub-region, a real-time texture feature vector is extracted using the optimized WideResNet-50. Call the corresponding spatial coordinates The reference model for normal enamel texture is used to calculate the weighted Mahalanobis distance value. Weighted Mahalanobis distance value The calculation formula is: ; in, Coordinates in the image to be detected Feature vectors of texture blocks It is a diagonal weight matrix. It is the inverse of the covariance matrix. The weighted Mahalanobis distance value; Calculate the weighted Mahalanobis distance values ​​for the texture analysis sub-regions of defect-free enamel panels and enamel panels with minor defects, and use the 99.5th percentile as the base threshold. Introduce operating condition correction coefficient final threshold ; When the weighted Mahalanobis distance value of the texture analysis sub-region > When the texture analysis sub-region is determined to be a differential texture region, adjacent differential texture sub-regions are merged to form a continuous differential texture region, and the coordinates of the differential texture region are recorded.

5. The method for detecting surface defects of enamel plates based on machine vision according to claim 4, characterized in that: The construction of the enamel normal texture reference model includes the following steps: The defect-free reflection suppression image is divided into non-overlapping defect-free reflection suppression image blocks. For each defect-free reflection suppression image block, normal texture feature vectors are extracted using Wide ResNet-50. Where (p,q) represents the index coordinates of the defect-free reflection-suppressed image patch in the sample image, and k represents the dataset index, a reference model for normal enamel texture is constructed. ; The formula for calculating the mean vector is: ; in, The total number of training samples. The mean of the feature dimension corresponding to each element. This is a normal texture feature vector; The formula for calculating the covariance matrix is: ; in, For regularization terms, It is a 64th order identity matrix. Let covariance matrix be the variance matrix. It is the transpose of the deviation between the normal texture feature vector and the mean vector.

6. The method for detecting surface defects of enamel plates based on machine vision according to claim 5, characterized in that: Within the differential texture region, feature extraction and fusion of the real-time reflection suppression image are performed using scale attention feature extraction to obtain a real-time fusion matrix. Then, a normal enamel texture reference model is constructed for the defect-free image using scale attention feature extraction, comprising the following steps: The regions with different textures are divided into small-scale, medium-scale, and large-scale regions based on their area. The formula for calculating the actual physical area of ​​the regions with different textures is as follows: ; in, The total number of pixels in the difference region. and The physical size of a pixel. The actual physical area of ​​the region of difference; A scale-channel spatial attention module is used to extract features from real-time reflection suppression images to obtain a real-time fusion matrix. Image patches in different regions are processed by four dilated convolution branches of the scale feature extraction module to output multi-scale feature maps. , , , The feature maps of the four branches are concatenated by channel to obtain an aggregated feature map. Channel statistical vectors are generated through global average pooling. After two layers of MLP mapping, channel weight vectors are generated using the sigmoid function. These channel weight vectors are multiplied by the aggregated feature map by channel to obtain a channel-weighted feature map. The channel-weighted feature map is then split by branch, and each branch feature map is compressed into a spatial encoding map using a 1×1 convolution. The spatial encoding maps of each branch are concatenated to obtain an aggregated spatial map. The aggregated spatial map is then used to generate a spatial weight map through a 7×7 convolution, which is multiplied pixel-by-pixel with the split branch feature maps to obtain four branch feature maps. These four branch feature maps are then concatenated by channel and compressed into a fused feature map using a 1×1 convolution. ; From the fused feature map Structural feature parameters are extracted from the data, and then standardized using the following formula: ; in, Here, i represents the original feature parameters, and i represents the index of the core feature parameter. and The minimum and maximum values ​​of this feature in the standard defect sample set are given. These are the standardized eigenvalues; A 2×3 dimensional real-time fusion matrix is ​​constructed by arranging the six standardized feature values ​​in a fixed order. , ; Five types of typical defects in enamel panels were selected as standard samples. Features of each sample were extracted and a fusion matrix was constructed according to the above process to obtain the standard fusion matrix for each type of defect. , Index for defect categories.

7. The method for detecting surface defects of enamel plates based on machine vision according to claim 6, characterized in that: The extraction of structural feature parameters from the fused feature map is as follows: The formula for calculating the aspect ratio R is: ,in This is the length of the longest side of the circumscribed rectangle. The length of the shortest side; The formula for calculating edge sharpness E is: ; in: The set of pixels at the edge of the defect. This represents the total number of edge pixels. and Let be the magnitude of the Sobel gradient of pixel (x, y) in the x and y directions. For edge sharpness; Internal grayscale transition smoothness The calculation formula is: ; in, For the set of pixels in the defect area, This represents the total number of pixels in the defect area. For pixels grayscale value, The average gray value of the defect area. For the smoothness of internal grayscale transition; The formula for calculating the contour connectivity C is as follows: ,in The number of connected components in the outline; Grayscale contrast The calculation formula is: ; in, The average gray value of the defect area. The average grayscale value of the normal area 5 pixels wide surrounding the defect. This refers to grayscale contrast.

8. The method for detecting surface defects of enamel plates based on machine vision according to claim 7, characterized in that: The process of performing similarity matching between the real-time fusion matrix and the standard fusion matrix to obtain the defect detection results includes the following specific steps: The formula for calculating the cosine similarity between the real-time fusion matrix and the standard fusion matrix is: ; in, For matrix vectorization operations, For real-time fusion matrix, For the first The standard fusion matrix of class-standard defects Represents the vector dot product. Describes the L2 norm of a vector. Cosine similarity between the real-time fusion matrix and the standard fusion matrix; Calculate the real-time fusion matrix Similarity with 5 standard fusion matrices A similarity threshold is set by mixing defective samples. When there is a unique Make ≥ Then the region to be detected is determined to be the first... Class defects; when multiple Make ≥ Then, take the defect type corresponding to the maximum similarity. < If the defect is identified as a suspected defect, the defect detection result is obtained, which includes the defect type and the corresponding structural feature parameters.

9. The method for detecting surface defects of enamel plates based on machine vision according to claim 8, characterized in that: The coordinate transformation of the differential texture region coordinates to obtain the defect location result is as follows: Construct a four-level coordinate transformation system: image pixel coordinate system - camera coordinate system - world coordinate system - enamel plate physical coordinate system. The origin is the top left corner of the real-time reflection suppression image, the u-axis extends horizontally to the right along the image, and the v-axis extends vertically downwards along the image. Camera coordinate system With the optical center of the industrial camera lens as the origin, the x-axis is parallel to the image u-axis, the y-axis is parallel to the image v-axis, and the z-axis is perpendicular to the lens optical axis forward. World coordinate system With the center point of the enamel plate inlet of the conveyor line inspection station as the origin, the X-axis moves along the direction of the conveyor line, the Y-axis is perpendicular to the conveyor line and moves horizontally to the right, and the Z-axis is perpendicular to the conveyor line and moves upward. Enamel plate physical coordinate system With the top left corner of a single enamel panel as the origin, axis A is along the length of the panel, and axis B is along the width of the panel. The formula for transforming from pixel coordinates to camera coordinates is: ; Where (u,v) are the coordinates of the center point of the defect in the image pixel coordinate system. For the camera intrinsic parameter matrix, The inverse of the intrinsic parameter matrix. The fixed working distance from the camera to the enamel plate surface, ( , , () represents the three-dimensional coordinates of the defect in the camera coordinate system; The formula for changing the camera coordinate system to the world coordinate system is: ; in, It is a 3×3 rotation matrix. It is a 3×1 translation matrix, ( , , () represents the three-dimensional coordinates of the defect in the world coordinate system; The final defect location result is obtained, which is the final coordinate of the defect in the physical coordinate system of the enamel plate. The conversion formula from the world coordinate system to the physical coordinate system of the enamel plate is as follows: ; in,( , ) represents the coordinates of the top-left corner vertex of the current enamel panel in the world coordinate system. B) represents the final coordinates of the defect in the physical coordinate system of the enamel plate. Let be the rotation matrix of the enamel plate relative to the world coordinate system.

10. The method for detecting surface defects of enamel plates based on machine vision according to claim 9, characterized in that: The calculation of the comprehensive defect score based on the defect detection results is as follows: A comprehensive defect score is calculated based on the defect detection results. The calculation formula is: ; in, This is a normalization function for the core parameters of the defect. For the comprehensive score of defects, This is a defect density correction term. For defect type weights, For positional weights, Defect density.

Citation Information

Patent Citations

  • Mirror reflection-based texture tile surface defect detection method

    CN118115468A

  • Stainless steel tube surface defect detection method and system

    CN121095233A

  • Machine vision-based detecting method and system for glass bottle bottom defects

    WO2022027949A1

Cited By

  • Glass curtain wall stain segmentation method and device and computer readable storage medium

    CN121962177A

  • A machine vision-based quality detection method for basic cobalt carbonate powder material

    CN122265280A

  • A machine vision-based quality detection method for basic cobalt carbonate powder material

    CN122265280B