Method and system for identifying micro-defects on hydraulic side plate surface
Patent Information
- Application Number
- CN202610939368.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-26
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2046-06-26
AI Technical Summary
在自动化产线基于缺陷识别模型进行连续检测的过程中,常常出现同批次液压侧板的缺陷识别误报频次与漏报频次呈现无规律起伏的问题,导致无缺陷的液压侧板被系统误判为存在缺陷的不合格品,或,实际存在微划痕与微凹坑等缺陷的液压侧板被系统漏判为无缺陷的合格品
[0016] Compared to existing technologies, the advantages of this invention are as follows: This invention utilizes alternating dual-light source illumination and pixel-level gray-scale difference operations to achieve physical separation of oil film interference and real defects by leveraging optical response differences. Combined with adaptive threshold segmentation, it eliminates reflective artifacts and provides clean feature input. Multi-scale convolution and morphological filtering are introduced to cover full-size defects and remove noise. A partial order lattice of defect features is constructed based on descriptors, organizing discrete defects into a hierarchical structure with progressive severity relationships. The drift difference of the partial order lattice is quantified through a sliding time window, generating a composite drift correction operator to perform adaptive gray-scale compensation and sub-pixel translation, ensuring that the model input features always return to the baseline state. This mechanism eliminates the need for model retraining, effectively overcoming the decrease in recognition accuracy caused by light source attenuation and equipment vibration during long-term production line operation. Combined with a three-level confidence level judgment, it reduces boundary sample misjudgments, significantly improving the stability and reliability of industrial image feature extraction and online adaptive correction.
Smart Images

Figure CN122473173B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, and in particular to a method and system for identifying minute defects on the surface of hydraulic side plates. Background Technology As a core component of hydraulic transmission devices, the surface microstructure of hydraulic side plates directly determines the sealing reliability of the entire assembly. In existing technologies, automated production lines commonly employ an online inspection architecture combining machine vision and deep learning. This architecture utilizes industrial cameras to image continuously moving workpieces in real time, and relies on pre-trained networks to extract surface texture features, thus automating the identification of micro-scratches and micro-dimples. This architecture aligns with continuous production cycles and can replace manual labor for batch quality screening.
[0002] Automated production lines typically rely on pre-trained defect recognition models to online identify surface defects in hydraulic side plates. During continuous inspection using these models, irregular fluctuations in the frequency of false positives and false negatives often occur within the same batch of hydraulic side plates. This leads to defect-free side plates being mistakenly identified as defective or, conversely, side plates with micro-scratches or dents being missed and identified as defect-free. This severely impacts the accuracy of hydraulic side plate inspection and the sealing reliability of the final assembled hydraulic transmission system. Therefore, reducing false positives and false negatives during continuous inspection of hydraulic side plates in automated production lines is a pressing issue that needs to be addressed. Summary of the Invention
[0003] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for identifying minute defects on the surface of hydraulic side plates. By separating the reflective areas of the oil film, extracting multi-scale Gaussian Laplace features, constructing a partial order lattice for defect features, and fusing correction with a composite drift correction operator, the method effectively suppresses oil film interference and production line drift, improves the accuracy of minute defect identification, and achieves automated and precise sorting.
[0004] To achieve the above objectives, the present invention adopts the following technical solution: In a first aspect, the present invention provides a method for identifying minute defects on the surface of a hydraulic side plate, comprising the following steps: The original image sequence of the hydraulic side plate surface is acquired. The oil film reflective area is separated and the real defect candidate area is extracted from the original image sequence to obtain the oil film mask and the defect candidate grayscale image. Based on the oil film mask, the oil film interference is suppressed on the defect candidate grayscale image to obtain the purification defect feature map. Multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening are performed on the feature map of purification defects to extract spatial feature descriptor subsets of defect regions, and a partial order lattice of defect features is constructed based on the spatial feature descriptor subsets. Based on the defect feature partial order grid and production line historical operation data, the gray-scale reference offset vector and spatial reference offset vector in the current time window are calculated, and the gray-scale reference offset vector and spatial reference offset vector are fused to generate a composite drift correction operator. The grayscale correction and spatial translation correction are performed on the feature map of the purification defect based on the composite drift correction operator to obtain the corrected image. Then, the defect candidate region in the corrected image is judged for defect category, and the identification result of the small defect on the surface of the hydraulic side plate is output and the sorting instruction is executed.
[0005] Preferably, the step of separating the oil film reflective region and extracting the real defect candidate region from the original image sequence includes: alternately acquiring a frontal white light image under the illumination of a frontal white light source and a side red light image under the illumination of a side red light source to form a dual-source image pair; performing Gaussian filtering to denoise the frontal white light image and the side red light image respectively, and then taking the absolute gray level difference pixel by pixel to obtain a differential gray level image; statistically analyzing the full-image gray level histogram of the differential gray level image and determining the oil film determination threshold, marking the pixel region with the differential gray level value lower than the oil film determination threshold as the oil film region, and marking the region with the differential gray level value higher than or equal to the oil film determination threshold as the defect candidate region, and generating an oil film mask image and a defect candidate gray level image accordingly.
[0006] Preferably, the determination of the oil film judgment threshold by analyzing the full-image grayscale histogram of the statistical differential grayscale image includes: searching for the first local minimum point in the grayscale histogram of the full-image grayscale image from low to high, where the local minimum point is the position of the grayscale value whose frequency is strictly less than the frequency of the adjacent grayscale levels on the left and right; using the grayscale value corresponding to the first local minimum point as the oil film judgment threshold, thereby performing adaptive threshold segmentation on the differential grayscale image to separate the oil film region from the defect candidate region.
[0007] Preferably, the multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening of the purification defect feature map includes: constructing a Gaussian Laplacian convolution kernel by setting the standard deviations of small-scale, medium-scale, and large-scale corresponding to the defect size range; performing two-dimensional convolution on the purification defect feature map to obtain three scale response maps and fusing them into a multi-scale fused response map by taking the maximum value of each pixel; performing binarization and connected component labeling on the multi-scale fused response map; calculating the morphological parameters of each connected component; removing noisy connected components with area or aspect ratio exceeding a preset threshold to obtain effective defect connected components and extracting a spatial feature descriptor subset.
[0008] Preferably, obtaining the effective defect connected domain and extracting the spatial feature descriptor subset includes: calculating the centroid coordinates, area, perimeter, major-minor axis ratio, circularity, and internal gray-level mean and standard deviation of each effective defect connected domain to form a multi-dimensional feature vector; determining the partial order relationship between vectors using area, internal gray-level mean, and circularity as partial order comparison dimensions; calculating the global supremum and infimum nodes; and constructing a directed acyclic graph that stores feature vectors and whose edges represent the partial order direction as a defect feature partial order lattice.
[0009] Preferably, the calculation of the grayscale reference offset vector and the spatial reference offset vector within the current time window includes: extracting the reference defect feature partial order grid of the first calibration of the production line, establishing a sliding time window to summarize the features of the most recent K side plates to construct the current batch defect feature partial order grid; calculating the difference between the global grayscale mean and the grayscale standard deviation mean in the reference defect feature partial order grid and the current batch defect feature partial order grid respectively to form the grayscale reference offset vector, and calculating the difference between each component of the centroid coordinate mean of the two to form the spatial reference offset vector.
[0010] Preferably, the step of generating a composite drift correction operator after constructing a spatial reference offset vector includes: normalizing each component of the grayscale reference offset vector and the spatial reference offset vector by the corresponding reference global grayscale mean, reference grayscale standard deviation mean, or total number of image pixels to obtain four normalized offset coefficients, and combining the four coefficients into a four-dimensional vector as the composite drift correction operator.
[0011] Preferably, the step of performing grayscale correction and spatial translation correction on the purification defect feature map based on the composite drift correction operator to obtain the corrected image includes: extracting the normalized grayscale offset coefficient and the normalized grayscale standard deviation offset coefficient in the composite drift correction operator, performing reverse offset compensation and dispersion scaling on the grayscale values of all pixels in the image according to a preset compensation formula; extracting the normalized spatial offset coefficient in the operator to calculate the negative translation amount, and using bilinear interpolation to complete the sub-pixel level spatial translation to obtain the fully corrected image.
[0012] Preferably, the reverse offset compensation and dispersion scaling includes: obtaining the original grayscale value of each pixel in the purification defect feature map, subtracting the product of the normalized grayscale offset coefficient and the reference global grayscale mean as the numerator, dividing it by the sum of the product of the normalized grayscale standard deviation offset coefficient and the reference grayscale standard deviation mean as the denominator, and calculating the grayscale value of each pixel after grayscale correction.
[0013] Preferably, the defect category determination for the defect candidate region in the corrected image includes: cropping a fixed-size local image patch in the corrected image based on the centroid coordinates of each effective defect connected region in the spatial feature descriptor subset; inputting the local image patch into a pre-trained convolutional neural network classification model, outputting the probability vector of each defect category through multi-layer convolutional feature extraction and fully connected classification layers, and taking the category and score corresponding to the highest probability as the determination result.
[0014] Preferably, taking the category and score corresponding to the highest probability as the judgment result includes: if the judgment labels of all local image blocks are qualified, the current side plate is marked as qualified; if there are defective labels and the confidence level is greater than or equal to the preset judgment confidence threshold, it is marked as unqualified; if there are defective labels but the confidence levels are all less than the preset threshold, it is marked as a product to be re-inspected; and the pneumatic push rod of the production line sorting device is controlled to complete the sorting according to the marking result.
[0015] Secondly, the present invention provides a hydraulic side plate surface micro-defect recognition system for implementing the aforementioned hydraulic side plate surface micro-defect recognition method, comprising: an image acquisition and preprocessing module for acquiring original image sequences of the hydraulic side plate surface and performing oil film reflective area separation and real defect candidate area extraction, outputting a purification defect feature map; a feature extraction and partial order grid construction module for performing multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening on the purification defect feature map, extracting a spatial feature descriptor set and constructing a defect feature partial order grid; a drift quantization module for calculating grayscale reference offset vectors and spatial reference offset vectors based on the defect feature partial order grid and historical production line operation data, and fusing them to generate a composite drift correction operator; and a defect recognition and sorting module for performing grayscale correction and spatial translation correction based on the composite drift correction operator to obtain a corrected image, performing defect category determination on the defect candidate area and outputting the recognition result to drive production line sorting instructions.
[0016] Compared to existing technologies, the advantages of this invention are as follows: This invention utilizes alternating dual-light source illumination and pixel-level gray-scale difference operations to achieve physical separation of oil film interference and real defects by leveraging optical response differences. Combined with adaptive threshold segmentation, it eliminates reflective artifacts and provides clean feature input. Multi-scale convolution and morphological filtering are introduced to cover full-size defects and remove noise. A partial order lattice of defect features is constructed based on descriptors, organizing discrete defects into a hierarchical structure with progressive severity relationships. The drift difference of the partial order lattice is quantified through a sliding time window, generating a composite drift correction operator to perform adaptive gray-scale compensation and sub-pixel translation, ensuring that the model input features always return to the baseline state. This mechanism eliminates the need for model retraining, effectively overcoming the decrease in recognition accuracy caused by light source attenuation and equipment vibration during long-term production line operation. Combined with a three-level confidence level judgment, it reduces boundary sample misjudgments, significantly improving the stability and reliability of industrial image feature extraction and online adaptive correction. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of the method for identifying minute defects on the surface of the hydraulic side plate in this invention; Figure 2 This is a diagram showing the alternating illumination setup of dual light sources in an embodiment of the present invention; Figure 3 This is a pixel-level grayscale difference operation diagram in an embodiment of the present invention; Figure 4 This is a diagram illustrating the multiplication operation between the oil film mask and the grayscale image of the defect candidate in an embodiment of the present invention. Figure 5 This is a multi-scale Gaussian Laplacian convolution fusion diagram in an embodiment of the present invention; Figure 6 This is a connected component labeling diagram in an embodiment of the present invention; Figure 7 This is a spatial feature descriptor vector representation diagram in an embodiment of the present invention; Figure 8 This is a partial order lattice structure diagram of defect features in an embodiment of the present invention; Figure 9 This is a vector diagram of the composite drift correction operator in an embodiment of the present invention; Figure 10 This is a functional block diagram of the hydraulic side plate surface micro-defect identification system in this invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Example 1: Please see Figure 1 As shown, this embodiment provides a method for identifying minute defects on the surface of a hydraulic side plate, including: S1: Collect the original image sequence of the hydraulic side plate surface, perform oil film reflective area separation and real defect candidate area extraction on the original image sequence to obtain oil film mask and defect candidate grayscale image, and suppress oil film interference on the defect candidate grayscale image based on the oil film mask to obtain the purification defect feature map; Further, step S1 includes: S11: The hydraulic side plate on the conveyor belt is continuously captured by an industrial area array camera above the production line under multi-angle light source illumination to obtain the original image sequence of the hydraulic side plate surface. Further, step S11 includes: S111: An industrial area scan camera is fixedly installed directly above the production line conveyor belt. The optical axis of the lens of the industrial area scan camera is perpendicular to the plane of the conveyor belt. The installation height of the industrial area scan camera is determined according to the maximum external dimensions of the hydraulic side plate and the field of view of the lens, so that a single frame image can completely cover the entire surface area of a hydraulic side plate. The resolution of the industrial area scan camera is determined according to the minimum defect size that needs to be detected on the surface of the hydraulic side plate. For example, if it is necessary to detect scratches with a size of not less than 0.05 mm, and the maximum external dimensions of the hydraulic side plate are 120 mm by 80 mm, then the resolution of the industrial area scan camera is not less than 2400 pixels by 1600 pixels, to ensure that the actual physical size corresponding to each pixel is not greater than 0.05 mm. In this embodiment, a Baslerac A2440-75um industrial area scan camera is actually selected, with a resolution of 2448 pixels by 2048 pixels, which meets the above resolution requirements. A forward-facing white light source and a side-facing red light source are arranged around the industrial area scan camera. The forward-facing white light source is mounted on a ring-shaped bracket directly below the industrial area scan camera, with its beam direction parallel to the optical axis of the camera lens and an illumination angle of zero degrees, i.e., directly and perpendicularly illuminating the surface of the hydraulic side plate. The side-facing red light source is mounted on a strip-shaped bracket on the side of the conveyor belt, with its beam direction at a preset side-facing illumination angle to the normal direction of the hydraulic side plate surface. The effective range of the preset side-facing illumination angle is greater than 45 degrees and less than 85 degrees. The basis for selecting this range is that when the side-facing illumination angle is greater than 45 degrees, the specular reflection direction of the oil film surface can be sufficiently deviated from the optical axis of the industrial area scan camera lens, so that the oil film area presents a low grayscale response in the side-facing red light image; when the side-facing illumination angle is less than 85 degrees, the effective illumination area of the side-facing red light source on the surface of the hydraulic side plate can still cover the entire area to be inspected, and the effective illumination light flux will not be insufficient due to an excessively large incident angle.
[0021] See Figure 2 This is a schematic diagram of the alternating illumination setup of dual light sources provided in an embodiment of this application. Figure 2As shown in the figure, the physical layout of the optical system at the hydraulic side plate surface defect acquisition station is illustrated. An industrial area array camera is fixedly mounted directly above the conveyor belt, with its lens optical axis perpendicular to the conveyor belt plane. A positive white light source, mounted on a ring-shaped bracket directly below the camera, has its beam direction parallel to the lens optical axis, achieving zero-degree angle vertical illumination of the hydraulic side plate surface. A lateral red light source is mounted on a strip-shaped bracket to the side of the conveyor belt, with its beam direction at a preset lateral illumination angle to the normal direction of the hydraulic side plate surface. Figure 2 The angle is marked with an arc. When a very thin film of cutting fluid remains on the surface of a hydraulically machined side panel, both the reflective area of the oil film and the actual defect area may exhibit high-brightness grayscale responses under single positive white light illumination, making reliable differentiation difficult. Introducing a side red light source causes specular reflection of the side-incident light in the oil film area due to its nearly flat and smooth surface. The reflection direction is away from the camera lens optical axis, resulting in a lower grayscale response in the oil film area in the side red light image. Meanwhile, real defects such as scratches, pits, and microcracks, due to their irregular microscopic geometry, experience diffuse reflection and scattering of the side red light at the defect edges and inner walls of the depressions. Some of the scattered light enters the camera lens, allowing the defect area to maintain a recognizable grayscale response. This dual-light source alternating illumination layout utilizes the differentiated optical response characteristics of the oil film and defects to light at different incident angles, providing a physical separation basis for subsequent pixel-level grayscale difference calculations. It can fundamentally separate the oil film interference signal from the effective defect signal without relying on empirical annotation.
[0022] S112: When the conveyor belt transports the hydraulic side plate to the acquisition station directly below the industrial area array camera, the production line positioning sensor sends a trigger signal. The industrial area array camera acquires one frame of image under the illumination of a forward white light source, recorded as the forward white light image. Subsequently, the forward white light source is turned off, and the side red light source is turned on. The industrial area array camera acquires one frame of image under the illumination of the side red light source, recorded as the side red light image. The forward white light image and the side red light image constitute a pair of dual-light source images for the current hydraulic side plate. Multiple hydraulic side plates continuously transported by the production line conveyor belt pass through the acquisition station in sequence. Each hydraulic side plate acquires a pair of dual-light source images. All dual-light source image pairs are arranged in the order of acquisition time to form the original image sequence of the hydraulic side plate surface.
[0023] Specifically, step S11 employs a dual-source alternating illumination scheme of a forward white light source and a side red light source, an imaging strategy specifically designed for the optical reflection characteristics of the hydraulic side plate's metal surface. After machining, the hydraulic side plate retains an extremely thin, unevenly thick cutting fluid oil film on its surface. This oil film produces irregular reflections when illuminated. Under forward white light illumination, both the oil film area and the actual defect area on the hydraulic side plate's metal surface may exhibit a high-brightness grayscale response. A single forward white light image is insufficient to reliably distinguish between the oil film reflection and the actual defect. After introducing a side-emitting red light source, because the thickness of the oil film layer is much smaller than the wavelength of visible light, and the surface of the oil film is approximately flat and smooth, the specular reflection direction generated when the side-emitting red light illuminates the oil film area is far from the optical axis of the industrial area array camera lens. Therefore, the grayscale response of the oil film area in the side-emitting red light image is low. However, real defects such as scratches, dents, and microcracks have irregular geometric morphological changes at the microscopic level. When the side-emitting red light illuminates the defect area, the light undergoes diffuse reflection and scattering at the defect edges and the inner walls of the depressions. Some of the scattered light enters the lens of the industrial area array camera, allowing the defect area to still maintain a recognizable grayscale response in the side-emitting red light image. The difference in grayscale response between the oil film area and the defect area in the frontal white light image and the side-emitting red light image provides the physical basis for the pixel-level grayscale difference operation in the subsequent step S12, enabling the effective separation of the reflective oil film area from the real defect candidate area through difference operations.
[0024] S12: Perform pixel-level gray-level difference operation on each group of positive white light image and side red light image in the original image sequence to obtain the difference gray-level image; Further, step S12 includes: S121: Perform Gaussian filtering denoising processing on the forward white light image and the side red light image respectively to obtain the filtered forward white light image and the filtered side red light image. The convolution kernel size of the Gaussian filter is determined according to the imaging noise level of the industrial area array camera. For example, the convolution kernel size of the Gaussian filter can be set to 5 pixels by 5 pixels, and the standard deviation of the Gaussian filter can be set to 1.0 pixel. While suppressing the grayscale fluctuations caused by the thermal noise of the industrial area array camera's photosensitive chip and the flicker of the light source, the edge grayscale gradient information of the surface defects of the hydraulic side plate is preserved.
[0025] S122: The absolute grayscale difference between the filtered forward white light image and the filtered lateral red light image is taken pixel-by-pixel to obtain a difference grayscale image. Specifically, for the image at coordinates... Line 1 Column of pixels (where) Represents the row coordinate of a pixel, with a value ranging from 1 to the total number of vertical pixels in the image; Represents the column coordinate of a pixel, ranging from 1 to the total number of horizontal pixels in the image. In the differential grayscale image, the coordinate is the […]. Line 1 The pixel grayscale value of the column is equal to the coordinate of the filtered positive white light image. Line 1 The pixel grayscale value of the column and the coordinates in the filtered lateral red light image are the first... Line 1 The absolute value of the difference between the pixel grayscale values of the column. See also Figure 3 This is a schematic diagram of pixel-level grayscale difference operation provided in an embodiment of this application. For example... Figure 3 As shown, the left matrix is the filtered image under forward white light, where both the oil film reflective area and the defect candidate area appear as bright grayscale pixel blocks. The middle matrix is the filtered image under lateral red light. Due to the specular reflection of the lateral incident red light from the oil film surface, the grayscale of the oil film area is significantly reduced, appearing as dark pixel blocks. The defect area, due to its irregular microstructure, still maintains a certain grayscale response, but the intensity varies. The two images are processed by taking the absolute grayscale difference pixel by pixel to obtain the differential grayscale image on the right. The oil film reflective area, because its grayscale value is close in both frames, approaches zero after the difference and appears black. The real defect area, due to the significant difference in scattering response under the two light source conditions, retains a high grayscale contrast after the difference and appears as a bright area. In the scenario of hydraulic side plate surface inspection, the thickness and distribution of the residual cutting fluid oil film from machining vary with batch, resulting in significant uncertainty in the grayscale response of the oil film reflection. This pixel-level differential operation method utilizes the physical characteristic that the gray-level response difference of the oil film layer is minimal under two lighting conditions, namely positive white light and side red light, while the gray-level response difference of the real defect is significant under the two conditions. Through simple pixel-by-pixel arithmetic operations, the oil film interference and defect signal can be effectively separated, providing a gray-level histogram bimodal structure with clear distribution characteristics for subsequent adaptive threshold segmentation.
[0026] S123: Perform adaptive threshold segmentation on the differential grayscale image, marking pixel regions with differential grayscale values below the oil film determination threshold as oil film regions, and pixel regions with differential grayscale values above or equal to the oil film determination threshold as defect candidate regions. The oil film determination threshold is adaptively calculated based on the valley position of the full-image grayscale histogram of the differential grayscale image. Specifically, the adaptive calculation process of the oil film determination threshold is as follows: statistically analyze the frequency distribution of gray values of all pixels in the differential grayscale image and draw a grayscale histogram of the entire image; search for the first local minimum point in the grayscale histogram of the entire image from low to high gray values. The local minimum point refers to the gray value position in the grayscale histogram whose frequency is strictly less than the frequency of the adjacent gray level on the left (adjacent gray levels with a grayscale difference of 1) and strictly less than the frequency of the adjacent gray level on the right. During the search, gray levels with a frequency of zero are skipped (i.e., when the frequency of multiple consecutive gray levels is zero, it is not considered a minimum point, and the search continues in the direction of higher gray levels until a gray level with a frequency greater than zero is encountered); the gray value corresponding to the first local minimum point is used as the oil film determination threshold. The physical meaning of the first local minimum point is the valley value between the differential grayscale value distribution of the oil film reflective area and the differential grayscale value distribution of the real defect area. The differential grayscale values of the oil film reflective area are concentrated near zero, forming the first peak of the grayscale histogram. The differential grayscale values of the real defect area are larger, forming the second peak of the grayscale histogram. The first local minimum point is located at the valley between the two peaks. Using this as a segmentation threshold can maximize the separation of oil film reflective pixels from defect candidate pixels. For example, assuming that the first local minimum point appears at a grayscale value of 12 in the overall grayscale histogram of the differential grayscale image, the oil film determination threshold is set to 12. Pixels with a differential grayscale value less than 12 are marked as oil film areas, and pixels with a differential grayscale value greater than or equal to 12 are marked as defect candidate areas.
[0027] S13: Generate an oil film mask based on the marking results of step S123. In the oil film mask, the pixel values of the oil film region are zero, and the pixel values of the defect candidate region are one. Specifically, the size of the oil film mask is the same as the size of the differential grayscale image. Each pixel in the differential grayscale image is traversed. If the currently traversed pixel is marked as an oil film region in step S123, the pixel value at the corresponding coordinate position in the oil film mask is set to zero; if the currently traversed pixel is marked as a defect candidate region in step S123, the pixel value at the corresponding coordinate position in the oil film mask is set to one.
[0028] S14: Extract the grayscale information corresponding to the candidate defect regions from the filtered forward white light image to obtain a candidate defect grayscale image. Specifically, the size of the candidate defect grayscale image is the same as the size of the filtered forward white light image. Iterate through each pixel in the filtered forward white light image. If the pixel value at the corresponding coordinate position in the oil film mask image is one, then the pixel grayscale value at the corresponding coordinate position in the candidate defect grayscale image is equal to the pixel grayscale value at the corresponding coordinate position in the filtered forward white light image; if the pixel value at the corresponding coordinate position in the oil film mask image is zero, then the pixel grayscale value at the corresponding coordinate position in the candidate defect grayscale image is set to zero. The filtered forward white light image, rather than the filtered lateral red light image, is chosen as the source for extracting the grayscale information of the defects because the grayscale contrast of the defects on the hydraulic side plate surface is higher under forward white light illumination, and the grayscale difference between the defect area and the non-defect background area is larger, which is beneficial for the fine extraction of defect features in the subsequent step S2.
[0029] S15: Perform pixel-by-pixel multiplication between the oil film mask and the defect candidate grayscale image. Set the grayscale values of the oil film region to zero, while retaining the original grayscale values of the defect candidate region, to obtain the cleaned defect feature map. The data type of the cleaned defect feature map is the same as that of the filtered forward white light image. See also... Figure 4 This is a schematic diagram of pixel-by-pixel multiplication operation between the oil film mask and the grayscale image of the defect candidate provided in the embodiments of this application. Figure 4 As shown, the upper matrix is an oil film mask image, where white pixels represent candidate defect regions with a pixel value of 1, and black pixels represent oil film regions with a pixel value of 0. The middle matrix is a candidate grayscale image of defects, containing pixel blocks of different grayscale levels. It retains both the original grayscale information of the defect region and the grayscale information of the oil film coverage area. After pixel-by-pixel multiplication, the lower cleaned defect feature image is obtained. In the oil film mask image, the grayscale value corresponding to the position with a pixel value of 0 is forced to zero and displayed as black, while the grayscale value corresponding to the position with a pixel value of 1 remains unchanged, thus completely preserving the grayscale feature information of the defect. In the actual working conditions of hydraulic side plate surface inspection, if oil film reflective pseudo-defects are not eliminated, they will directly participate in subsequent multi-scale gradient analysis and connected component morphological screening, and may be misidentified as scratches or pits, leading to an increase in the false detection rate of the defect recognition model. By performing binary multiplication on the oil film mask, the oil film interference can be completely eliminated with pixel-by-pixel precision, while not causing any attenuation or distortion of the gray-level gradient information of the real defect area. This provides a clean input after removing the oil film interference for the subsequent fine extraction of defect features.
[0030] The overall function of step S1 is to address the imaging interference caused by residual cutting fluid oil film on the surface of the hydraulic side plate after machining. Through the collaborative processing of alternating dual-light source acquisition and pixel-level gray-level difference calculation, a physical separation mechanism based on the optical response differences between oil film and defects under different lighting conditions is established. The gray-level response difference of the oil film reflective area is minimal under both forward white light and side red light conditions, while the gray-level response difference of the real defect area is significant under both light source conditions. Utilizing this physical characteristic for difference calculation can fundamentally separate the oil film interference signal from the effective defect signal, rather than relying on empirical labeling of oil film and defects in the training data. Adaptive threshold segmentation dynamically determines the segmentation threshold based on the valley position of the gray-level histogram, without relying on a preset fixed threshold, and can adapt to changes in the thickness and distribution of the oil film on the surface of different batches of hydraulic side plates. The purified defect feature map output from step S1 provides a clean input after removing oil film interference for defect feature extraction in the subsequent step S2, avoiding the risk of misjudgment caused by false defects due to oil film reflection. If the oil film separation process in step S1 is missing, the spatial feature descriptor subset extracted in the subsequent step S2 will contain a large amount of feature information of oil film reflective pseudo-defects, resulting in a significant increase in the false detection rate of the defect identification model in step S4.
[0031] S2: Perform multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening on the purification defect feature map to extract spatial feature descriptor subsets of defect regions, and construct a partial order lattice of defect features based on the spatial feature descriptor subsets; Further, step S2 includes: S21: Perform Gaussian Laplacian convolution operations at three different scales on the purification defect feature map to obtain small-scale response maps, medium-scale response maps, and large-scale response maps respectively; take the maximum value of each pixel in the small-scale response map, medium-scale response map, and large-scale response map to obtain a multi-scale fused response map.
[0032] Further, step S21 includes: S211: Set the standard deviation parameters for three Gaussian Laplacian convolution kernels, denoted as small-scale standard deviation, medium-scale standard deviation, and large-scale standard deviation, respectively. The small-scale, medium-scale, and large-scale standard deviations are determined based on the defect size range that needs to be detected on the hydraulic side plate surface. The small-scale standard deviation corresponds to the gray-level gradient response at the smallest defect size level, the large-scale standard deviation corresponds to the gray-level gradient response at the largest defect size level, and the medium-scale standard deviation is the geometric mean of the small-scale and large-scale standard deviations. The reason for choosing the geometric mean is to achieve equally spaced sampling in logarithmic space, making the response range of the three scales more uniformly cover the defect size range. For example, if the defect size range that needs to be detected on the hydraulic side plate surface is 0.05 mm to 2.0 mm, corresponding to a pixel scale range of 1 pixel to 40 pixels, then the small-scale standard deviation can be set to 1.0 pixel, the large-scale standard deviation can be set to 6.0 pixels, and the medium-scale standard deviation is... Pixel.
[0033] S212: Construct three Laplacian Gaussian convolution kernels with small-scale, medium-scale, and large-scale standard deviations respectively. Perform two-dimensional convolution operations on the cleaned defect feature map and the three Laplacian Gaussian convolution kernels respectively to obtain small-scale, medium-scale, and large-scale response maps. The three convolution operations are independent of each other, have no serial dependency, and can be executed in parallel. The physical meaning of the Laplacian Gaussian convolution operation is as follows: First, Gaussian smoothing is performed on the image to suppress noise. Then, the Laplacian operator operation is performed on the smoothed image to extract the second derivative of the image gray-level function (i.e., the Laplacian operator). The second derivative of the gray-level function crosses zero at the defect edge. The defect region and the background region show response values with opposite signs due to the different directions of gray-level extrema. Laplace Gaussian convolution kernels with different standard deviations have different response intensities to defect regions of different sizes. Laplace Gaussian convolution kernels with small standard deviations have a stronger response to tiny scratches and tiny pits, while Laplace Gaussian convolution kernels with large standard deviations have a stronger response to defect regions with larger areas.
[0034] S213: For each coordinate position in the small-scale, medium-scale, and large-scale response maps, take the maximum of the three response values to generate a multi-scale fused response map. See also Figure 5 This is a schematic diagram of multi-scale Gaussian Laplacian convolution fusion provided in an embodiment of this application. For example... Figure 5As shown, the three matrices on the left are the small-scale response map, the medium-scale response map, and the large-scale response map, respectively. These are obtained by performing two-dimensional convolution operations between the cleaned defect feature map and Gaussian Laplacian convolution kernels with the small-scale, medium-scale, and large-scale standard deviations, respectively. In the small-scale response map, isolated bright pixel blocks appear in the upper left region, corresponding to the strong gradient response of micro-scratches. In the medium-scale response map, patches of bright pixel blocks appear in the upper part of the map, corresponding to the gradient response of medium-sized defects. In the large-scale response map, large areas of bright pixel blocks appear in the lower right region, corresponding to the gradient response of larger defect areas. The three response maps are fused by taking the maximum value pixel by pixel to obtain the multi-scale fused response map on the right, preserving the gradient response signals of defects at all size levels. In the hydraulic side plate surface inspection scenario, the size range of the defects to be inspected is quite large, ranging from micro-scratches at the 0.05 mm level to pits at the 2.0 mm level. The problem of insufficient or overly smoothed response to defects of specific sizes by single-scale Gaussian Laplacian convolution is alleviated here. The fusion strategy of taking the maximum value pixel by pixel ensures that the strongest gradient response signal of the defect can be retained in the fused response map regardless of the defect size level, which is beneficial to the accurate execution of subsequent connected component labeling and morphological screening.
[0035] S22: Perform binarization processing on the multi-scale fusion response map to obtain a binary defect region map; perform connected component labeling on the binary defect region map to obtain a connected component labeling map. Specifically, the binarization processing uses the Otsu thresholding method to automatically determine the binarization threshold. The Otsu thresholding method selects the gray level that maximizes the inter-class variance between the foreground pixel class and the background pixel class as the binarization threshold by traversing all gray levels of the image as candidate thresholds. Pixels in the multi-scale fusion response map with pixel values greater than or equal to the binarization threshold are set to one, and pixels with pixel values less than the binarization threshold are set to zero, generating a binary defect region map. Perform an 8-connected component labeling algorithm on the binary defect region map, grouping all pixels in the binary defect region map with pixel values of one that are interconnected within 8 neighborhoods into the same connected component. Each connected component is assigned a unique connected component number, generating a connected component labeling map. See also Figure 6 This is a schematic diagram of connected component labeling provided in an embodiment of this application. For example... Figure 6 As shown, the dark grid background area represents the background area with a pixel value of zero after binarization. The figure uses four different filling textures to identify four effective defect connected regions. The legend on the right illustrates the correspondence between each filling texture and the effective defect connected region number, as well as the identification of the background area. Effective defect connected region 1 appears as a narrow area filled with a diagonal texture in the upper left corner; effective defect connected region 2 is located in the upper right corner and filled with a dot texture; effective defect connected region 3 is located in the lower left corner and filled with a cross texture, presenting a relatively compact block shape; and effective defect connected region 4 is located in the lower right corner and filled with a reverse diagonal texture, presenting an irregular distribution. In the surface inspection of hydraulic side plates, the response after multi-scale fusion... Figure 2 The valued foreground pixels may contain non-defect regions such as residual imaging noise and residual processing texture. By using the 8-connected domain labeling algorithm to group spatially connected foreground pixels into the same connected domain and assigning a unique number, morphological parameters such as area, perimeter, aspect ratio, and roundness can be calculated independently for each connected domain. Then, by using the dual constraints of the minimum defect area threshold and the maximum aspect ratio threshold, noisy connected domains and processing texture connected domains are eliminated, and only effective defect connected domains that conform to the geometric morphology of defects are retained, thereby reducing the false alarm rate of subsequent feature analysis and defect classification.
[0036] S23: Calculate morphological parameters for each connected component in the connected component labeled graph. These morphological parameters include the area, perimeter, ratio of major to minor axis, and circularity of the connected component. The area is the total number of pixels contained within the connected component; the perimeter is the total number of pixels at the boundary of the connected component; the ratio of major to minor axis is the ratio of the major axis length to the minor axis length of the smallest circumscribed ellipse of the connected component; and the circularity of the connected component is calculated using the following formula: in, For the circularity of the connected components, The area of the connected region. The perimeter of the connected region is defined as the circularity value, which ranges from zero to one. A circularity value closer to one indicates a more circular shape. Connected regions with an area smaller than the minimum defect area threshold are classified as noisy connected regions. Connected regions with a major-minor axis ratio greater than the maximum major-minor axis ratio threshold are also classified as noisy connected regions. These noisy connected regions are removed from the connected region labeling map, and the remaining connected regions are marked as valid defect connected regions. The minimum defect area threshold is determined based on the pixel area corresponding to the minimum detectable defect size on the hydraulic side plate surface. For example, if the minimum defect size is 0.05 mm corresponding to 1 pixel, the minimum defect area threshold can be set to 3 pixels. Connected regions with an area smaller than 3 pixels are considered residual imaging noise rather than actual defects. The maximum major-minor axis ratio threshold is determined based on the geometric characteristics of the hydraulic side plate's processing texture direction. For example, the maximum major-minor axis ratio threshold can be set to 15. Narrow connected regions with a major-minor axis ratio exceeding 15 are considered residual processing texture rather than surface defects.
[0037] S24: Extract spatial feature descriptors for each effective defect connected component. These descriptors include the centroid coordinates, area, perimeter, aspect ratio, circularity, mean grayscale value, and standard deviation of the grayscale values within the connected component. The centroid coordinates are the arithmetic mean of all pixel coordinates within the effective defect connected component, calculated by taking the mean horizontal and vertical coordinates to form a two-dimensional centroid coordinate system. The mean grayscale value within the connected component is the arithmetic mean of all pixel grayscale values covered by the effective defect connected component in the cleanup defect feature image. The standard deviation of the grayscale values within the connected component is the standard deviation of all pixel grayscale values covered by the effective defect connected component in the cleanup defect feature image. All spatial feature descriptors for all effective defect connected components are compiled into a spatial feature descriptor set. The data structure of the spatial feature descriptor set is an ordered list, where each element is a multidimensional vector containing the aforementioned feature components. See also... Figure 7 , is the spatial feature descriptor vector representation diagram provided in the embodiments of this application.
[0038] like Figure 7 As shown, the left region is a schematic diagram of the morphology of the effective defect connected domain. Irregular closed contour lines mark the boundaries of the defect connected domains retained after morphological screening. Internal markers indicate the centroid position of the connected domain, and the intersecting dashed axes represent the major and minor axes of the minimum circumscribed ellipse of the connected domain. The right region is the spatial feature descriptor vector corresponding to this connected domain. Vertically arranged independent feature boxes quantify the geometric and grayscale attributes of the connected domain. The arrow in the middle indicates the mapping transformation relationship from the image connected domain to the feature vector. In the identification of surface defects on hydraulic side plates, the discrete connected domains extracted through multi-scale response processing and morphological screening need to be transformed into structured data for subsequent partial order relation construction. Through feature extraction processing, the spatial location, geometric shape, and internal grayscale distribution information of the effective defect connected domain are independently calculated and recombined into a fixed-length multi-dimensional feature vector. Each feature box corresponds sequentially to the horizontal component of the centroid coordinates, the vertical component of the centroid coordinates, the area of the connected domain, the perimeter of the connected domain, the ratio of the major and minor axes of the connected domain, the circularity of the connected domain, the mean grayscale value within the connected domain, and the standard deviation of the grayscale value within the connected domain. This vectorization transforms unstructured image connected components into numerical data that can directly participate in partial order comparison and baseline drift quantization. It eliminates the representational differences of different defects in terms of morphology and grayscale, providing a standardized data carrier for subsequent construction of defect feature partial order lattices and calculation of composite drift correction operators. This ensures the stability of feature inputs and the accuracy of classification judgment in the long-term operation of the defect identification model on the production line.
[0039] S25: Constructing a partially ordered lattice of defect features based on spatial feature description subsets; Further, step S25 includes: S251: Define the partial order relation between spatial feature descriptors. The rule for determining the partial order relation is as follows: For any two spatial feature descriptors in the set of spatial feature descriptors, denoted as spatial feature descriptor A and spatial feature descriptor B, if the area of the connected domain of spatial feature descriptor A is less than or equal to the area of the connected domain of spatial feature descriptor B, and the mean gray value within the connected domain of spatial feature descriptor A is less than or equal to the mean gray value within the connected domain of spatial feature descriptor B, and the circularity of the connected domain of spatial feature descriptor A is less than or equal to the circularity of the connected domain of spatial feature descriptor B, then the partial order of spatial feature descriptor A is determined to be less than or equal to that of spatial feature descriptor B. The partial order relation selects only three dimensions for comparison: area of connected domains, mean gray value within connected domains, and circularity of connected domains. Other dimensions (centroid coordinates, perimeter of connected domains, aspect ratio of connected domains, and standard deviation of gray value within connected domains) are not included in the partial order comparison. The reason is that: the area of connected domains reflects the size of the defect, the mean gray value within connected domains reflects the severity of the gray value contrast of the defect, and the circularity of connected domains reflects the regularity of the defect shape. These three dimensions together depict the hierarchical progression of defects from small to large, from shallow to deep, and from irregular to regular, which can establish a meaningful partial order structure of defect severity. However, the centroid coordinates reflect the spatial location of the defect, the perimeter of connected domains is highly correlated with the area, the aspect ratio of connected domains has redundant correlation with the circularity, and the standard deviation of gray value within connected domains reflects the dispersion of gray value distribution rather than its severity. These dimensions are not suitable as comparison dimensions for the hierarchical progression of defect severity.
[0040] S252: Arrange all spatial feature descriptors in the spatial feature descriptor set according to the partial order relation defined in step S251. Calculate the supremum and infimum in the partial order relation for any two spatial feature descriptors. The supremum is a virtual descriptor formed by taking the maximum value of each of the three partial order comparison dimensions: area of the connected domain, mean gray value within the connected domain, and circularity of the connected domain. The infimum is a virtual descriptor formed by taking the minimum value of each of the three partial order comparison dimensions: area of the connected domain, mean gray value within the connected domain, and circularity of the connected domain. Take the global maximum value in each of the three partial order comparison dimensions of all spatial feature descriptors to form a global supremum node (top element), and take the global minimum value to form a global infimum node (bottom element), to ensure that the constructed structure satisfies the axiom of lattices (i.e., any two elements have unique supremum and infimum). Construct a defect feature partial order lattice by connecting all spatial feature descriptors and their supremum and infimum to form a directed hierarchical relation. The data structure of the defect feature partial order lattice is a directed acyclic graph. Each node in the defect feature partial order lattice stores a spatial feature descriptor or a virtual descriptor. The directed edges between nodes represent the partial order relationship, and the direction of the directed edges is from the node with the smaller partial order to the node with the larger partial order.
[0041] See Figure 8 This is a schematic diagram of the partial order lattice structure of defect features provided in an embodiment of this application. For example... Figure 8 As shown, the bottom of this directed acyclic graph (DAG) consists of global infimum nodes (bottom elements), and the top consists of global supremum nodes (top elements). The circular nodes in the middle layers represent spatial feature descriptors of different effective defect connected domains. The size of the node reflects the comprehensive magnitude of the descriptor in three partial order comparison dimensions: connected domain area, average gray level within the connected domain, and connected domain circularity. The directed edges between nodes represent partial order relationships, with the direction pointing from the node with the smaller partial order to the node with the larger partial order. The legend on the left illustrates the graphical meaning of the spatial feature descriptor nodes and the directed edges of the partial order relationships. In the long-term operation scenario of the production line for hydraulic side plate surface inspection, the defect feature partial order grid organizes discrete defect feature points into a hierarchical directed acyclic graph, preserving the hierarchical progression relationship between defects in three dimensions: area, gray level contrast, and shape regularity, from small to large, from shallow to deep, and from irregular to regular. When light decay of the light source or camera position shift during production line operation causes slow drift in imaging features, the gray mean and centroid coordinates of nodes in the partial order grid will shift as a whole. Subsequent steps quantify the degree of drift by comparing the structural differences between the baseline defect feature partial order grid and the current batch defect feature partial order grid. Compared with performing a dimension-by-dimensional mean comparison on the flat feature list, this method can more effectively capture the hierarchical relationship changes between defect features.
[0042] The overall function of step S2 is to cover the gray-level gradient response range of defects of different sizes on the hydraulic side plate surface through multi-scale Gaussian Laplacian convolution operations, avoiding the problem of insufficient or excessive response of single-scale convolution operations to defects of specific sizes. Connected-domain morphological screening, through dual constraints of connected-domain area thresholds and aspect ratio thresholds, excludes residual imaging noise and processing textures from the effective defect connected domains, reducing the false alarm rate of subsequent feature analysis and defect classification. A partial-order lattice of defect features is constructed based on the spatial feature descriptor subset, organizing discrete defect feature points into a hierarchical directed acyclic graph. This allows subsequent step S3 to perform benchmark comparison and drift quantization at the structural level of the partial-order lattice, rather than independent comparison on a single feature dimension. The partial order grid of defect features preserves the partial order hierarchical relationship between defects in three dimensions: area, grayscale contrast, and shape regularity. When light source decay or camera position shift causes slow drift in imaging features during production line operation, the grayscale mean and centroid coordinates of nodes in the partial order grid of defect features will shift as a whole. Step S3 can quantify the degree of drift by comparing the structural differences between the baseline partial order grid of defect features and the partial order grid of defect features in the current batch. Without the partial order grid construction in step S2, step S3 will not be able to obtain a structured representation of defect features and can only perform a dimensional mean comparison on a flat feature list, making it difficult to capture the hierarchical relationship changes between defect features.
[0043] S3: Based on the defect feature partial order grid and production line historical operation data, calculate the gray-scale reference offset vector and spatial reference offset vector in the current time window, and fuse the gray-scale reference offset vector and spatial reference offset vector to generate a composite drift correction operator. Further, step S3 includes: S31: Extract the baseline defect feature partial sequence grid recorded during the initial calibration of the production line from the historical operation data of the production line. The historical operation data of the production line is stored in the local database of the production line's industrial control computer, including all inspection records from the initial calibration stage and each subsequent re-calibration stage. The baseline defect feature partial sequence grid is the defect feature partial sequence grid obtained by performing steps S1 to S2 on the standard defect sample during the initial calibration stage of the production line. The standard defect sample is a hydraulic side plate standard part with known defect type, defect location, and defect size, provided by a metrology and testing institution and calibrated and collected before the production line is put into operation for the first time.
[0044] S32: Establish a sliding time window mechanism, and record the defect feature partial order grids corresponding to the K most recent continuously detected hydraulic side plates as the current batch defect feature partial order grids. K is a preset time window length, representing the number of continuously detected hydraulic side plates. The value of K is determined based on the production line's unit time capacity and the light source decay rate. The conditions that K must meet are: the continuous detection time span of the K hydraulic side plates is not less than the minimum time interval for detectable grayscale changes caused by light source decay, and the K hydraulic side plates must contain at least a certain number of defective hydraulic side plates to ensure that the number of nodes in the defect feature partial order grid meets the statistical comparison requirements. For example, K can be set to an integer value in the range of 50 to 200. The method for constructing the current batch defect feature partial order grid is as follows: summarize all nodes in the defect feature partial order grids of the K most recent hydraulic side plates, and reconstruct the partial order relationship according to the methods in steps S251 and S252 to form the current batch defect feature partial order grid. When the number of defective hydraulic side plates in the most recent K hydraulic side plates is insufficient (the total number of nodes in the effective defect connected domain after aggregation is less than the preset minimum node number threshold, for example, the minimum node number threshold can be set to 10), the time window range is extended (the K value is increased) until the aggregated number of nodes meets the minimum node number requirement.
[0045] S33: Calculate the grayscale reference offset vector; Further, step S33 includes: S331: Extract the mean gray level of all nodes within the connected components from the baseline defect feature partial order lattice, and take the arithmetic mean of the mean gray level of all nodes within the connected components to obtain the baseline global mean gray level (denoted as ). ).
[0046] S332: Extract the mean gray level of all nodes within the connected domain from the partial order lattice of the defect features of the current batch, and take the arithmetic mean of the mean gray level of all nodes within the connected domain to obtain the current global mean gray level.
[0047] S333: Calculate the difference between the current global grayscale mean and the baseline global grayscale mean, denoted as the grayscale offset. Extract the grayscale standard deviation within the connected components of all nodes from the baseline defect feature partial order grid, and take the arithmetic mean of the grayscale standard deviations within the connected components of all nodes to obtain the baseline grayscale standard deviation mean (denoted as...). The grayscale standard deviation within the connected components of all nodes is extracted from the partial order lattice of the defect features of the current batch. The arithmetic mean of the grayscale standard deviations within the connected components of all nodes is taken to obtain the current grayscale standard deviation mean. The difference between the current grayscale standard deviation mean and the baseline grayscale standard deviation mean is calculated and denoted as the grayscale standard deviation offset. The grayscale offset and the grayscale standard deviation offset are combined to form a grayscale baseline offset vector. The grayscale baseline offset vector is a 2D vector, with the first component being the grayscale offset and the second component being the grayscale standard deviation offset. For example, assuming the baseline global grayscale mean is 120 and the current global grayscale mean is 113, the grayscale offset is -7; assuming the baseline grayscale standard deviation mean is 18 and the current grayscale standard deviation mean is 21, the grayscale standard deviation offset is 3. The grayscale baseline offset vector is a 2D vector composed of -7 and 3. A negative grayscale offset indicates that the light source on the production line has decayed, causing a decrease in the overall grayscale of the acquired image. A positive grayscale standard deviation offset indicates an increase in the dispersion of the grayscale distribution.
[0048] S34: Calculate the spatial reference offset vector; Further, step S34 includes: S341: Extract the centroid coordinates of all nodes from the partial order lattice of the baseline defect features. Take the arithmetic mean of the horizontal components of the centroid coordinates of all nodes to obtain the baseline centroid horizontal mean. Take the arithmetic mean of the vertical components of the centroid coordinates of all nodes to obtain the baseline centroid vertical mean. Combine the baseline centroid horizontal mean and the baseline centroid vertical mean to obtain the baseline centroid coordinate mean.
[0049] S342: Extract the centroid coordinates of all nodes from the partial order lattice of the defect features of the current batch. Take the arithmetic mean of the horizontal components of the centroid coordinates of all nodes to obtain the current centroid horizontal mean. Take the arithmetic mean of the vertical components of the centroid coordinates of all nodes to obtain the current centroid vertical mean. Combine the current centroid horizontal mean and the current centroid vertical mean to obtain the current centroid coordinate mean.
[0050] S343: Calculate the difference between the current centroid's average water level and the reference centroid's average water level, denoted as the horizontal component difference. Calculate the difference between the current centroid's vertical average and the reference centroid's vertical average, denoted as the vertical component difference. Combine the horizontal and vertical component differences into a spatial reference offset vector. The spatial reference offset vector is a 2D vector, with the first component being the horizontal component difference and the second component being the vertical component difference. The physical meaning of the spatial reference offset vector is: the projection of the micrometer-level positional offset of the industrial area scan camera caused by equipment vibration during long-term operation of the production line into the image coordinate system. The horizontal component difference reflects the positional offset of the industrial area scan camera along the conveyor belt's movement direction, and the vertical component difference reflects the positional offset of the industrial area scan camera along a direction perpendicular to the conveyor belt's movement direction.
[0051] S35: Fuse the grayscale reference offset vector and the spatial reference offset vector to generate a composite drift correction operator; Further, step S35 includes: S351: Divide the grayscale offset in the grayscale reference offset vector by the reference global grayscale mean. The normalized grayscale offset coefficient (denoted as ) is obtained. The grayscale standard deviation offset in the grayscale reference offset vector is divided by the mean of the reference grayscale standard deviation. The normalized grayscale standard deviation offset coefficient (denoted as ) is obtained. The purpose of normalization is to transform the grayscale offset and grayscale standard deviation offset into relative offset ratios independent of the absolute value of the grayscale, so that the composite drift correction operator has a uniform physical meaning and correction effectiveness across production lines with different grayscale reference levels. This requires a baseline global grayscale mean. Mean of standard deviation of reference gray level Both are non-zero, a condition that must be met in actual working conditions, because the baseline defect feature partial order grid originates from standard defect samples containing real defect areas, and its grayscale mean and grayscale standard deviation cannot be zero. For example, if the grayscale offset is -7 and the baseline global grayscale mean is 120, then the normalized grayscale offset coefficient is -7 divided by 120, which is approximately -0.0583; if the grayscale standard deviation offset is 3 and the baseline grayscale standard deviation mean is 18, then the normalized grayscale standard deviation offset coefficient is 3 divided by 18, which is approximately 0.1667.
[0052] S352: Divide the difference in the horizontal components of the spatial reference offset vector by the total number of horizontal pixels in the image to obtain the normalized horizontal spatial offset coefficient. Divide the difference in the vertical components of the spatial reference offset vector by the total number of vertical pixels in the image to obtain the normalized vertical spatial offset coefficient. The total number of horizontal and vertical pixels in the image are resolution parameters of the industrial area scan camera, read from the camera configuration parameters of the production line control computer. For example, assuming the difference in the horizontal components is 3.2 pixels and the total number of horizontal pixels in the image is 2448 pixels, the normalized horizontal spatial offset coefficient is 3.2 divided by 2448, which is approximately equal to 0.001307; assuming the difference in the vertical components is -1.8 pixels and the total number of vertical pixels in the image is 2048 pixels, the normalized vertical spatial offset coefficient is -1.8 divided by 2048, which is approximately equal to -0.000879.
[0053] S353: The normalized grayscale shift coefficient, normalized grayscale standard deviation shift coefficient, normalized horizontal spatial shift coefficient, and normalized vertical spatial shift coefficient are combined into a 4-dimensional vector, denoted as the composite drift correction operator. See also Figure 9 This is a schematic diagram of the composite drift correction operator vector provided in the embodiments of this application. Figure 9 As shown, the curly braces on the left indicate that the operator is a 4-dimensional vector structure. The outer rectangle is divided into four rows by dashed lines, corresponding from top to bottom to the four components: normalized grayscale offset coefficient, normalized grayscale standard deviation offset coefficient, normalized horizontal spatial offset coefficient, and normalized vertical spatial offset coefficient. The central vertical dashed line is the zero baseline. Each component extends to the left or right in the form of rectangular bars; leftward extension represents a negative value, and rightward extension represents a positive value. The length of the rectangular bar reflects the relative magnitude of the component's offset. During the long-term continuous operation of the production line for detecting surface defects on hydraulic side plates, linear light decay of the light source leads to a decrease in the overall grayscale of the acquired image and changes in grayscale dispersion. Industrial area array cameras are also affected by equipment vibration, resulting in micrometer-level positional shifts. The composite drift correction operator normalizes and fuses these four imaging feature drift modes into a unified 4D vector representation. The normalized gray-level offset coefficient characterizes the relative offset direction and magnitude of the gray-level mean, the normalized gray-level standard deviation offset coefficient characterizes the relative change in gray-level dispersion, and the normalized horizontal and vertical spatial offset coefficients characterize the camera's positional offset ratio along the conveyor belt's movement direction and vertically, respectively. This 4D vector provides precise correction parameters for gray-level inverse compensation and sub-pixel-level translation correction in subsequent adaptive feature correction steps, ensuring that the defect identification model consistently performs classification and judgment based on input features close to the baseline state during long-term operation on the production line.
[0054] The overall function of step S3 is to establish an imaging feature benchmark drift quantification mechanism based on the defect feature partial order lattice structure, quantifying two types of unlabeled, slow imaging feature shifts during long-term production line operation: linear light decay of the light source and micron-level positional shift of the industrial area array camera. Traditional defect detection systems use fixed-weight recognition models without an adaptive correction mechanism for imaging feature shifts. When light decay causes an overall decrease in the grayscale of the acquired image, the grayscale value of small defect areas with already low grayscale contrast will further decrease below the response threshold of the defect recognition model, resulting in missed detections. When the positional shift of the industrial area array camera causes a systematic shift in the position of the defect area in the image coordinate system, the prior spatial position of the defect learned by the defect recognition model during training will deviate from the actual position, resulting in false detections. Step S3 continuously tracks the offset between the current batch of defect feature partial order lattices and the benchmark defect feature partial order lattice in both grayscale and spatial dimensions through a sliding time window mechanism. After normalizing the offset, it is fused into a composite drift correction operator, providing accurate correction parameters for the adaptive feature correction in the subsequent step S4. The composite drift correction operator characterizes four imaging feature drift modes—grayscale mean shift, grayscale dispersion shift, horizontal spatial shift, and vertical spatial shift—using four dimensions, covering the main imaging feature drift scenarios that may occur during long-term production line operation. Without drift quantization in step S3, the defect identification model in step S4 will perform classification on the uncorrected drift feature map. The identification accuracy will gradually decrease as the production line runs longer, eventually requiring the model to be retrained with re-acquired labeled data to restore accuracy, resulting in high maintenance costs and lengthy downtime adjustments.
[0055] S4: Based on the composite drift correction operator, perform grayscale correction and spatial translation correction on the purification defect feature map to obtain the corrected image, then perform defect category determination on the defect candidate region in the corrected image, output the identification result of the small defects on the hydraulic side plate surface and execute the sorting instruction.
[0056] Further, step S4 includes: S41: Load the pre-trained defect recognition model. The defect recognition model is a classification model based on a convolutional neural network, comprising an input layer, three convolutional feature extraction layers, one global average pooling layer, and one fully connected classification layer. The input layer receives a local image patch of fixed size, which is determined based on the size of the bounding rectangle of the largest defect area on the hydraulic side plate surface. For example, the fixed size can be set to a single-channel grayscale image patch of 64 pixels by 64 pixels. The first convolutional feature extraction layer contains 16 convolutional kernels of size 3 pixels by 3 pixels, which perform convolution operations on the local image patch output by the input layer, and output a 16-channel first convolutional feature map after processing by a linear rectified activation function. The second convolutional feature extraction layer contains 32 convolutional kernels of size 3 pixels by 3 pixels, which perform convolution operations on the first convolutional feature map, and output a 32-channel second convolutional feature map after processing by a linear rectified activation function. The third convolutional feature extraction layer contains 64 convolutional kernels, each 3 pixels by 3 pixels. It performs convolution operations on the second convolutional feature map, and after processing with a linear rectified activation function, outputs a 64-channel third convolutional feature map. The global average pooling layer calculates the arithmetic mean of all pixels in each channel of the third convolutional feature map, outputting a 64-dimensional pooled feature vector. The fully connected classification layer multiplies the pooled feature vector by the classification weight matrix and adds a classification bias vector, then processes it with a normalized exponential function to output a 5-dimensional defect category probability vector. The classification weight matrix has a dimension of 64 rows and 5 columns, and the classification bias vector has a dimension of 5. The classification weight matrix, classification bias vector, and all convolutional kernel parameters in the three convolutional feature extraction layers are learnable parameters obtained through training on a standard defect sample dataset. The defect identification model uses cross-entropy loss function for training and adaptive moment estimation algorithm for optimization. The training termination condition is that the absolute value of the difference between the cross-entropy loss function values of two adjacent epochs in 10 consecutive training epochs (each epoch is a complete iteration over the entire training dataset) is less than a preset training convergence threshold. This preset training convergence threshold is determined based on the size of the training dataset; for example, it can be set to 0.001. The output of the defect identification model is a defect category label and a confidence score. The defect category label includes five categories: scratches, dents, microcracks, burrs, and acceptable. The confidence score is the maximum probability value in the defect category probability vector; that is, the category with the highest probability value in the 5-dimensional probability vector is taken as the defect category label, and this maximum probability value is used as the confidence score. This scheme uses the category corresponding to the highest probability as the sole classification criterion, and controls the risk of misclassification of boundary samples by subsequently determining the confidence threshold.
[0057] S42: Adaptive feature correction is performed on the purification defect feature map based on the composite drift correction operator; Further, step S42 includes: S421: Extracting the normalized grayscale shift coefficient from the composite drift correction operator and normalized grayscale standard deviation offset coefficient Inverse compensation is performed on the grayscale values of the entire cleanup defect feature map. Specifically, the grayscale correction calculation process is as follows: for the cleanup defect feature map with coordinates at position i... Line 1 The pixels in the column, after grayscale correction, have coordinates in the cleanup defect feature map as the [number]th [column]. Line 1 The formula for calculating the pixel grayscale value of a column is: The variables are defined as follows: The coordinates of the purification defect feature map after grayscale correction are the first... Line 1 The pixel grayscale value of the column; The coordinates of the defect feature diagram are as follows: Line 1 The pixel grayscale value of the column; The normalized grayscale offset coefficient is calculated in step S351 by dividing the grayscale offset by the baseline global grayscale mean. The baseline global grayscale mean is calculated in step S331; The normalized grayscale standard deviation offset coefficient is calculated in step S351 by dividing the grayscale standard deviation offset by the mean of the reference grayscale standard deviation. The mean of the standard deviation of the baseline gray level is calculated in step S333.
[0058] The prerequisite for using this formula is that the denominator is... Not equal to zero, that is ,because It equals the grayscale standard deviation offset (i.e., the current grayscale standard deviation mean minus the baseline grayscale standard deviation mean). A denominator of zero is equivalent to the current grayscale standard deviation mean being zero. However, in actual working conditions, the grayscale standard deviation of defective areas cannot be zero. Therefore, this premise must be satisfied.
[0059] The physical meaning of grayscale correction is: due to Grayscale offset ,therefore This is equal to the grayscale offset itself (i.e., the difference between the current global grayscale mean and the baseline global grayscale mean). Subtracting the grayscale offset from the grayscale value of each pixel in the cleaned defect feature map compensates for the overall decrease or increase in grayscale caused by light source attenuation; in the denominator... It equals the grayscale standard deviation offset (i.e., the difference between the current grayscale standard deviation mean and the baseline grayscale standard deviation mean). The scaling correction is applied to the variation in grayscale dispersion. When the grayscale standard deviation offset is positive, the denominator is greater than one, and the grayscale value is compressed to compensate for the drift caused by the increase in grayscale dispersion. When the grayscale standard deviation offset is negative, the denominator is less than one, and the grayscale value is stretched to compensate for the drift caused by the decrease in grayscale dispersion.
[0060] For example, suppose the grayscale value of a pixel in the purification defect feature image is 105, and the normalized grayscale offset coefficient is... The baseline global grayscale mean is -0.0583. The normalized grayscale standard deviation offset coefficient is 120. The mean standard deviation of the baseline grayscale is 0.1667. If the value is 18, then the numerator is calculated as follows: The denominator is calculated as After grayscale correction, the pixel grayscale value is approximately Perform the above grayscale correction operation on all pixels in the purification defect feature map to obtain the grayscale-corrected purification defect feature map.
[0061] It should be noted that in the above exemplary calculations The corresponding grayscale standard deviation offset is In this scenario (i.e., the current mean standard deviation of grayscale is 21, and the mean standard deviation of the baseline grayscale is 18), the parameters in this scenario are only used to illustrate the formula calculation process and are not related to the parameter settings in the subsequent complete workflow example. (The corresponding grayscale standard deviation offset is 1.5) represents different hypothetical scenarios.
[0062] S422: Extract the normalized horizontal spatial offset coefficient and normalized vertical spatial offset coefficient from the composite drift correction operator, and perform sub-pixel-level translation correction on the grayscale-corrected cleaned defect feature map. The normalized spatial offset coefficient quantifies the positive spatial offset of the current image relative to the reference image. Perform a reverse (negative) translation to compensate for this offset, correcting the defect position back to the reference coordinate system. Specifically, the spatial correction calculation process is as follows: the number of pixels translated in the horizontal direction of the grayscale-corrected cleaned defect feature map is equal to the negative normalized horizontal spatial offset coefficient multiplied by the total number of horizontal pixels in the image; the number of pixels translated in the vertical direction is equal to the negative normalized vertical spatial offset coefficient multiplied by the total number of vertical pixels in the image. The reason for the negative sign of the translation direction is that the spatial offset recorded in the composite drift correction operator is the positive deviation of the current imaging position relative to the reference imaging position. Performing a reverse translation can correct the defect position in the current image coordinate system back to its position in the reference image coordinate system. Since the translation pixel amount is usually a non-integer value, bilinear interpolation is used to complete the sub-pixel-level translation operation. The specific process of the bilinear interpolation is as follows: For the coordinate in the fully corrected purification defect feature map, the first... Line 1 For each pixel in a column, the source location coordinates (floating-point coordinates) corresponding to that pixel need to be found from the grayscale-corrected and cleaned defect feature map. The horizontal component of the floating-point coordinates is equal to... Adding the normalized horizontal spatial offset coefficient multiplied by the total number of horizontal pixels in the image (addition is used here because reverse translation is equivalent to shifting the source position in the coordinate mapping), the vertical component of the floating-point coordinate is equal to... Add the normalized vertical spatial offset coefficient multiplied by the total number of vertical pixels in the image; find the four nearest neighbor integer coordinate pixels around the floating-point coordinate, and perform a weighted average based on the distance between the floating-point coordinate and the four nearest neighbor integer coordinates to obtain the coordinates of the fully corrected cleaned defect feature map. Line 1 The pixel grayscale values of the column. The above bilinear interpolation translation operation is performed on all pixels in the fully corrected and purified defect feature map to obtain the fully corrected and purified defect feature map. For example, if the normalized horizontal spatial offset coefficient is 0.001307 and the total number of horizontal pixels in the image is 2448, then the horizontal translation amount is approximately -3.2 pixels (0.001307 multiplied by 2448), meaning the grayscale-corrected and purified defect feature map is shifted 3.2 pixels to the left. If the normalized vertical spatial offset coefficient is -0.000879 and the total number of vertical pixels in the image is 2048, then the vertical translation amount is approximately 1.8 pixels (0.000879 multiplied by 2048), meaning the grayscale-corrected and purified defect feature map is shifted downwards by 1.8 pixels.
[0063] S43: From the fully corrected purification defect feature map, crop a fixed-size local image block according to the centroid coordinates of each effective defect connected region in the spatial feature descriptor subset. Specifically, if the spatial feature descriptor subset corresponding to the current hydraulic side plate is empty (i.e., no effective defect connected region), the current hydraulic side plate is directly marked as a qualified product, without performing subsequent cropping and classification steps, and directly jumps to step S45. If the spatial feature descriptor subset is not empty, for the spatial feature descriptor of each effective defect connected region in the spatial feature descriptor subset, read the horizontal and vertical components of the centroid coordinates in the spatial feature descriptor, and crop a 64-pixel multiplied 64-pixel local image block centered on the centroid coordinates in the fully corrected purification defect feature map. The size of the 64-pixel multiplied 64-pixel block is consistent with the fixed size received by the input layer of the defect recognition model in step S41. If the centroid coordinates are located at the edge of the fully corrected purification defect feature map, causing the cropped area to exceed the image boundary, the pixel area exceeding the boundary is filled with a grayscale value of zero. Each local image patch is input into the defect recognition model. The input layer of the defect recognition model receives the local image patch and propagates it forward layer by layer through three convolutional feature extraction layers, a global average pooling layer, and a fully connected classification layer. The fully connected classification layer outputs a 5-dimensional defect category probability vector. The category with the highest probability value in the defect category probability vector is taken as the defect category label of the current local image patch, and the maximum probability value in the defect category probability vector is taken as the confidence score of the current local image patch.
[0064] S44: Determine the defect category label and confidence score output by the defect identification model, and perform the determination in the following priority order; Further, step S44 includes: S441: If the defect category labels of all local image blocks corresponding to a hydraulic side plate are qualified, then the current hydraulic side plate is marked as qualified.
[0065] S442: If at least one local image block in a hydraulic side plate has a defect category label of scratch, dent, microcrack, or burr, and the confidence score of the local image block is greater than or equal to a preset decision confidence threshold, then the current hydraulic side plate is marked as a defective product. When the same hydraulic side plate has both local image blocks that meet the defective product criteria and local image blocks that meet the re-inspection criteria, it is preferentially marked as a defective product. The preset decision confidence threshold is determined according to the tolerance requirements of the production line quality control standard for false positive rate and false negative rate. Specifically, a receiver operating characteristic (ROC) curve is plotted on the validation dataset of the defect identification model, and the probability threshold corresponding to the point on the ROC curve that maximizes the Youden index is selected as the preset decision confidence threshold. The Youden index is equal to the sum of sensitivity and specificity minus one, that is, equal to the difference between the true positive rate and the false positive rate. For example, the preset decision confidence threshold can be set to 0.85.
[0066] S443: If a local image block corresponding to a hydraulic side plate contains a defect category labeled as scratch, dent, microcrack, or burr, but the confidence score corresponding to all such local image blocks is less than the preset judgment confidence threshold (i.e., it does not meet the non-conforming product condition in step S442), then the current hydraulic side plate is marked as a product to be re-inspected. The product to be re-inspected refers to a hydraulic side plate that the defect recognition model detects may have defects but whose confidence score does not reach the non-conforming product judgment standard, and which needs to be manually re-inspected to confirm the final quality level.
[0067] S45: Based on the determination result of step S44, a sorting instruction is sent to the production line sorting module. Specifically, the production line sorting module is a pneumatic pusher sorting device installed at the end of the conveyor belt. The sorting device includes three pusher channels, corresponding to the qualified product outlet, the unqualified product outlet, and the buffer area for products awaiting re-inspection, respectively. Based on the marking results of steps S441, S442, and S443, the production line industrial control computer sends control instructions to the sorting device via the industrial fieldbus: hydraulic side plates marked as qualified products are directly transported to the qualified product outlet by the conveyor belt; hydraulic side plates marked as unqualified products trigger the pneumatic pusher action of the first pusher channel, pushing the hydraulic side plate to the unqualified product outlet; hydraulic side plates marked as products awaiting re-inspection trigger the pneumatic pusher action of the second pusher channel, pushing the hydraulic side plate to the buffer area for products awaiting re-inspection.
[0068] The overall function of step S4 is to apply the composite drift correction operator output from step S3 to the input feature layer of the defect recognition model, achieving a complete closed-loop correction from drift quantization to drift compensation. Gray-level correction compensates for the overall gray-level shift and gray-level dispersion changes caused by light source attenuation, restoring them to the baseline state. This ensures that the gray-level distribution characteristics of the input feature map received by the defect recognition model are consistent with those during model training, avoiding classification bias caused by gray-level shifts in the convolutional feature extraction layer. Spatial correction compensates for the systematic shift in defect region position caused by the industrial area camera's positional shift, restoring it to the baseline position. This ensures that the spatial position of the defect region in the local image patch cropped based on centroid coordinates is consistent with its spatial position during model training, preventing the defect region in the cropped local image patch from deviating from the center position and affecting the classification accuracy of the defect recognition model. The synergistic effect of grayscale correction and spatial correction enables the defect identification model to perform classification and judgment on input features close to the baseline state during long-term continuous operation of the production line. This eliminates the need to re-collect labeled data and retrain the model due to imaging feature drift, fundamentally solving the problem of irregularly increasing false positive and false negative rates for defect identification of the same batch of workpieces in long-term production line operation scenarios. It transforms the passive maintenance mode of traditional solutions requiring production stoppage for model retraining into an active compensation mode of online adaptive correction, significantly reducing maintenance costs and eliminating downtime adjustment cycles. The three-level judgment mechanism subdivides the defect category judgment results into three levels: qualified products, unqualified products, and products awaiting re-inspection. The setting of the product awaiting re-inspection level provides a buffer channel for boundary samples with confidence levels between qualified and unqualified, avoiding the risk of misclassification of boundary samples due to hard judgment based on a single threshold, and improving the reliability of overall quality control on the production line.
[0069] For example, let's describe the complete workflow using a production line with a cycle time of 8 hydraulic side plates per minute. Before the production line is put into operation, calibration data is collected using 10 standard defect sample hydraulic side plates provided by a metrology and testing institution. Each standard defect sample hydraulic side plate is processed through steps S1 and S2 to generate a defect feature partial order grid. The defect feature partial order grids of the 10 standard defect samples are summarized to construct a baseline defect feature partial order grid, which is stored in the local database of the production line's industrial control computer. After the production line is officially running, the conveyor belt transports the hydraulic side plates to be inspected sequentially to the data acquisition station. The industrial area scan camera is a Baslerac A2440-75um model with a resolution of 2448 pixels by 2048 pixels. The forward white light source uses a ring-shaped white LED light source, and the side red light source uses a strip-shaped red LED light source. The side illumination angle is set to 70 degrees. After the first hydraulic side plate reaches the acquisition station, the production line positioning sensor sends a trigger signal, turning on the forward white light source and allowing the industrial area array camera to acquire the forward white light image; the forward white light source turns off, and the side red light source turns on, allowing the industrial area array camera to acquire the side red light image. Gaussian filtering is performed on the forward white light image and the side red light image in step S121, with a convolution kernel size of 5 pixels multiplied by 5 pixels and a standard deviation of 1.0 pixel. Pixel-by-pixel absolute grayscale difference is performed in step S122 to obtain a difference grayscale image. Adaptive threshold segmentation is performed in step S123, and the full-image grayscale histogram of the difference grayscale image is calculated. Assuming the first local minimum point occurs at a grayscale value of 15, the oil film determination threshold is set to 15. An oil film mask is generated in step S13, and defect candidate grayscale images are extracted from the filtered forward white light image in step S14. Finally, the oil film mask and the defect candidate grayscale images are multiplied pixel-by-pixel in step S15 to obtain a purification defect feature map. Step S211 is performed on the cleanup defect feature map, setting the small-scale standard deviation to 1.0 pixel and the medium-scale standard deviation to approximately 2.45 pixels (i.e., ...). The approximate values of the large-scale standard deviation (6.0 pixels) are used to obtain small-scale, medium-scale, and large-scale response maps in step S212. Step S213 then takes the maximum value for each pixel to obtain a multi-scale fused response map. Step S22 involves Otsu's thresholding method for binarization and 8-connected component labeling, resulting in 5 connected components. Step S23 calculates the morphological parameters of each connected component, setting the minimum defect area threshold to 3 pixels and the maximum aspect ratio threshold to 15. Two connected components are deleted because their area is less than 3 pixels, and one is deleted because its aspect ratio is greater than 15, leaving two valid defect connected components. Step S24 extracts spatial feature descriptors from the two valid defect connected components. Spatial feature descriptor A has a connected component area of 12 pixels, a mean gray level of 68, and a circularity of 0.4; spatial feature descriptor B has a connected component area of 30 pixels, a mean gray level of 92, and a circularity of 0.8. Step S251 determines the partial order relationship. Since all three comparison dimensions of spatial feature descriptor A are less than or equal to those of spatial feature descriptor B, the partial order of spatial feature descriptor A is determined to be less than or equal to that of spatial feature descriptor B. Step S252 constructs a defect feature partial order grid, containing nodes for spatial feature descriptor A and spatial feature descriptor B, and a directed edge from spatial feature descriptor A to spatial feature descriptor B. A global lower bound node (area 12, grayscale mean 68, circularity 0.4) and a global upper bound node (area 30, grayscale mean 92, circularity 0.8) are added. Since this example only has two descriptors, A and B, and the partial order of A is less than or equal to that of B, the global lower bound is equal to A, and the global upper bound is equal to B. Assuming the current sliding time window K is set to 100, after the production line has continuously inspected 100 hydraulic side plates, step S32 summarizes the defect feature partial order grids of the 100 hydraulic side plates to construct the defect feature partial order grid for the current batch. Steps S331 to S333 are executed to calculate the grayscale reference offset vector. Assuming the reference global grayscale mean is 120, the current global grayscale mean is 115, the grayscale offset is -5, the reference grayscale standard deviation mean is 18, the current grayscale standard deviation mean is 19.5, and the grayscale standard deviation offset is 1.5, the grayscale reference offset vector is a 2D vector composed of -5 and 1.5. Steps S341 to S343 are executed to calculate the spatial reference offset vector. Assuming the horizontal component difference is 2.1 pixels and the vertical component difference is -0.9 pixels, the spatial reference offset vector is a 2D vector composed of 2.1 and -0.9. Steps S351 to S353 are executed to normalize the grayscale offset coefficient. -5 divided by 120 is approximately -0.0417, which is the normalized grayscale standard deviation offset coefficient. The normalized horizontal spatial offset coefficient is 1.5 divided by 18, approximately equal to 0.0833. The normalized horizontal spatial offset coefficient is 2.1 divided by 2448, approximately equal to 0.000858. The normalized vertical spatial offset coefficient is -0.9 divided by 2048, approximately equal to -0.000439. The composite drift correction operator is a 4-dimensional vector composed of -0.0417, 0.0833, 0.000858, and -0.000439. Step S421 grayscale correction is performed on the purification defect feature map of the current hydraulic side plate to be inspected. Assuming the grayscale value of a certain pixel is 95, according to the formula... molecule is The denominator is After grayscale correction, the pixel grayscale value is approximately Step S422 involves spatial correction. The horizontal translation is approximately -2.1 pixels (0.000858 x 2448) and the vertical translation is approximately 0.9 pixels (0.000439 x 2048). Bilinear interpolation is used to complete the sub-pixel-level translation, resulting in a fully corrected and cleaned defect feature map. Step S43 involves cropping 64-pixel multiplied by 64-pixel local image patches from the fully corrected and cleaned defect feature map according to the centroid coordinates of the two effective defect connected regions. These patches are then input into the defect recognition model. Assuming the model outputs a scratch label and a confidence score of 0.92 for the first local image patch, and a pit label and a confidence score of 0.88 for the second local image patch, the model is responsible for the defect category label. In step S442, the confidence threshold is set to 0.85. The confidence score of the first local image block (0.92) is greater than 0.85, and the confidence score of the second local image block (0.88) is also greater than 0.85. The current hydraulic side plate has both scratches and dents, and both confidence scores meet the standard. Therefore, the current hydraulic side plate is marked as a defective product. In step S45, the production line control computer sends a defective product sorting command to the sorting device. The pneumatic pusher in the first pusher channel actuates, pushing the current hydraulic side plate to the defective product outlet.
[0070] Example 2: This embodiment, based on Embodiment 1, provides a system for identifying minute defects on the surface of a hydraulic side plate, such as... Figure 10 As shown, it includes: The image acquisition and preprocessing module is used to acquire the original image sequence of the hydraulic side plate surface and perform oil film reflective area separation and real defect candidate area extraction, and output the purification defect feature map. The feature extraction and partial order lattice construction module is used to perform multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening on the purification defect feature map, extract spatial feature descriptor subsets and construct defect feature partial order lattice; The drift quantization module is used to calculate the grayscale reference offset vector and the spatial reference offset vector based on the defect feature partial order grid and the production line historical operation data, and fuse them to generate a composite drift correction operator. The defect identification and sorting module is used to perform grayscale correction and spatial translation correction based on the composite drift correction operator to obtain the corrected image, perform defect category determination on the defect candidate region and output the identification result to drive the production line sorting instruction.
Claims
1. A method for identifying minute defects on the surface of a hydraulic side plate, characterized in that, include: The original image sequence of the hydraulic side plate surface is acquired. The oil film reflective area is separated and the real defect candidate area is extracted from the original image sequence to obtain an oil film mask and a defect candidate grayscale image. Based on the oil film mask, the oil film interference is suppressed on the defect candidate grayscale image to obtain a purification defect feature map. Multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening are performed on the purification defect feature map to extract a set of spatial feature descriptors of the defect region. A partial order lattice of defect features is constructed based on this set of spatial feature descriptors. The construction of the partial order lattice of defect features based on the set of spatial feature descriptors includes: defining a partial order relationship between spatial feature descriptors; selecting connected component area, mean gray level within the connected component, and circularity of the connected component as the partial order comparison dimensions; arranging all spatial feature descriptors in the set of spatial feature descriptors according to the partial order relationship; calculating the supremum and infimum in the partial order relationship for any two spatial feature descriptors; taking the global maximum value on the partial order comparison dimension of all spatial feature descriptors to form a global supremum node, and taking the global minimum value on the global infimum node; and constructing the partial order lattice of defect features by connecting all spatial feature descriptors and the supremum and infimum to form a directed hierarchical relationship. The data structure of the partial order lattice of defect features is a directed acyclic graph. Based on the defect feature partial order grid and production line historical operation data, calculate the gray-scale reference offset vector and spatial reference offset vector within the current time window, and fuse the gray-scale reference offset vector and the spatial reference offset vector to generate a composite drift correction operator. Based on the composite drift correction operator, grayscale correction and spatial translation correction are performed on the purification defect feature map to obtain a corrected image. Then, defect category determination is performed on the defect candidate region in the corrected image, the identification result of the small defects on the hydraulic side plate surface is output, and sorting instructions are executed.
2. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 1, characterized in that the step of performing oil film reflective region separation and real defect candidate region extraction on the original image sequence to obtain an oil film mask and a defect candidate grayscale image includes: The hydraulic side plate on the conveyor belt is continuously captured by an industrial area array camera above the production line under alternating illumination from a frontal white light source and a side red light source to obtain the original image sequence, which includes multiple sets of frontal white light images and side red light images. Pixel-level grayscale difference operations are performed on each group of forward white light images and side red light images in the original image sequence to obtain a difference grayscale image; Adaptive threshold segmentation is performed on the differential grayscale image. Pixel regions with differential grayscale values lower than the oil film determination threshold are marked as oil film regions, and pixel regions with differential grayscale values higher than or equal to the oil film determination threshold are marked as defect candidate regions. The oil film mask is generated based on the marking results. In the oil film mask, the pixel value of the oil film area is zero, and the pixel value of the defect candidate area is one. The grayscale information corresponding to the defect candidate region is extracted from the filtered forward white light image to obtain the defect candidate grayscale image.
3. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 2, characterized in that the step of performing pixel-level gray-level difference operations on each group of forward white light images and side red light images in the original image sequence to obtain a difference gray-level image includes: Gaussian filtering is performed on the forward white light image and the side red light image respectively to obtain the filtered forward white light image and the filtered side red light image; The difference grayscale image is obtained by taking the absolute grayscale difference pixel by pixel between the filtered forward white light image and the filtered lateral red light image. Statistically analyze the frequency distribution of gray values of all pixels in the differential grayscale image, and draw a grayscale histogram of the entire image; The first local minimum point in the grayscale histogram of the whole image is searched in the direction of grayscale value from low to high, and the grayscale value corresponding to the first local minimum point is used as the oil film determination threshold.
4. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 1, characterized in that the step of performing multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening on the purification defect feature map to extract the spatial feature descriptor subset of the defect region includes: Three different scales of Gaussian Laplacian convolution operations were performed on the purification defect feature map to obtain small-scale response maps, medium-scale response maps and large-scale response maps, respectively. The maximum value of each pixel in the small-scale response map, the medium-scale response map, and the large-scale response map is taken to obtain a multi-scale fused response map; The multi-scale fused response map is binarized to obtain a binary defect region map; Perform connected component labeling on the binary defect region map to obtain a connected component labeled map; For each connected component in the connected component labeling graph, calculate the morphological parameters, delete the connected components that are determined to be noisy connected components from the connected component labeling graph, and mark the remaining connected components as valid defective connected components; For each of the effective defect connected domains, a spatial feature descriptor is extracted, and the spatial feature descriptors of all effective defect connected domains are summarized into the spatial feature descriptor set.
5. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 4, characterized in that the calculation of morphological parameters for each connected component in the connected component marker graph includes: Calculate the morphological parameters, which include the area of the connected region, the perimeter of the connected region, the ratio of the major axis to the minor axis of the connected region, and the circularity of the connected region; Connected regions whose area is less than the minimum defect area threshold are classified as noisy connected regions. Connected components whose major-minor axis ratio is greater than the maximum major-minor axis ratio threshold are classified as noisy connected components.
6. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 4, characterized in that, the extraction of spatial feature descriptors for each effective defect connected region includes: The centroid coordinates, area, perimeter, ratio of major to minor axis, circularity, mean gray value, and standard deviation of gray value within the effective defect connected domain are extracted as the spatial feature descriptors. The data structure of the spatial feature descriptor subset is an ordered list, and each element in the ordered list is a multidimensional vector containing the centroid coordinates, the area of the connected region, the perimeter of the connected region, the ratio of the major axis to the minor axis of the connected region, the circularity of the connected region, the mean gray value in the connected region, and the standard deviation of the gray value in the connected region.
7. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 1, characterized in that, the step of calculating the grayscale reference offset vector and the spatial reference offset vector within the current time window based on the defect feature partial order grid and historical production line operation data includes: Extract the baseline defect feature partial order grid recorded during the first calibration of the production line from the historical operation data of the production line; Establish a sliding time window mechanism, and record the defect feature partial order grids corresponding to the K most recent hydraulic side plates in the current continuous detection as the defect feature partial order grids of the current batch, where K is the preset time window length; The mean gray level and the standard deviation of gray level in the connected domain are extracted from the baseline defect feature partial order grid and the current batch defect feature partial order grid, respectively, and the gray level baseline offset vector is calculated. The centroid coordinates are extracted from the baseline defect feature partial order grid and the current batch defect feature partial order grid, respectively, and the spatial baseline offset vector is calculated.
8. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 7, characterized in that the step of extracting the mean gray level and the standard deviation of gray level within the connected domain from the reference defect feature partial order grid and the current batch defect feature partial order grid respectively, and calculating the gray level reference offset vector includes: The arithmetic mean of the grayscale values within the connected domains of all nodes in the baseline defect feature partial order lattice is calculated to obtain the baseline global grayscale mean. The arithmetic mean of the grayscale values within the connected components of all nodes in the partial order grid of the current batch defect features is calculated to obtain the current global grayscale mean. The grayscale offset is obtained by calculating the difference between the current global grayscale mean and the baseline global grayscale mean. The arithmetic mean of the gray-level standard deviations within the connected domains of all nodes in the baseline defect feature partial order lattice is calculated to obtain the baseline gray-level standard deviation mean. The arithmetic mean of the grayscale standard deviations within the connected domains of all nodes in the partial order grid of the current batch defect features is calculated to obtain the current mean grayscale standard deviation. The grayscale standard deviation offset is obtained by calculating the difference between the current mean grayscale standard deviation and the reference mean grayscale standard deviation. The grayscale offset and the grayscale standard deviation offset are combined to form the grayscale reference offset vector.
9. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 1, characterized in that the step of fusing the grayscale reference offset vector and the spatial reference offset vector to generate a composite drift correction operator includes: The normalized grayscale offset coefficient is obtained by dividing the grayscale offset amount in the grayscale reference offset vector by the reference global grayscale mean. The normalized grayscale standard deviation offset coefficient is obtained by dividing the grayscale standard deviation offset in the grayscale reference offset vector by the mean of the reference grayscale standard deviation. The normalized horizontal spatial offset coefficient is obtained by dividing the difference of the horizontal component in the spatial reference offset vector by the total number of horizontal pixels in the image. The normalized vertical spatial offset coefficient is obtained by dividing the difference of the vertical component in the spatial reference offset vector by the total number of vertical pixels in the image. The normalized grayscale offset coefficient, the normalized grayscale standard deviation offset coefficient, the normalized horizontal spatial offset coefficient, and the normalized vertical spatial offset coefficient are combined into a 4-dimensional vector, which is denoted as the composite drift correction operator.
10. The method for identifying minute defects on the surface of a hydraulic side plate according to claim 1, characterized in that, the step of performing grayscale correction and spatial translation correction on the purification defect feature map based on the composite drift correction operator to obtain a corrected image, and then performing defect category determination on the defect candidate region in the corrected image, includes: The normalized grayscale shift coefficient and the normalized grayscale standard deviation shift coefficient are extracted from the composite drift correction operator, and reverse compensation is performed on the full-image grayscale value of the purification defect feature map. The normalized horizontal spatial offset coefficient and the normalized vertical spatial offset coefficient are extracted from the composite drift correction operator, and sub-pixel level translation correction is performed on the grayscale-corrected purification defect feature map to obtain the fully corrected purification defect feature map. A fixed-size local image block is cropped from the fully corrected and cleaned defect feature map according to the centroid coordinates of the effective defect connected domains; The local image patch is input into a pre-trained defect recognition model, which outputs defect category labels and confidence scores. The hydraulic side plate is determined as a qualified product, a non-qualified product, or a product awaiting re-inspection based on the defect category label and the confidence score.
11. A hydraulic side plate surface micro-defect identification system, characterized in that, For implementing the method for identifying minute defects on the surface of a hydraulic side plate according to any one of claims 1-10, the system comprises: The image acquisition and preprocessing module is used to acquire the original image sequence of the hydraulic side plate surface, perform oil film reflective area separation and real defect candidate area extraction on the original image sequence to obtain an oil film mask and a defect candidate grayscale image, and perform oil film interference suppression on the defect candidate grayscale image based on the oil film mask to obtain a purification defect feature map. The feature extraction and partial order lattice construction module is used to perform multi-scale Gaussian Laplacian convolution analysis and connected component morphological screening on the purification defect feature map to extract a set of spatial feature descriptors of the defect region, and construct a partial order lattice of defect features based on the set of spatial feature descriptors. The construction of the partial order lattice of defect features based on the set of spatial feature descriptors includes: defining the partial order relationship between spatial feature descriptors, selecting the area of the connected component, the mean gray value within the connected component, and the circularity of the connected component as the partial order comparison dimensions; arranging all spatial feature descriptors in the set of spatial feature descriptors according to the partial order relationship; calculating the supremum and infimum in the partial order relationship for any two spatial feature descriptors; taking the global maximum value on the partial order comparison dimension of all spatial feature descriptors to form a global supremum node, and taking the global minimum value on the global infimum node; constructing the partial order lattice of defect features by connecting all spatial feature descriptors and the supremum and infimum, where the data structure of the partial order lattice of defect features is a directed acyclic graph. The drift quantization module is used to calculate the grayscale reference offset vector and the spatial reference offset vector within the current time window based on the defect feature partial order grid and the production line historical operation data, and to fuse the grayscale reference offset vector and the spatial reference offset vector to generate a composite drift correction operator. The defect identification and sorting module is used to perform grayscale correction and spatial translation correction on the purification defect feature map based on the composite drift correction operator to obtain a corrected image, then perform defect category determination on the defect candidate region in the corrected image, output the identification result of the small defects on the hydraulic side plate surface and execute the sorting instruction.
Citation Information
Patent Citations
Automobile circuit board solder paste printing quality detection method and system
CN121504881A
Fast computation of compact poset isomorphism certificates
US20090216820A1