A deep learning-based printed matter defect online detection method and system
Patent Information
- Application Number
- CN202611119271.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-10-16
AI Technical Summary
[0002]印刷品质量直接影响产品价值与品牌形象,在包装、出版、标签等行业中占据核心地位;随着消费市场对产品外观要求的不断提升,印刷品表面即使存在毫米级的墨斑、漏印或套印偏差,都可能导致整批产品报废,造成巨大经济损失
[0014] The beneficial effects of this invention are as follows: This invention extracts printing texture features at multiple spatial scales through a multi-layer convolutional feature extraction network, effectively distinguishing the differences between normal pattern textures and defect areas; it achieves precise positioning of defect edges by combining gray-level gradient distribution matrix with morphological gradient operators; it quantifies the physical size of defects through a connected component labeling algorithm, filtering out interference areas that are too small; and it performs secondary discrimination of defect areas through an anomaly detection model based on a random partitioning strategy, combined with gray-level distribution feature descriptors to comprehensively evaluate the degree of pixel anomalies, reducing the false detection rate and false negative rate. This enables accurate identification of minute printing defects on high-speed printing production lines, automatically adapting to changes in different products and printing conditions without relying on manual parameter tuning, while ensuring the real-time performance of detection results meets online quality inspection requirements.
Smart Images

Figure CN122928792A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of printed matter inspection technology, specifically a method and system for online detection of defects in printed matter based on deep learning. Background Technology
[0002] The quality of printed materials directly affects product value and brand image, occupying a core position in industries such as packaging, publishing, and labeling. As the consumer market continues to raise its requirements for product appearance, even millimeter-level ink spots, missing prints, or misregistration on the surface of printed materials can lead to the scrapping of an entire batch of products, resulting in huge economic losses.
[0003] However, traditional printing defect detection technologies have the following shortcomings: First, manual visual inspection is difficult to maintain consistent accuracy in high-speed production line environments, resulting in an irreconcilable contradiction between inspection efficiency and quality. Second, while rule-based machine vision methods can achieve automated inspection, they often exhibit significant limitations in adapting to the complex and varied textures and backgrounds of printed surfaces and the mixed occurrence of different types of defects. Third, existing detection schemes generally rely on manually set feature thresholds to identify defects. This method requires repeated parameter adjustments when dealing with different printing materials and background colors. When the production line switches product types or printing conditions change, the original detection rules immediately become invalid, leading to a sharp increase in false positive and false negative rates. Finally, printing defects often exhibit characteristics of being small, scattered, and having blurred boundaries. Ink spots may be only a few tenths of a millimeter in size, and registration deviations may only be micrometer-level misalignments. These minute features occupy a very limited pixel area in high-resolution images, and the grayscale difference between them and the surrounding normal printing areas is not obvious. Summary of the Invention
[0004] The purpose of this invention is to address the aforementioned shortcomings in the prior art by providing a deep learning-based online defect detection method and system for printed materials.
[0005] The objective of this invention is achieved through the following technical solution: an online defect detection method for printed materials based on deep learning, comprising the following steps: S1. Acquire the original image of the printed surface through the image acquisition device within a preset acquisition time window, and perform noise suppression processing based on Gaussian kernel function and grayscale conversion processing on the original image to obtain a standardized grayscale image. S2. Based on the standardized grayscale image, a multi-layer convolutional feature extraction network is used to perform texture feature analysis on the standardized grayscale image. By extracting the local texture distribution features of the printing texture at multiple spatial scales through the receptive field range corresponding to different convolutional kernel sizes, a texture feature representation matrix is obtained. S3. Based on the feature response intensity of each pixel position in the texture feature characterization matrix, calculate the gray level change amplitude between horizontal adjacent pixel pairs and vertical adjacent pixel pairs in the normalized gray level image to obtain a gray level gradient distribution matrix covering the entire image space. S4. If there is a target pixel region in the gray-level gradient distribution matrix whose gray-level change amplitude is greater than the preset gradient judgment threshold, then extract the spatial coordinate information corresponding to the target pixel region, apply the morphological gradient operator to perform edge enhancement processing within the neighborhood range corresponding to the spatial coordinate information, and determine the set of boundary pixel coordinates that form a closed contour. S5. Based on the set of boundary pixel coordinates, the connected area of pixels within the closed region enclosed by the set of boundary pixel coordinates is calculated using a connected component labeling algorithm to obtain a quantitative index of defect size that reflects the physical size of the printed surface defect. S6. If the defect size quantification index is greater than the preset size discrimination threshold, then extract the grayscale distribution data of all pixels within the area enclosed by the boundary pixel coordinate set, calculate the central tendency statistics and dispersion statistics of the pixel grayscale within the area enclosed by the boundary pixel coordinate set, and obtain the target grayscale distribution feature descriptor. S7. Based on the target grayscale distribution feature descriptor, an anomaly detection model based on a random partitioning strategy is used to detect the abnormal distribution of pixels within the area enclosed by the set of boundary pixel coordinates. For each pixel position, a quantized value of its deviation from the normal printed texture distribution is output to obtain an anomaly score sequence that reflects the degree of pixel anomaly within the area. S8. If the maximum score value in the abnormal score sequence is greater than the preset abnormal judgment threshold, it is determined that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image, and the defect identification confidence value for the printing quality defect is determined according to the maximum score value and the preset score accuracy mapping relationship.
[0006] The present invention is further configured such that step S1 specifically includes: S11. Activate the charge-coupled sensor of the image acquisition device to acquire images of the printed surface according to the preset pixel resolution and frame rate, and obtain the original acquired image containing the printed pattern. S12. Perform Gaussian kernel convolution operation on the original acquired image. The standard deviation parameter of the Gaussian kernel is set to the range of 1.2 to 1.8 pixels to eliminate the influence of random noise and sensor thermal noise. S13. Perform grayscale conversion on the image after noise suppression processing, mapping the RGB three-channel image to a single-channel grayscale image. The grayscale mapping formula is Gray=0.299R+0.587G+0.114B, resulting in a standardized grayscale image.
[0007] The present invention is further configured such that step S2 specifically includes: S21. Construct a multi-layer convolutional feature extraction network, which includes an input layer, a first convolutional layer, a second convolutional layer, a third convolutional layer, and an output layer connected in sequence. S22. Configure a first convolutional kernel with a size of 3×3 in the first convolutional layer, set the number of convolutional kernels to 32, the stride to 1, and the padding to same, in order to extract fine-grained local features of the printed texture. S23. Configure a second convolutional kernel with a size of 5×5 in the second convolutional layer, set the number of convolutional kernels to 64, the stride to 1, and the padding to same, in order to extract medium-scale features of the printed texture. S24. Configure a third convolutional kernel with a size of 7×7 in the third convolutional layer, set the number of convolutional kernels to 128, set the stride to 1, and set the padding to same, in order to extract coarse-grained global features of the printing texture. S25. Perform batch normalization and ReLU activation on the output of each convolutional layer, and concatenate the feature maps of each layer along the channel dimension to obtain the texture feature representation matrix. (This is relevant to the field of printed matter inspection technology.) The present invention is further configured such that step S3 specifically includes: S31. Extract the feature response values of each pixel position in the texture feature representation matrix, and perform global average pooling on the three-dimensional feature tensor along the channel dimension to obtain the two-dimensional feature response map. S32. Apply the Sobel operator to the two-dimensional feature response map to perform gradient calculation. The horizontal convolution kernel of the Sobel operator is set to [[-1,0,1],[-2,0,2],[-1,0,1]], and the vertical convolution kernel is set to [[-1,-2,-1],[0,0,0],[1,2,1]]. S33. After summing the squares of the horizontal and vertical convolution results, take the square root to obtain the gradient magnitude at each pixel location. The formula for calculating the gradient magnitude is: ,in For horizontal gradient components, The vertical gradient component; S34. Map the calculated gradient magnitude to the corresponding pixel position according to the spatial coordinates of the original image to form a gray-level gradient distribution matrix.
[0008] The present invention is further configured such that step S4 specifically includes: S41. Extract the pixel location coordinates in the gray-level gradient distribution matrix where the gradient magnitude exceeds the preset gradient judgment threshold, and obtain the spatial coordinate set of the target pixel region. S42. For each pixel position in the set of spatial coordinates, apply a morphological gradient operator to perform edge enhancement processing within its 3×3 neighborhood. The morphological gradient operator consists of the difference between the dilation operation and the erosion operation. S43. Perform contour search on the edge-enhanced binary image to extract the set of boundary pixel coordinates that form a closed curve; S44. Perform polynomial fitting smoothing on the extracted contours to eliminate the interference of isolated noise points on the integrity of the contours.
[0009] The present invention is further configured such that step S5 specifically includes: S51. Mark the connected components of the closed region enclosed by the set of boundary pixel coordinates. Use the eight-connectivity discrimination criterion to mark all sets of mutually connected pixels. S52. Calculate the total number of pixels contained in each connected component, multiply the number of pixels by the physical size corresponding to a single pixel, and obtain the physical area of the connected component. S53. Sort all connected components in descending order of physical area, and extract the connected component with the largest area as the candidate defect region. S54. The physical area of the candidate defect region is used as a quantitative indicator of defect size, and the unit of this indicator is square millimeters.
[0010] The present invention is further configured such that step S6 specifically includes: S61. Extract the grayscale values of all pixels within the region enclosed by the set of boundary pixel coordinates; S62. Calculate the central tendency statistics of pixel gray levels within the region, including the gray level mean and gray level median, wherein the formula for calculating the gray level mean is: ,in For the first grayscale value of each pixel. The total number of pixels within the region; S63. Calculate the statistical measures of pixel grayscale dispersion within the region, including grayscale standard deviation and grayscale variance, wherein the formula for calculating grayscale variance is: ; S64. Combine the gray mean, gray median, gray standard deviation, and gray variance into a target gray distribution feature descriptor.
[0011] The present invention is further configured such that step S7 specifically includes: S71. Construct an anomaly detection model based on a random partitioning strategy. This model is built on the isolated forest algorithm and contains several isolated trees. S72. Perform statistical modeling on the grayscale distribution characteristics of normal printed samples to obtain the grayscale distribution parameters of normal printed textures. and ; S73. Input the target grayscale distribution feature descriptor into the anomaly detection model. The anomaly detection model calculates the path length of each pixel position relative to the normal distribution. The shorter the path length, the more abnormal the pixel is. S74. Calculate the anomaly score based on the path length. The formula for calculating the anomaly score is as follows: ,in This represents the average path length. For normalization constants, The number of samples; S75, an anomaly score sequence consisting of anomaly scores for all pixel locations within the output area.
[0012] The present invention is further configured such that step S8 specifically includes: S81. Extract the maximum score value from the abnormal score sequence. The maximum score value represents the degree of deviation of the most abnormal pixel in the region. S82. Compare the maximum score value with the preset anomaly detection threshold, which is set to 0.7. S83. If the maximum score value is greater than 0.7, it is determined that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image. S84. Determine the defect identification confidence value based on the maximum score value and the preset score accuracy mapping relationship. The score accuracy mapping relationship is as follows: The confidence level is 70% when the maximum rating value is in the range of 0.6 to 0.7, 85% when it is in the range of 0.7 to 0.8, 95% when it is in the range of 0.8 to 0.9, and 99% when it is greater than 0.9.
[0013] A deep learning-based online defect detection system for printed materials includes: The image acquisition and preprocessing module is used to acquire the original image of the printed surface through the image acquisition device within a preset acquisition time window, and to perform noise suppression processing based on Gaussian kernel function and grayscale conversion processing of multi-channel image to obtain a standardized grayscale image. The texture feature extraction module is used to perform texture feature analysis based on a standardized grayscale image using a multi-layer convolutional feature extraction network. It extracts the local texture distribution features of the printed texture at multiple spatial scales by using the receptive field range corresponding to different convolutional kernel sizes, and obtains the texture feature representation matrix. The gradient calculation module is used to calculate the gray level change amplitude between horizontal and vertical adjacent pixel pairs in a normalized grayscale image based on the feature response intensity of each pixel position in the texture feature characterization matrix, and obtain a gray level gradient distribution matrix covering the entire image space. The edge enhancement and contour extraction module is used to extract the spatial coordinate information of the target pixel region when the gray level change amplitude in the gray level gradient distribution matrix is greater than the preset gradient judgment threshold. Then, it applies the morphological gradient operator to perform edge enhancement processing within the neighborhood of the spatial coordinate information to determine the set of boundary pixel coordinates that form a closed contour. The defect size quantization module is used to calculate the connected area of pixels within a closed region based on the set of boundary pixel coordinates using a connected component labeling algorithm, thereby obtaining a defect size quantification index that reflects the physical size of defects on the printed surface. The grayscale feature description module is used to extract the grayscale distribution data of all pixels within the area enclosed by the boundary pixel coordinate set when the defect size quantification index is greater than the preset size discrimination threshold, calculate the central tendency statistics and dispersion statistics of pixel grayscale, and obtain the target grayscale distribution feature descriptor. The anomaly detection module is used to detect the abnormal distribution of pixels within the region enclosed by the set of boundary pixel coordinates based on the target grayscale distribution feature descriptor and an anomaly detection model based on a random partitioning strategy. For each pixel position, it outputs a quantified value of the degree of deviation from the normal printed texture distribution, and obtains an anomaly score sequence that reflects the degree of pixel anomaly within the region. The defect determination module is used to determine that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image when the maximum score value in the abnormal scoring sequence is greater than the preset abnormal determination threshold, and to determine the defect identification confidence value according to the maximum score value and the preset scoring accuracy mapping relationship.
[0014] The beneficial effects of this invention are as follows: This invention extracts printing texture features at multiple spatial scales through a multi-layer convolutional feature extraction network, effectively distinguishing the differences between normal pattern textures and defect areas; it achieves precise positioning of defect edges by combining gray-level gradient distribution matrix with morphological gradient operators; it quantifies the physical size of defects through a connected component labeling algorithm, filtering out interference areas that are too small; and it performs secondary discrimination of defect areas through an anomaly detection model based on a random partitioning strategy, combined with gray-level distribution feature descriptors to comprehensively evaluate the degree of pixel anomalies, reducing the false detection rate and false negative rate. This enables accurate identification of minute printing defects on high-speed printing production lines, automatically adapting to changes in different products and printing conditions without relying on manual parameter tuning, while ensuring the real-time performance of detection results meets online quality inspection requirements. Attached Figure Description
[0015] The invention will be further illustrated with reference to the accompanying drawings, but the embodiments in the drawings do not constitute any limitation on the invention. For those skilled in the art, other drawings can be obtained based on the following drawings without any creative effort.
[0016] Figure 1This is a flowchart of the online defect detection method for printed materials based on deep learning according to the present invention. Figure 2 This is a system block diagram of the online defect detection system for printed materials based on deep learning, as described in this invention. Detailed Implementation
[0017] The present invention will be further described in conjunction with the following embodiments.
[0018] Example 1;
[0019] Depend on Figure 1 and Figure 2 As shown, this embodiment uses a cigarette pack production line of a packaging and printing company as the detection object. The production line is equipped with a rotary printing machine with a rated speed of 300 meters per minute. The image acquisition system uses an industrial camera with a resolution of 4096×4096 pixels, and the detection algorithm runs on a workstation equipped with a high-performance graphics processor.
[0020] During the actual operation of this production line, the industrial camera needs to complete image acquisition within milliseconds, and the detection system must immediately determine whether there are defects in the frame and output the results. This embodiment elaborates on how to achieve accurate online detection of surface defects of printed materials through industrial vision technology.
[0021] In step S1, image acquisition and preprocessing of the printed surface are first required. The image acquisition module activates the charge-coupled sensor to acquire images of the printed surface according to the preset pixel resolution and frame rate, obtaining the original acquired image containing the printed pattern. In this embodiment, the pixel resolution of the industrial camera is set to 4096×4096 pixels, and the frame rate is set to 500 frames per second to meet the real-time requirements of high-speed production lines. The preset acquisition time window is set to 10 milliseconds to ensure that clear images can be acquired even when the printed material is moving at high speed. Gaussian kernel convolution is performed on the original acquired image, and the standard deviation parameter of the Gaussian kernel is set to 1.5 pixels to eliminate the influence of random noise and sensor thermal noise. The specific implementation process of the Gaussian kernel convolution operation includes: constructing a two-dimensional Gaussian kernel template with a template size of 5×5 pixels, a center pixel weight of 0.234, and neighboring pixel weights distributed according to the Gaussian distribution decay law to ensure the integrity of image edge information while suppressing high-frequency noise. After performing Gaussian kernel convolution on the original acquired image, the noise-suppressed image is obtained. The image after noise suppression is converted to grayscale, mapping the RGB three-channel image to a single-channel grayscale image. The grayscale mapping formula is Gray=0.299R+0.587G+0.114B, resulting in a standardized grayscale image. The grayscale conversion process converts the three-channel color image into a single-channel grayscale image, reducing the computational complexity of subsequent processing while preserving the main visual features of the image.
[0022] In step S2, based on the standardized grayscale image, a multi-layer convolutional feature extraction network is used to perform texture feature analysis on the standardized grayscale image. By extracting the local texture distribution features of the printed texture at multiple spatial scales through the receptive field range corresponding to different convolutional kernel sizes, a texture feature representation matrix is obtained. The specific construction process of the multi-layer convolutional feature extraction network is as follows: The network includes an input layer, a first convolutional layer, a second convolutional layer, a third convolutional layer, and an output layer connected sequentially. A 3×3 first convolutional kernel is configured in the first convolutional layer, with 32 kernels, a stride of 1, and "same" padding. Fine-grained local features of the printed texture are extracted. In the second convolutional layer, a 5×5 kernel is configured with 64 kernels, a stride of 1, and the same padding to extract medium-scale features. In the third convolutional layer, a 7×7 kernel is configured with 128 kernels, a stride of 1, and the same padding to extract coarse-grained global features. Batch normalization and ReLU activation are applied to the output of each convolutional layer. The feature maps from each layer are concatenated along their channel dimensions to obtain the texture feature representation matrix. Each convolutional operation in the multi-layer convolutional feature extraction network is followed by a max-pooling operation with a 2×2 pooling window and a stride of 2 to compress feature dimensions and enhance spatial invariance. Max-pooling effectively reduces the dimensionality of the feature maps, lowers the complexity of subsequent calculations, and enhances the network's robustness to image translation changes.
[0023] In step S3, based on the feature response intensity of each pixel position in the texture feature representation matrix, the gray level change amplitude between horizontally adjacent pixel pairs and vertically adjacent pixel pairs in the normalized grayscale image is calculated to obtain a gray level gradient distribution matrix covering the entire image space. The specific gradient calculation process is as follows: extract the feature response values of each pixel position in the texture feature representation matrix, perform global average pooling on the three-dimensional feature tensor along the channel dimension to obtain a two-dimensional feature response map; apply the Sobel operator to perform gradient calculation on the two-dimensional feature response map, and set the horizontal convolution kernel of the Sobel operator to [[-1,0,1],[-2,0,2],[-1,0,1]]. The vertical convolution kernel is set to [[-1,-2,-1],[0,0,0],[1,2,1]]. The gradient magnitude at each pixel location is obtained by summing the squares of the horizontal and vertical convolution results and then taking the square root. The formula for calculating the gradient magnitude is... ,in For horizontal gradient components, The vertical gradient component is used; the calculated gradient magnitude is mapped to the corresponding pixel position according to the spatial coordinates of the original image to form a gray-level gradient distribution matrix. In this embodiment, the preset gradient judgment threshold is set to 20 gray levels; if there is a target pixel region in the gray-level gradient distribution matrix with a gray-level change greater than 20 gray levels, the region is marked as a potential defect region and needs further processing; the specific value of the preset gradient judgment threshold is adaptively adjusted according to the material type and printing resolution of the printed material.
[0024] In step S4, if there is a target pixel region in the gray-level gradient distribution matrix whose gray-level change amplitude is greater than the preset gradient judgment threshold, then the spatial coordinate information corresponding to the target pixel region is extracted, and the morphological gradient operator is applied to the neighborhood range corresponding to the spatial coordinate information for edge enhancement processing to determine the set of boundary pixel coordinates that form a closed contour. The specific edge enhancement and contour extraction process is as follows: extract the pixel position coordinates in the gray-level gradient distribution matrix where the gradient amplitude exceeds the preset gradient judgment threshold to obtain the set of spatial coordinates of the target pixel region; for each pixel position in the set of spatial coordinates, the morphological gradient operator is applied to its 3×3 neighborhood range for edge enhancement processing. The morphological gradient operator consists of the difference between dilation and erosion operations; the specific application of the morphological gradient operator includes: first, using a structuring element with a radius of 1 pixel to perform a dilation operation on the image, then using a structuring element with a radius of 1 pixel to perform an erosion operation on the image, and performing a difference operation between the dilation result and the erosion result to obtain the morphological gradient image; perform contour search on the edge-enhanced binary image to extract the set of boundary pixel coordinates that form a closed curve; perform polynomial fitting smoothing processing on the extracted contour to eliminate the interference of isolated noise points on the integrity of the contour.
[0025] In step S5, based on the boundary pixel coordinate set, a connected component labeling algorithm is used to calculate the connected area of pixels within the closed region enclosed by the boundary pixel coordinate set, obtaining a defect size quantification index reflecting the physical size of the printed surface defect. The specific connected component labeling and size quantization process is as follows: Connected component labeling is performed on the closed region enclosed by the boundary pixel coordinate set. An eight-connected component discrimination criterion is used to label all interconnected pixel sets. A depth-first search-based connected component labeling algorithm is used to scan all pixels in the image, marking pixels with the same connectivity attribute as the same region label. The number of pixels corresponding to each label is counted, and the pixel count is converted into physical size according to the calibration parameters of the image acquisition device. The total number of pixels contained in each connected component is calculated, and the number of pixels is multiplied by the physical size corresponding to a single pixel to obtain the physical area of the connected component. The physical area calculation formula is as follows: ,in For the number of pixels, The physical size corresponding to a single pixel is defined. All connected components are sorted from largest to smallest according to their physical area, and the connected component with the largest area is extracted as a candidate defect region. The physical area of the candidate defect region is used as the defect size quantification index, and the unit of this index is square millimeters. In this embodiment, the preset size discrimination threshold is set to 0.1 square millimeters. If the defect size quantification index is greater than 0.1 square millimeters, the region is considered a candidate defect region and proceeds to the next step of processing. If the defect size quantification index is less than or equal to 0.1 square millimeters, the region is determined to be an interference region with too small a size and is not processed as a defect. The specific value of the preset size discrimination threshold is determined according to the quality requirement level of the printed material.
[0026] In step S6, if the defect size quantification index is greater than the preset size discrimination threshold, then the grayscale distribution data of all pixels within the area enclosed by the boundary pixel coordinate set is extracted, and the central tendency statistics and dispersion statistics of the pixel grayscale within the area enclosed by the boundary pixel coordinate set are calculated to obtain the target grayscale distribution feature descriptor; the specific grayscale feature descriptor calculation process is as follows: extract the grayscale values of all pixels within the area enclosed by the boundary pixel coordinate set; calculate the central tendency statistics of the pixel grayscale within the area, including the grayscale mean and grayscale median, wherein the grayscale mean is calculated using the following formula: ,in For the first grayscale value of each pixel. Let be the total number of pixels within the region; calculate the statistical measures of grayscale dispersion of pixels within the region, including grayscale standard deviation and grayscale variance, where the formula for calculating grayscale variance is: The gray-level mean, gray-level median, gray-level standard deviation, and gray-level variance are combined to form the target gray-level distribution feature descriptor.
[0027] In step S7, based on the target grayscale distribution feature descriptor, an anomaly detection model based on a random partitioning strategy is used to detect anomalies in the pixels within the area enclosed by the boundary pixel coordinate set. For each pixel location, a quantified value of its deviation from the normal printed texture distribution is output, resulting in an anomaly score sequence reflecting the degree of pixel anomaly within the area. The anomaly detection model based on the random partitioning strategy is constructed using the isolated forest algorithm and contains several isolated trees. The specific anomaly detection process is as follows: An anomaly detection model based on a random partitioning strategy is constructed, which is based on the isolated forest algorithm and contains several isolated trees; statistical modeling is performed on the grayscale distribution features of the normal printed sample to obtain the grayscale distribution parameters of the normal printed texture. and The target grayscale distribution feature descriptor is input into the anomaly detection model. The anomaly detection model calculates the path length of each pixel position relative to the normal distribution; the shorter the path length, the more abnormal the pixel. Each isolated tree in the anomaly detection model based on a random partitioning strategy is constructed using a recursive random partitioning method: at each node, a feature dimension is randomly selected, and then a splitting value is randomly selected within the value range of that feature, dividing the sample into two subsets. This partitioning is repeated until the leaf node contains only a single sample or reaches a preset depth. An anomaly score is calculated based on the path length. The anomaly score calculation formula is as follows: ,in This represents the average path length. For normalization constants, The number of samples is denoted as ; the output is a sequence of anomaly scores consisting of the anomaly scores for all pixel locations within the output region.
[0028] In step S8, if the maximum score value in the abnormal score sequence is greater than the preset abnormality judgment threshold, it is determined that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image. Based on the maximum score value and the preset scoring accuracy mapping relationship, the defect identification confidence value for the printing quality defect is determined. The specific defect judgment process is as follows: The maximum score value is extracted from the abnormal score sequence, representing the deviation degree of the most abnormal pixel in the region; the maximum score value is compared with the preset abnormality judgment threshold, which is set to 0.7; if the maximum score value is greater than 0.7, it is determined that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image; the defect identification confidence value is determined based on the maximum score value and the preset scoring accuracy mapping relationship. The scoring accuracy mapping relationship is as follows: the confidence level is 70% when the maximum score value is in the range of 0.6 to 0.7, 85% when it is in the range of 0.7 to 0.8, 95% when it is in the range of 0.8 to 0.9, and 99% when it is greater than 0.9.
[0029] This embodiment also relates to an online defect detection system for printed materials based on deep learning, used to implement the above method; the system includes an image acquisition and preprocessing module, a texture feature extraction module, a gradient calculation module, an edge enhancement and contour extraction module, a defect size quantization module, a grayscale feature description module, an anomaly detection module, and a defect judgment module; the image acquisition and preprocessing module is used to acquire the original image of the printed surface through an image acquisition device within a preset acquisition time window, and to perform noise suppression processing based on Gaussian kernel function and grayscale conversion processing on the original image to obtain a standardized grayscale image; the texture feature extraction module is used to perform standard... The grayscale image is analyzed using a multi-layer convolutional feature extraction network. By leveraging the receptive field range corresponding to different convolutional kernel sizes, local texture distribution features of the printed texture at multiple spatial scales are extracted, resulting in a texture feature representation matrix. The gradient calculation module calculates the grayscale variation amplitude between horizontally adjacent pixel pairs and vertically adjacent pixel pairs in the standardized grayscale image based on the feature response intensity of each pixel position in the texture feature representation matrix, obtaining a grayscale gradient distribution matrix covering the entire image space. The edge enhancement and contour extraction module extracts target pixels when the grayscale variation amplitude in the grayscale gradient distribution matrix exceeds a preset gradient threshold. The spatial coordinate information corresponding to the region is used to perform edge enhancement processing within the neighborhood of the corresponding spatial coordinate information, determining the set of boundary pixel coordinates that form a closed contour. The defect size quantization module is used to calculate the connected area of pixels within the closed region based on the boundary pixel coordinate set using a connected component labeling algorithm, obtaining a defect size quantification index that reflects the physical size of the printed surface defect. The grayscale feature description module is used to extract the grayscale distribution data of all pixels within the region enclosed by the boundary pixel coordinate set when the defect size quantization index is greater than a preset size discrimination threshold, calculate the central tendency statistics and dispersion statistics of pixel grayscale, and obtain the target The grayscale distribution feature descriptor; the anomaly detection module is used to detect anomalies in pixels within a region enclosed by the set of boundary pixel coordinates using an anomaly detection model based on a random partitioning strategy, based on the target grayscale distribution feature descriptor. For each pixel position, it outputs a quantized value of its deviation from the normal printing texture distribution, resulting in an anomaly score sequence reflecting the degree of pixel anomaly within the region; the defect determination module is used to determine that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image when the maximum score value in the anomaly score sequence is greater than a preset anomaly determination threshold, and determines the defect identification confidence value based on the maximum score value and the preset score accuracy mapping relationship.
[0030] Example 2;
[0031] Based on Example 1, this example elaborates on the defect detection scenario for dark-background printed materials. The difference between this scenario and Example 1 is that the gray values of the edge pixels of light-colored ink spots on dark backgrounds may be similar to the texture fluctuations of the background itself. Simple threshold comparison may misjudge normal textures as defects, while real defects are ignored because the features are not significant enough. The focus of this example is to explain how the detection system adjusts the detection strategy for dark-background printed materials to ensure accurate identification of defects even against complex texture backgrounds.
[0032] In step S1, the image acquisition module activates the charge-coupled sensor to acquire an image of the dark-textured printed surface. The acquisition parameters are consistent with those in Example 1, with the pixel resolution set to 4096×4096 pixels and the frame rate set to 500 frames per second. The original acquired image is subjected to Gaussian kernel convolution, with the standard deviation parameter of the Gaussian kernel set to 1.5 pixels. The image after noise suppression is converted to grayscale, mapping the RGB three-channel image to a single-channel grayscale image to obtain a standardized grayscale image.
[0033] In step S2, a multi-layer convolutional feature extraction network is used to perform texture feature analysis based on the standardized grayscale image. Since the texture contrast of dark backgrounds is low, this embodiment increases the number of channels in the feature map based on embodiment one. The number of convolutional kernels in the first convolutional layer is set to 48, the number of convolutional kernels in the second convolutional layer is set to 96, and the number of convolutional kernels in the third convolutional layer is set to 192 to enhance the feature extraction capability for low-contrast textures. After batch normalization and ReLU activation function processing of the output results of each convolutional layer, the channel dimensions are concatenated to obtain the texture feature representation matrix.
[0034] In step S3, the gray-level gradient distribution matrix is calculated based on the texture feature representation matrix. In a dark background scene, the preset gradient judgment threshold is set to 25 gray levels, which improves the detection sensitivity compared to Example 1, to adapt to the characteristic that the gray-level difference between light-colored ink spots and the background is small on a dark background. The formula for calculating the gradient amplitude is the same as in Example 1. .
[0035] In step S4, a morphological gradient operator is applied to enhance the edge. In the dark background scene, the structuring element radius of the morphological gradient operator is set to 2 pixels to expand the neighborhood range and better capture the edge features of the light-colored ink spots. Contour search and polynomial fitting smoothing are performed on the edge-enhanced binary image to determine the set of boundary pixel coordinates.
[0036] In step S5, the connected component labeling algorithm is used to calculate the defect size quantification index. The preset size discrimination threshold in this embodiment is set to 0.15 square millimeters, which is higher than that in embodiment one, so as to filter out the small interference areas on the dark background caused by texture fluctuations. Only areas with a size greater than 0.15 square millimeters are identified as candidate defect areas.
[0037] In step S6, the target grayscale distribution feature descriptor is calculated. Since the grayscale difference pattern between the defect area and the normal area on the dark background is different from that on the light background, this embodiment adds the skewness coefficient and kurtosis coefficient of the grayscale distribution as additional statistical features on the basis of embodiment one. Together with the grayscale mean, grayscale median, grayscale standard deviation and grayscale variance, they form the target grayscale distribution feature descriptor.
[0038] In step S7, an anomaly detection model based on a random partitioning strategy is used to detect anomaly distributions; the parameter settings for the isolated forest algorithm are the same as in Example 1, but the dimension of the input feature descriptor is increased to 6 dimensions; the formula for calculating the anomaly score remains unchanged. .
[0039] In step S8, defect determination is performed; the preset anomaly determination threshold is set to 0.75, which is higher than that in Example 1, in order to adapt to the characteristics of high noise in dark background scenes; only areas with anomaly scores exceeding 0.75 are determined to have printing quality defects; the defect identification confidence level is determined according to the scoring accuracy mapping relationship.
[0040] The test in Example 2 verifies the detection system's ability to detect defects in dark-background printed materials, effectively distinguishing normal texture fluctuations from actual defect information on dark backgrounds, and solving the problem of difficulty in identifying light-colored ink spots on dark backgrounds.
[0041] Example 3;
[0042] Building upon Examples 1 and 2, this example elaborates on the detection scenario of small defects at high resolution. The difference between this scenario and the previous two examples is that printing defects are characterized by being small, scattered, and having blurred boundaries. Ink spots may be only a few tenths of a millimeter in size. These minute features occupy a very limited pixel area in the high-resolution image, and the grayscale difference between them and the surrounding normal printing area is not obvious. The focus of this example is to explain how the detection system adjusts the detection strategy for small defects to achieve pixel-level accurate identification of minute printing defects.
[0043] In step S1, the image acquisition module uses a higher resolution industrial camera to acquire images, with a pixel resolution of 8192×8192 pixels, which is twice that of Example 1; the frame rate is set to 250 frames per second to meet the data processing requirements of high-resolution images; a Gaussian kernel function convolution operation is performed on the original acquired image, with the standard deviation parameter of the Gaussian kernel function set to 1.2 pixels, which is lower than that of Example 1, in order to retain more detail information; the image after noise suppression processing is converted to grayscale to obtain a standardized grayscale image.
[0044] In step S2, a multi-layer convolutional feature extraction network is used for texture feature analysis. In high-resolution scenes, this embodiment adds a fourth convolutional layer with a 9×9 kernel size and 256 kernels to extract coarser-grained global features to meet the feature extraction requirements of large images. After batch normalization and ReLU activation, the output results of each convolutional layer are concatenated along the channel dimension to obtain the texture feature representation matrix.
[0045] In step S3, the gray-level gradient distribution matrix is calculated based on the texture feature representation matrix. In the case of small defects, the preset gradient judgment threshold is set to 15 gray levels, which is significantly lower than that in Example 1 and Example 2, so as to enhance the sensitivity to small gray-level changes. The formula for calculating the gradient amplitude is the same as that in Example 1.
[0046] In step S4, a morphological gradient operator is applied to perform edge enhancement processing. In the case of small defects, the structuring element radius of the morphological gradient operator is set to 1 pixel, maintaining the same setting as in Example 1, in order to accurately locate the edge of the small defect. Contour search and polynomial fitting smoothing processing are performed on the edge-enhanced binary image to determine the set of boundary pixel coordinates.
[0047] In step S5, a connected component labeling algorithm is used to calculate the defect size quantification index. The preset size discrimination threshold in this embodiment is set to 0.05 square millimeters, significantly lower than in Embodiments 1 and 2, to allow smaller defects to be identified as valid defects. The formula for calculating the physical area is the same as in Embodiment 1. Sort all connected components by their physical area from largest to smallest, and extract the connected component with the largest area as the candidate defect region.
[0048] In step S6, the target gray-scale distribution feature descriptor is calculated. Since the number of pixels in the small defect area is small, this embodiment uses accurate calculation based on all pixels when calculating gray-scale statistical features to ensure the accuracy of the statistics. The calculation formulas for gray-scale mean, gray-scale median, gray-scale standard deviation and gray-scale variance are the same as in embodiment one.
[0049] In step S7, an anomaly detection model based on a random partitioning strategy is used to detect anomaly distribution. In the case of minor defects, the number of trees in the isolated forest algorithm is set to 200, which is increased compared to Example 1, in order to improve the accuracy of anomaly detection for a small number of samples. The calculation formula for anomaly score is the same as in Example 1.
[0050] In step S8, defect determination is performed; the preset anomaly determination threshold is set to 0.6, which is significantly lower than that in Example 1 and Example 2, in order to adapt to the characteristic that the anomaly scores are generally low in small defect scenarios; only areas with anomaly scores exceeding 0.6 are determined to have printing quality defects; the defect identification confidence level is determined according to the scoring accuracy mapping relationship.
[0051] The test in Example 3 verifies the detection system's ability to detect small printing defects at high resolution, achieving pixel-level accurate identification and solving the problem of difficult detection of minute defects.
[0052] In summary, this invention comprehensively elucidates the technical implementation of a method and system for detecting surface defects in printed materials based on industrial vision through specific embodiments 1, 2, and 3. The three embodiments respectively cover three typical scenarios: conventional printed materials, dark-textured printed materials, and high-resolution small defects. A multi-layer convolutional feature extraction network extracts printing texture features at multiple spatial scales. A combination of gray-level gradient distribution matrix and morphological gradient operator achieves precise positioning of defect edges. A connected component labeling algorithm quantifies the physical size of defects to filter out excessively small interference areas. An anomaly detection model based on a random partitioning strategy performs secondary discrimination of defect areas and combines gray-level distribution feature descriptors to comprehensively evaluate the degree of pixel anomalies. This achieves pixel-level accurate identification of minute printing defects, automatically adapting to changes in different products and printing conditions without relying on manual parameter tuning, while ensuring the real-time performance of the detection results meets online quality inspection requirements.
[0053] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit the scope of protection of the present invention. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the essence and scope of the technical solutions of the present invention.
Claims
1. A deep learning-based online defect detection method for printed materials, characterized in that: Includes the following steps: S1. Acquire the original image of the printed surface within a preset acquisition time window using an image acquisition device, and perform Gaussian kernel function noise suppression and multi-channel grayscale conversion processing on the original image to obtain a standardized grayscale image. S2. Based on standardized grayscale images, a multi-layer convolutional feature extraction network is used for texture feature analysis. By using the receptive fields corresponding to different convolutional kernel sizes, the local distribution features of printing texture under multiple spatial scales are extracted to obtain the texture feature representation matrix. S3. Based on the feature response intensity of each pixel in the texture feature characterization matrix, calculate the gray level change amplitude of adjacent pixel pairs in the horizontal and vertical directions of the standardized gray level image to obtain the gray level gradient distribution matrix covering the entire image. S4. If there is a target region in the gray-level gradient distribution matrix whose gray-level change amplitude is greater than the preset gradient judgment threshold, extract its spatial coordinate information, apply the morphological gradient operator to the edge enhancement in the corresponding neighborhood, and determine the set of boundary pixel coordinates that form a closed contour. S5. Based on the set of boundary pixel coordinates, the connected component labeling algorithm is used to calculate the connected area of pixels within the closed region to obtain the quantitative index of defect size. S6. If the defect size quantification index is greater than the preset size discrimination threshold, extract the grayscale distribution data of all pixels within the boundary area, calculate the grayscale central tendency and dispersion statistics, and obtain the target grayscale distribution feature descriptor. S7. Based on the target grayscale distribution feature descriptor, an anomaly detection model based on a random partitioning strategy is used to detect anomalies in the pixels within the region, and the deviation of each pixel from the normal printed texture distribution is quantified to obtain an anomaly score sequence. S8. If the maximum score value of the abnormal score sequence is greater than the preset abnormal judgment threshold, it is determined that there is a quality defect on the surface of the printed matter, and the confidence value of defect identification is determined.
2. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S1 specifically includes: S11. Activate the charge-coupled sensor of the image acquisition device to acquire images of the printed surface according to the preset pixel resolution and frame rate, and obtain the original acquired image containing the printed pattern. S12. Perform Gaussian kernel convolution operation on the original acquired image to eliminate the influence of random noise and sensor thermal noise; S13. Perform grayscale conversion on the image after noise suppression processing, mapping the RGB three-channel image to a single-channel grayscale image to obtain a standardized grayscale image.
3. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S2 specifically includes: S21. Construct a multi-layer convolutional feature extraction network, which includes an input layer, a first convolutional layer, a second convolutional layer, a third convolutional layer, and an output layer connected in sequence. S22. Configure the first convolution kernel in the first convolutional layer to extract fine-grained local features of the printed texture; S23. Configure a second convolution kernel in the second convolutional layer to extract medium-scale features of the printed texture; S24. Configure a third convolution kernel in the third convolutional layer to extract coarse-grained global features of the printed texture; S25. Perform batch normalization and ReLU activation on the output of each convolutional layer, and concatenate the feature maps of each layer by channel dimension to obtain the texture feature representation matrix.
4. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S3 specifically includes: S31. Extract the feature response values of each pixel position in the texture feature representation matrix, and perform global average pooling on the three-dimensional feature tensor along the channel dimension to obtain the two-dimensional feature response map. S32. Apply the Sobel operator to the two-dimensional feature response map to calculate the gradient; S33. Sum the squares of the horizontal and vertical convolution results and then take the square root to obtain the gradient magnitude at each pixel position. S34. Map the calculated gradient magnitude to the corresponding pixel position according to the spatial coordinates of the original image to form a gray-level gradient distribution matrix.
5. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S4 specifically includes: S41. Extract the pixel location coordinates in the gray-level gradient distribution matrix where the gradient magnitude exceeds the preset gradient judgment threshold, and obtain the spatial coordinate set of the target pixel region. S42. For each pixel position in the set of spatial coordinates, apply the morphological gradient operator to perform edge enhancement processing. The morphological gradient operator consists of the difference between the dilation operation and the erosion operation. S43. Perform contour search on the edge-enhanced binary image to extract the set of boundary pixel coordinates that form a closed curve; S44. Perform polynomial fitting smoothing on the extracted contours to eliminate the interference of isolated noise points on the integrity of the contours.
6. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S5 specifically includes: S51. Mark the connected components of the closed region enclosed by the set of boundary pixel coordinates. Use the eight-connectivity discrimination criterion to mark all sets of mutually connected pixels. S52. Calculate the total number of pixels contained in each connected component, multiply the number of pixels by the physical size corresponding to a single pixel, and obtain the physical area of the connected component. S53. Sort all connected components in descending order of physical area, and extract the connected component with the largest area as the candidate defect region. S54. Use the physical area of the candidate defect region as a quantitative indicator of defect size.
7. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S6 specifically includes: S61. Extract the grayscale values of all pixels within the region enclosed by the set of boundary pixel coordinates; S62. Calculate the central tendency statistics of pixel gray levels within the region, including the gray level mean and gray level median; S63. Calculate the statistical measures of the dispersion of pixel gray levels within the region, including the standard deviation and variance of gray levels; S64. Combine the gray mean, gray median, gray standard deviation, and gray variance into a target gray distribution feature descriptor.
8. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S7 specifically includes: S71. Construct an anomaly detection model based on a random partitioning strategy. This model is built on the isolated forest algorithm and contains several isolated trees. S72. Perform statistical modeling on the grayscale distribution characteristics of normal printed matter samples; S73. Input the target grayscale distribution feature descriptor into the anomaly detection model. The anomaly detection model calculates the path length of each pixel position relative to the normal distribution. The shorter the path length, the more abnormal the pixel is. S74. Calculate the anomaly score based on the path length; S75, an anomaly score sequence consisting of anomaly scores for all pixel locations within the output area.
9. The online defect detection method for printed materials based on deep learning according to claim 1, characterized in that: Step S8 specifically includes: S81. Extract the maximum score value from the abnormal score sequence. The maximum score value represents the degree of deviation of the most abnormal pixel in the region. S82. Compare the maximum score value with the preset anomaly detection threshold; S83. If the maximum score value is greater than the preset anomaly judgment threshold, it is determined that there is a printing quality defect on the surface of the printed matter corresponding to the standardized grayscale image. S84. Determine the defect identification confidence value based on the maximum score value and the preset score accuracy mapping relationship.
10. A deep learning-based online defect detection system for printed materials, characterized in that: include: The image acquisition and preprocessing module is used to acquire the original image of the printed surface through the image acquisition device within a preset acquisition time window, and then obtain a standardized grayscale image through Gaussian kernel function noise suppression and multi-channel grayscale conversion processing. The texture feature extraction module is used to extract the distribution features of printing texture at multiple spatial scales based on a standardized grayscale image using a multi-layer convolutional feature extraction network, and obtain the texture feature representation matrix. The gradient calculation module is used to calculate the gray-level change amplitude in the horizontal and vertical directions based on the pixel feature response intensity of the texture feature characterization matrix, and obtain the gray-level gradient distribution matrix of the entire image. The edge enhancement and contour extraction module is used to extract the spatial coordinates of target areas where the grayscale variation exceeds the threshold. After edge enhancement by morphological gradient operators, the set of boundary pixel coordinates of the closed contour is determined. The defect size quantification module is used to calculate the connected area of a closed region using a connected component labeling algorithm, thereby obtaining a defect size quantification index that reflects the physical size of the defect. The grayscale feature description module is used to extract pixel grayscale distribution data within the region when the defect size exceeds the threshold, calculate the central tendency and dispersion statistics, and obtain the target grayscale distribution feature descriptor. The anomaly detection module is used to output pixel deviation quantization values based on the target grayscale distribution feature descriptor and an anomaly detection model with a random partitioning strategy to obtain an anomaly score sequence. The defect determination module is used to determine that the printed material has a quality defect when the maximum abnormal score exceeds the threshold, and to determine the confidence level value of defect identification.