Method and system for online detection of printed matter based on machine vision
By constructing a database of printed images and training a generative adversarial network, the accuracy and stability issues of printed material detection under various imaging conditions were solved, achieving efficient defect detection of printed materials.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHONGWEN GROUP SHANDONG PRINTING CO LTD
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-23
AI Technical Summary
Existing printed matter inspection technologies are unable to fully cover a variety of imaging conditions under different time, lighting conditions, shooting angles, and conveyor belt postures, resulting in insufficient inspection accuracy and stability.
A printed image library is constructed, and feature classification and compression windowing are performed. A generative adversarial network is trained, and adversarial training is conducted through a VAE encoder and a defect identification model to generate a complete adversarial network for printing defect detection.
It improves the accuracy and robustness of printed defect detection, increases detection efficiency, and enables stable detection under various environmental conditions.
Smart Images

Figure CN122265196A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of printed matter inspection technology, and in particular to an online inspection method and system for printed matter based on machine vision. Background Technology
[0002] With the continuous improvement of automation and intelligence in the printing manufacturing industry, the quality inspection of printed materials is gradually shifting from manual visual inspection to automated inspection based on machine vision. Collecting images of the printed surface and identifying printing defects using machine vision has become an important technical means to improve inspection efficiency, reduce labor costs, and enhance product consistency.
[0003] Existing printing inspection technologies typically rely on machine vision and automated optical inspection. These technologies use high-speed industrial cameras to capture images in real-time during the printing process and employ algorithms such as template matching and pixel-level comparison to automatically identify defects like dirt and scratches. In recent years, deep learning algorithms have been gradually integrated with machine vision, significantly improving the accuracy of defect identification in complex backgrounds.
[0004] However, in actual production, the appearance of printed materials varies significantly under different times, lighting conditions, shooting angles, and conveyor belt postures, leading to substantial differences in the image feature distribution of the same standard printed material in different environments. Existing technologies typically identify printing defects based on fixed reference samples or single discrimination conditions, which struggles to adequately cover the diverse imaging scenarios that may occur in actual production, thus affecting the accuracy and stability of printed material defect detection. Therefore, there is an urgent need for a defect detection method capable of automating the detection of printed materials under various imaging conditions. Summary of the Invention
[0005] This invention provides a machine vision-based online inspection method for printed materials and a computer-readable storage medium. Its main purpose is to improve the accuracy and robustness of defect detection in printed materials and increase the efficiency of printed material inspection.
[0006] To achieve the above objectives, the present invention provides an online inspection method for printed materials based on machine vision, comprising:
[0007] Obtain a printed matter image library, which includes: multiple standard printed matter images and multiple defective printed matter images;
[0008] The printed image library is classified by features to obtain multiple feature image libraries, which include: a standard feature image set and a defect feature image set;
[0009] Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, which include: multiple standard window matrices and multiple defect window matrices;
[0010] Perform the following operation on each of the multiple window matrix libraries:
[0011] Multiple standard window matrices and multiple defective window matrices in the window matrix library are trained and grouped to obtain training matrix set, defective matrix set, positive verification matrix set, negative verification matrix set, positive adversarial matrix set, and negative adversarial matrix set;
[0012] The pre-constructed discrimination model is trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain the defect identification model;
[0013] Generative Adversarial Networks (GANs) are constructed based on pre-built VAE encoders and defect identification models. The GANs are then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network.
[0014] The completed adversarial networks are summarized, resulting in multiple completed adversarial networks, each corresponding one-to-one with a window matrix library;
[0015] Receive a printing inspection command, identify multiple images to be inspected based on the printing inspection command, and perform the following operations on each of the multiple images to be inspected:
[0016] The image to be detected is weighted and evaluated to obtain the feature matrix to be detected and the weight coefficient set;
[0017] Based on the weight coefficient group and multiple complete adversarial networks, the printing defect index is obtained by identifying the feature matrix to be detected.
[0018] By summing up the printing defect indices, multiple printing defect indices are obtained.
[0019] Based on multiple printing defect indices and multiple images to be inspected, multiple printing defect images are identified, and online inspection of printed materials is completed.
[0020] Optionally, the feature classification of the printed image library yields multiple feature image libraries, including:
[0021] Perform the following operation on each of the multiple standard printed images in the printed image library:
[0022] A standard printed image is converted to grayscale to obtain a grayscale printed image, wherein the grayscale printed image includes: multiple grayscale pixels, and each grayscale pixel includes: a printed grayscale value;
[0023] Identify the top left, top right, bottom left, bottom right, and center printing points of the grayscale printed image;
[0024] The first grayscale offset rate is calculated based on the top left printing point, bottom right printing point, and center printing point, using the following formula:
[0025]
[0026] in, The first grayscale offset rate, , and These are the printing gray values of the upper left printing point, the lower right printing point, and the center printing point, respectively.
[0027] The second grayscale offset rate is calculated based on the upper right printing point, the lower left printing point, and the center printing point.
[0028] The average grayscale value is determined based on multiple grayscale pixels in a grayscale printed image. The average grayscale value is the average of the grayscale values of multiple grayscale pixels.
[0029] The first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value are summarized separately to obtain multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple average printed grayscale values. Among them, the first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value all correspond one-to-one with the standard printed image.
[0030] Multiple standard printed images and multiple defective printed images are classified based on multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple printing grayscale averages to obtain multiple feature image libraries.
[0031] Optionally, the classification of multiple standard printed matter images and multiple defective printed matter images based on multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple printing grayscale averages yields multiple feature image libraries, including:
[0032] The first grayscale offset range is determined based on multiple first grayscale offset rates, wherein the maximum value of the first grayscale offset range is the largest first grayscale offset rate among multiple first grayscale offset rates, and the minimum value of the first grayscale offset range is the smallest first grayscale offset rate among multiple first grayscale offset rates.
[0033] Based on the preset number of categories, the first grayscale offset range is sampled at equal intervals to obtain a first reference offset rates, where a is the number of categories;
[0034] Based on multiple second grayscale offset rates and the number of categories, a second reference offset rate is determined, and based on multiple printing grayscale averages and the number of categories, a reference grayscale average is determined.
[0035] Based on a first reference offset, a second reference offset, and a reference gray-scale mean, Q feature groups are identified, where Q = a 3 Each feature group consists of a first reference offset, a second reference offset, and a reference grayscale mean.
[0036] Q image storage devices were identified based on Q feature groups;
[0037] Extract the i-th standard printed image from multiple standard printed images, where the initial value of i is 1;
[0038] Perform the following operation on each of the Q feature groups:
[0039] The feature difference rate is calculated based on the feature group, the first gray-scale offset rate corresponding to the i-th standard printed image in multiple first gray-scale offset rates, the second gray-scale offset rate corresponding to the i-th standard printed image in multiple second gray-scale offset rates, and the printing gray-scale mean corresponding to the i-th standard printed image in multiple printing gray-scale mean values.
[0040] Compare the feature difference rate with the preset difference threshold. If the feature difference rate is less than or equal to the difference threshold, then store the i-th standard printed image in the image memory corresponding to the feature group in the Q image memory to obtain the updated memory.
[0041] Let I = i + 1, take I as i, and return to the step of extracting the i-th standard printed image from multiple standard printed images until I = 0, where 0 is the number of printed images in the multiple standard printed images;
[0042] The update memories corresponding to the feature groups are summarized to obtain Q update memories;
[0043] Q standard feature image sets are extracted from Q update memories, wherein each standard feature image set corresponds one-to-one with an update memory, and each standard feature image set includes multiple standard feature images.
[0044] Based on multiple defective printed images, obtain multiple first defect offset rates, multiple second defect offset rates, and multiple printing defect averages;
[0045] Based on multiple defective printed images, multiple first defect offset rates, multiple second defect offset rates, multiple printing defect averages, Q feature groups, Q image storage devices, and difference thresholds, a set of Q defect feature images is identified. The set of defect feature images includes: multiple defect feature images.
[0046] Perform the following operation on each of the Q feature groups:
[0047] The feature image library is obtained by summarizing the standard feature image sets corresponding to the feature group in the Q standard feature image sets and the defect feature image sets corresponding to the feature group in the Q defect feature image sets.
[0048] By compiling the feature image database, multiple feature image databases are obtained.
[0049] Optionally, the compression and windowing of multiple feature image libraries to obtain multiple window matrix libraries includes:
[0050] Perform the following operation on each of the multiple feature image libraries:
[0051] Extract standard feature images sequentially from the standard feature image set in the feature image library, and perform the following operations on the extracted standard feature images:
[0052] The standard feature image is divided into multiple standard feature windows based on a pre-constructed image partitioning window. Each standard feature window includes multiple window pixels.
[0053] Perform the following operation on each of the multiple standard feature windows:
[0054] The window grayscale value is calculated based on multiple window pixels in the standard feature window, where the window grayscale value is the average of the printed grayscale values of multiple window pixels.
[0055] Summarize the grayscale values of the windows to obtain grayscale values for multiple windows;
[0056] The gray values of multiple windows are mapped to their positions on a standard feature image to obtain a standard window matrix;
[0057] By summing the standard window matrices corresponding to the standard feature images, multiple standard window matrices are obtained;
[0058] Multiple defect window matrices are obtained from the defect feature image set based on the feature image library;
[0059] By aggregating multiple standard window matrices and multiple defective window matrices, a window matrix library is obtained;
[0060] The window matrix libraries are aggregated to obtain multiple window matrix libraries.
[0061] Optionally, the step of training the pre-constructed discriminant model using a training matrix set, a defect matrix set, a positive verification matrix set, and a negative verification matrix set to obtain a defect identification model includes:
[0062] For each standard window matrix in the training matrix set, perform the following operation:
[0063] The preset integer value is combined with the standard window matrix to obtain the normal training group;
[0064] By aggregating the standard training sets, multiple standard training sets are obtained;
[0065] Multiple defect training groups are obtained based on a preset set of zero values and defect matrices;
[0066] The discriminant model is trained using multiple regular training groups and multiple defective training groups to obtain an updated discriminant model;
[0067] For each standard window matrix in the positive validation matrix set, perform the following operation:
[0068] The standard window matrix is input into the updated discriminant model to obtain the discriminant value;
[0069] Summarize the discriminant values to obtain multiple discriminant values, and calculate the mean of positive discriminant values based on the multiple discriminant values;
[0070] Obtain the negative discriminant mean based on the negative validation matrix set and the updated discriminant model;
[0071] The model evaluation value is calculated based on the positive and negative discriminant means;
[0072] Compare the model evaluation value with the preset error detection threshold. If the model evaluation value is less than the error detection threshold, the updated discriminant model is used as the defect identification model. Otherwise, the updated discriminant model is used as the discriminant model. Return to the step of training the discriminant model using multiple regular training groups and multiple defect training groups until the model evaluation value is less than the error detection threshold.
[0073] Optionally, the step of performing adversarial training on the generative adversarial network based on the positive adversarial matrix set and the negative adversarial matrix set to obtain a complete adversarial network includes:
[0074] Extract standard window matrices sequentially from the set of positive adversarial matrices, and perform the following operations on the extracted standard window matrices:
[0075] The generative adversarial network is trained using a standard window matrix to obtain an updated adversarial network;
[0076] The updated adversarial network is used as the generative adversarial network. The step of sequentially extracting standard window matrices from the set of positive adversarial matrices is repeated until all standard window matrices in the set of positive adversarial matrices have been extracted. The updated adversarial network is then used as the discriminative adversarial network.
[0077] The discriminative adversarial network is self-generated and trained based on the positive and negative adversarial matrix sets to obtain the complete adversarial network.
[0078] Optionally, the step of weighting the image to be detected to obtain the feature matrix to be detected and the weight coefficient set includes:
[0079] The first current offset rate, the second current offset rate, and the current grayscale mean are obtained based on the image to be detected.
[0080] Perform the following operation on each of the Q feature groups:
[0081] The current difference rate is calculated based on the feature group, the first current offset rate, the second current offset rate, and the current grayscale mean.
[0082] Summarize the current difference rates to obtain multiple current difference rates, and based on these multiple current difference rates, determine the first difference rate, the second difference rate, and the third difference rate.
[0083] The total difference is calculated based on the first difference rate, the second difference rate, and the third difference rate, where the total difference is the sum of the first difference rate, the second difference rate, and the third difference rate;
[0084] The first image weight is calculated based on the first difference rate and the sum of differences.
[0085] The second image weight is calculated based on the second difference rate and the sum of differences, and the third image weight is calculated based on the third difference rate and the sum of differences.
[0086] Summarize the weights of the first image, the second image, and the third image to obtain a weight coefficient set;
[0087] Obtain the feature matrix to be detected based on the image to be detected.
[0088] Optionally, the step of identifying the printing defect index based on the weighted coefficient set and multiple complete adversarial networks of the feature matrix to be detected, including:
[0089] Obtain a grayscale detection image based on the image to be detected;
[0090] Edge detection is performed on the grayscale detection image to obtain multiple edge pixels;
[0091] Multiple interlayer pixels and pixel areas were identified based on multiple edge pixels;
[0092] The average gray value of the edge is obtained based on multiple edge pixels, and the average gray value of the interlayer is obtained based on multiple interlayer pixels.
[0093] The first adversarial network is denoted as the first adversarial network, which corresponds to the first image weight in the weight coefficient group among multiple complete adversarial networks.
[0094] The first adversarial network is used to distinguish the feature matrix to be detected, and the first discrimination value is obtained.
[0095] A second discriminant value is determined based on the second image weights and multiple complete adversarial networks, and a third discriminant value is determined based on the third image weights and multiple complete adversarial networks.
[0096] The printing defect index is calculated based on pixel area, average edge grayscale, average interlayer grayscale, first image weight, second image weight, third image weight, first discrimination value, second discrimination value, and third discrimination value. The calculation formula is as follows:
[0097]
[0098] in, This is the printing defect index. , and These are the first image weights, the second image weights, and the third image weights, respectively. , and These are the first, second, and third discrimination values, respectively. and These are the average gray values at the edges and the average gray values of the interlayer, respectively. and These are the pixel area and the preset reference area, respectively. It is the hyperbolic tangent function. It is a natural constant. Refers to taking the absolute value.
[0099] Optionally, the step of identifying multiple printing defect images based on multiple printing defect indices and multiple images to be detected includes:
[0100] Perform the following operation on all printing defect indices among the multiple printing defect indices:
[0101] Compare the printing defect index with a preset defect threshold. If the printing defect index is greater than or equal to the defect threshold, then the image to be detected corresponding to the printing defect index among multiple images to be detected is recorded as a printing defect image.
[0102] The images of printing defects are compiled to obtain multiple images of printing defects.
[0103] To achieve the above objectives, the present invention also provides an online inspection system for printed materials based on machine vision, comprising:
[0104] The printing image classification module is used to obtain a printing image library, which includes multiple standard printing images and multiple defective printing images. The printing image library is classified by features to obtain multiple feature image libraries, which include a standard feature image set and a defective feature image set.
[0105] The image matrix training module is used to compress and window multiple feature image libraries to obtain multiple window matrix libraries. The window matrix library includes multiple standard window matrices and multiple defect window matrices. For each window matrix library, the following operations are performed: the multiple standard window matrices and multiple defect window matrices in the window matrix library are grouped for training to obtain a training matrix set, a defect matrix set, a positive verification matrix set, a negative verification matrix set, a positive adversarial matrix set, and a negative adversarial matrix set. The pre-constructed discriminant model is trained using the training matrix set, the defect matrix set, the positive verification matrix set, and the negative verification matrix set to obtain a defect identification model.
[0106] The adversarial network construction module is used to build a generative adversarial network based on a pre-built VAE encoder and defect identification model. The generative adversarial network is trained adversarially based on a positive adversarial matrix set and a negative adversarial matrix set to obtain a complete adversarial network. The complete adversarial networks are summarized to obtain multiple complete adversarial networks. Each complete adversarial network corresponds one-to-one with the window matrix library.
[0107] The printed image detection module receives printing detection instructions, identifies multiple images to be detected based on these instructions, and performs the following operations on each of the multiple images to be detected: performs weight evaluation on the image to be detected to obtain a feature matrix to be detected and a set of weight coefficients; identifies the feature matrix to be detected based on the set of weight coefficients and multiple complete adversarial networks to obtain a printing defect index; summarizes the printing defect indices to obtain multiple printing defect indices; and identifies multiple printing defect images based on the multiple printing defect indices and the multiple images to be detected, thus completing the online detection of printed materials.
[0108] To address the above problems, the present invention also provides an electronic device, the electronic device comprising:
[0109] Memory, storing at least one instruction;
[0110] The processor executes the instructions stored in the memory to implement the machine vision-based online inspection method for printed materials described above.
[0111] To address the aforementioned problems, the present invention also provides a computer-readable storage medium storing at least one instruction, which is executed by a processor in an electronic device to implement the above-described machine vision-based online inspection method for printed materials.
[0112] To address the problems described in the background section, this invention provides a printed matter image library. This library includes multiple standard printed matter images and multiple defective printed matter images. By acquiring this image library, the training samples cover the appearance variations of printed matter under different production batches, printing environments, and imaging conditions. This improves the adaptability of subsequent models to various imaging environments and provides diverse basic data support for subsequent feature classification and model training. Furthermore, feature classification is performed on the printed matter image library to obtain multiple feature image libraries, including a standard feature image set and a defective feature image set. This embodiment constructs multiple feature image libraries containing standard feature image sets and defect feature image sets, enabling group management of printed images under different feature distribution conditions. This allows subsequent models to model separately for different imaging characteristics, improving the model's ability to distinguish printing defect features under different poses, lighting conditions, and printing states. Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, including multiple standard window matrices and multiple defect window matrices. Thus, this embodiment effectively reduces the dimensionality of input data by converting the original high-resolution image into multiple window matrices, while preserving the grayscale statistical features of local regions. This allows the model to learn based on local structural features, thereby reducing computational complexity. While reducing computational complexity, this invention improves sensitivity to local defect features. For each window matrix library, the following operations are performed: multiple standard window matrices and multiple defect window matrices in the window matrix library are grouped for training, resulting in a training matrix set, a defect matrix set, a positive verification matrix set, a negative verification matrix set, a positive adversarial matrix set, and a negative adversarial matrix set. The pre-built discriminant model is then trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain a defect identification model. Therefore, this embodiment of the invention trains the pre-built discriminant model using the training matrix set, defect matrix set, and verification matrix set, enabling the defect identification model to learn the differences between the standard window matrix and the defect window matrix. Online detection provides a stable and reliable preliminary detection model. A generative adversarial network (GAN) is constructed based on a pre-built VAE encoder and defect identification model. The GAN is then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network (CAN). These CANs are then aggregated to obtain multiple CANs. Each CAN corresponds one-to-one with a window matrix library. Thus, this embodiment of the invention constructs a GAN using a VAE encoder and a defect identification model, and trains it adversarially using a positive adversarial matrix set. This enables the VAE encoder to generate diverse reconstruction matrices using the potential distribution of standard window matrices, simulating various imaging variations that may occur in actual production processes, thereby expanding the feature distribution of standard samples.This invention significantly improves the accuracy and robustness of the defect identification model in detecting printing defects under complex working conditions. It receives printing inspection instructions, identifies multiple images to be inspected based on these instructions, and performs the following operations on each image: weight evaluation of the image to be inspected to obtain a feature matrix and a set of weight coefficients; identification of the feature matrix based on the weight coefficients and multiple complete adversarial networks to obtain a printing defect index. As can be seen, this embodiment analyzes the image to be inspected, matches it with image features in multiple previously constructed feature groups, uses the complete adversarial network corresponding to the feature group most similar to the image to be inspected to detect defects, and weights and fuses the outputs of each complete adversarial network according to weight coefficients determined by similarity, ultimately obtaining a printing defect index that comprehensively reflects the degree of defect in the image to be inspected. This avoids misjudgment caused by a single model under conditions of mismatched image features, effectively improving the accuracy and robustness of printing defect detection under various environmental conditions. By summarizing printing defect indices, multiple printing defect indices are obtained. Based on these indices and multiple images to be inspected, multiple printing defect images are identified, completing the online inspection of printed materials. It is evident that this embodiment of the invention, by automatically identifying multiple printing defect images, enables workers to quickly locate printed materials with quality problems, achieving rapid screening and processing of abnormal printed materials, thereby significantly improving the efficiency of online printing inspection and increasing the automation level of printing inspection. Therefore, this invention can improve the accuracy and robustness of printing defect detection and enhance the efficiency of printing inspection. Attached Figure Description
[0113] Figure 1 This is a schematic flowchart of a machine vision-based online inspection method for printed materials provided in an embodiment of the present invention.
[0114] Figure 2 A functional block diagram of a machine vision-based online inspection system for printed materials provided in an embodiment of the present invention;
[0115] Figure 3 This is a schematic diagram of the structure of an electronic device that implements the machine vision-based online inspection method for printed materials, according to an embodiment of the present invention.
[0116] Explanation of reference numerals in the attached figures:
[0117] 10. Electronic device; 11. Processor; 12. Memory; 13. Bus.
[0118] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0119] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0120] This application provides a machine vision-based online inspection method for printed materials. The execution entity of the machine vision-based online inspection method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application: a server, a terminal, etc. In other words, the machine vision-based online inspection method for printed materials can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster.
[0121] Reference Figure 1 The diagram shown is a flowchart illustrating an online inspection method for printed materials based on machine vision, according to an embodiment of the present invention. In this embodiment, the online inspection method for printed materials based on machine vision includes:
[0122] S1. Obtain the printed matter image library, which includes: multiple standard printed matter images and multiple defective printed matter images.
[0123] It should be understood that the environment during printed material inspection is subject to fluctuations in factors such as lighting, shooting angle, and conveyor belt posture. Existing technologies often rely on images acquired under a single environment or shooting condition for printed material inspection, which fails to adequately cover the diverse imaging situations that may occur in actual production, thus affecting the generalization ability and recognition accuracy of the detection model. Therefore, this invention constructs a printed material image library by collecting printed material images from multiple times and printing environments as samples. Subsequently, it combines generative models from generative adversarial networks to model and expand the feature distribution of standard printed material images to simulate various imaging variations that may occur in actual production, thereby improving the accuracy and robustness of subsequent printed material inspection and recognition.
[0124] For example, a printing factory acquires multiple printed images by collecting surface images of multiple printed products produced historically. The acquisition time, printing environment (humidity, temperature, and lighting), and printed product posture (angle and height deviation on the conveyor belt) of these multiple printed images do not need to be exactly the same. This allows the printed image library to more comprehensively cover imaging variations that may occur in actual production, thus providing more sufficient and diverse training samples for subsequent printed product inspection, while ensuring that the printed patterns are identical. Then, the multiple printed images are manually distinguished into multiple images of acceptable printing and multiple images of printing defects (stains, omissions, color deviations, scratches, etc.). The multiple acceptable printing images are the multiple standard printed product images, and the multiple images of printing defects are the multiple defective printed product images. Both the multiple standard printed product images and the multiple defective printed product images are stored in a database, resulting in the printed image library.
[0125] S2. Perform feature classification on the printed image library to obtain multiple feature image libraries, including: standard feature image set and defect feature image set.
[0126] In detail, the feature classification of the printed image library yields multiple feature image libraries, including:
[0127] Perform the following operation on each of the multiple standard printed images in the printed image library:
[0128] A standard printed image is converted to grayscale to obtain a grayscale printed image, wherein the grayscale printed image includes: multiple grayscale pixels, and each grayscale pixel includes: a printed grayscale value;
[0129] Identify the top left, top right, bottom left, bottom right, and center printing points of the grayscale printed image;
[0130] The first grayscale offset rate is calculated based on the top left printing point, bottom right printing point, and center printing point, using the following formula:
[0131]
[0132] in, The first grayscale offset rate, , and These are the printing gray values of the upper left printing point, the lower right printing point, and the center printing point, respectively.
[0133] The second grayscale offset rate is calculated based on the upper right printing point, the lower left printing point, and the center printing point.
[0134] The average grayscale value is determined based on multiple grayscale pixels in a grayscale printed image. The average grayscale value is the average of the grayscale values of multiple grayscale pixels.
[0135] The first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value are summarized separately to obtain multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple average printed grayscale values. Among them, the first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value all correspond one-to-one with the standard printed image.
[0136] Multiple standard printed images and multiple defective printed images are classified based on multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple printing grayscale averages to obtain multiple feature image libraries.
[0137] It should be explained that converting a standard printed image to grayscale means converting every pixel in the standard printed image to grayscale. The grayscale printed image is the grayscale-converted standard printed image, and a grayscale pixel refers to a pixel in the grayscale printed image. The printed grayscale value refers to the grayscale value of a grayscale pixel. The top-left printed point refers to the first grayscale pixel at the top left corner of the grayscale printed image, the top-right printed point refers to the first grayscale pixel at the top right corner of the grayscale printed image, the bottom-left printed point refers to the first grayscale pixel at the bottom left corner of the grayscale printed image, the bottom-right printed point refers to the first grayscale pixel at the bottom right corner of the grayscale printed image, and the center printed point is the grayscale pixel located at the geometric center of the grayscale printed image.
[0138] It should be understood that the first grayscale offset rate characterizes the grayscale change trend of the printed image in the diagonal direction, so as to reflect the posture angle of the printed matter when it was photographed, thereby providing a basis for subsequent classification of the printed image library.
[0139] It is understood that the method for calculating the second grayscale offset rate based on the upper right printing point, the lower left printing point, and the center printing point is the same as the method for calculating the first grayscale offset rate based on the upper left printing point, the lower right printing point, and the center printing point, and will not be repeated here.
[0140] In detail, the classification of multiple standard printed matter images and multiple defective printed matter images based on multiple first gray-level offset rates, multiple second gray-level offset rates, and multiple printing gray-level averages yields multiple feature image libraries, including:
[0141] The first grayscale offset range is determined based on multiple first grayscale offset rates, wherein the maximum value of the first grayscale offset range is the largest first grayscale offset rate among multiple first grayscale offset rates, and the minimum value of the first grayscale offset range is the smallest first grayscale offset rate among multiple first grayscale offset rates.
[0142] Based on the preset number of categories, the first grayscale offset range is sampled at equal intervals to obtain a first reference offset rates, where a is the number of categories;
[0143] Based on multiple second grayscale offset rates and the number of categories, a second reference offset rate is determined, and based on multiple printing grayscale averages and the number of categories, a reference grayscale average is determined.
[0144] Based on a first reference offset, a second reference offset, and a reference gray-scale mean, Q feature groups are identified, where Q = a 3 Each feature group consists of a first reference offset, a second reference offset, and a reference grayscale mean.
[0145] Q image storage devices were identified based on Q feature groups;
[0146] Extract the i-th standard printed image from multiple standard printed images, where the initial value of i is 1;
[0147] Perform the following operation on each of the Q feature groups:
[0148] The feature difference rate is calculated based on the feature group, the first gray-level shift rate of the i-th standard printed image among multiple first gray-level shift rates, the second gray-level shift rate of the i-th standard printed image among multiple second gray-level shift rates, and the average printed gray-level value of the i-th standard printed image among multiple average printed gray-level values. The calculation formula is as follows:
[0149]
[0150] in, For characteristic difference rate, This is the second grayscale offset rate. The average grayscale value of the printed image. , and These are the first reference offset rate, the second reference offset rate, and the average reference gray value in the feature group, respectively.
[0151] Compare the feature difference rate with the preset difference threshold. If the feature difference rate is less than or equal to the difference threshold, then store the i-th standard printed image in the image memory corresponding to the feature group in the Q image memory to obtain the updated memory.
[0152] Let I = i + 1, take I as i, and return to the step of extracting the i-th standard printed image from multiple standard printed images until I = 0, where 0 is the number of printed images in the multiple standard printed images;
[0153] The update memories corresponding to the feature groups are summarized to obtain Q update memories;
[0154] Q standard feature image sets are extracted from Q update memories, wherein each standard feature image set corresponds one-to-one with an update memory, and each standard feature image set includes multiple standard feature images.
[0155] Based on multiple defective printed images, obtain multiple first defect offset rates, multiple second defect offset rates, and multiple printing defect averages;
[0156] Based on multiple defective printed images, multiple first defect offset rates, multiple second defect offset rates, multiple printing defect averages, Q feature groups, Q image storage devices, and difference thresholds, a set of Q defect feature images is identified. The set of defect feature images includes: multiple defect feature images.
[0157] Perform the following operation on each of the Q feature groups:
[0158] The feature image library is obtained by summarizing the standard feature image sets corresponding to the feature group in the Q standard feature image sets and the defect feature image sets corresponding to the feature group in the Q defect feature image sets.
[0159] By compiling the feature image database, multiple feature image databases are obtained.
[0160] For example, if the preset number of categories is 4 and the first grayscale offset range is [1, 4], then the first grayscale offset range is sampled at equal intervals to obtain 4 first reference offset rates: 1, 2, 3, 4, and the specific number of categories is manually set by the technician of the printing factory.
[0161] It is understood that the method for determining a second reference offset rate based on multiple second grayscale offset rates and the number of categories, and the method for determining a reference grayscale average based on multiple printed grayscale averages and the number of categories, are the same as the method for obtaining a first reference offset rate by equidistant sampling of the first grayscale offset range based on a preset number of categories, and will not be described again here.
[0162] For example, if there are 4 first reference offsets, 4 second reference offsets, and 4 reference grayscale averages, then the 4 first reference offsets, 4 second reference offsets, and 4 reference grayscale averages are multiplied by a Cartesian product to traverse all possible combinations (a combination contains a first reference offset, a second reference offset, and a reference grayscale average). Each combination is a feature group, resulting in 64 feature groups.
[0163] It should be understood that the embodiments of the present invention classify previously collected printed images based on three features: the first reference offset rate, the second reference offset rate, and the reference grayscale mean. This allows printed images with similar pose features and imaging brightness characteristics to be grouped into the same feature image library. Thus, at the feature image library level, the imaging characteristics of printed materials under different shooting poses, different conveyor belt offset states, and different lighting conditions can be distinguished. Through the above method, during the subsequent training of the adversarial production network, it is possible to learn the appearance distribution characteristics of printed materials under different poses and lighting conditions based on different feature image libraries. This improves the adversarial production network's ability to specifically identify defects in printed materials under various pose changes, various lighting environments, and different conveyor belt offset states.
[0164] It should be explained that the identification of Q image memories based on Q feature groups means that each feature group in the Q feature groups is associated with a pre-acquired memory, and the associated memory is the image memory. The image memory is subsequently used to store standard printed images and defective printed images corresponding to the feature groups.
[0165] For example, a first standard printed image is extracted from multiple standard printed images. Then, the feature difference rate between the extracted first standard printed image and each of the Q feature groups is calculated sequentially. If the difference threshold is 0.2, when the feature difference rate is less than 0.2, the standard printed image is stored in the image memory of the feature group corresponding to that feature difference rate, thus obtaining an updated memory. It should be noted that if the feature difference rate of a standard printed image simultaneously matches multiple feature groups, it can be copied and stored separately in the image memories corresponding to the multiple feature groups. Then, the second standard printed image is extracted from the multiple standard printed images. The process of extracting images from multiple standard printed materials continues until all standard printed material images have been extracted. The updated memories containing these images are then aggregated to obtain Q updated memories, each storing multiple standard printed material images. Next, the following operation is performed on each of the Q updated memories: the multiple standard printed material images in the updated memory are extracted and aggregated into a set, resulting in a set of standard feature images. The multiple standard printed material images in the set of standard feature images are renamed as standard feature images. Finally, the set of standard feature images is aggregated again to obtain Q sets of standard feature images. The difference threshold is manually set by the technicians at the printing factory.
[0166] It is understood that the method for obtaining multiple first defect offset rates, multiple second defect offset rates, and multiple printing defect averages based on multiple defective printed images is the same as the method for obtaining multiple first reference offset rates, multiple second reference offset rates, and multiple reference grayscale averages using multiple standard printed images. Similarly, the method for identifying a set of Q defect feature images based on multiple defective printed images, multiple first defect offset rates, multiple second defect offset rates, multiple printing defect averages, Q feature groups, Q image storage units, and a difference threshold is the same as the method for obtaining a set of Q standard feature images using multiple standard printed images, multiple first reference offset rates, multiple second reference offset rates, multiple reference grayscale averages, Q feature groups, Q image storage units, and a difference threshold. These methods will not be elaborated upon here.
[0167] S3. Compress and window multiple feature image libraries to obtain multiple window matrix libraries, which include multiple standard window matrices and multiple defect window matrices.
[0168] Specifically, the compression and windowing of multiple feature image libraries to obtain multiple window matrix libraries includes:
[0169] Perform the following operation on each of the multiple feature image libraries:
[0170] Extract standard feature images sequentially from the standard feature image set in the feature image library, and perform the following operations on the extracted standard feature images:
[0171] The standard feature image is divided into multiple standard feature windows based on a pre-constructed image partitioning window. Each standard feature window includes multiple window pixels.
[0172] Perform the following operation on each of the multiple standard feature windows:
[0173] The window grayscale value is calculated based on multiple window pixels in the standard feature window, where the window grayscale value is the average of the printed grayscale values of multiple window pixels.
[0174] Summarize the grayscale values of the windows to obtain grayscale values for multiple windows;
[0175] The gray values of multiple windows are mapped to their positions on a standard feature image to obtain a standard window matrix;
[0176] By summing the standard window matrices corresponding to the standard feature images, multiple standard window matrices are obtained;
[0177] Multiple defect window matrices are obtained from the defect feature image set based on the feature image library;
[0178] By aggregating multiple standard window matrices and multiple defective window matrices, a window matrix library is obtained;
[0179] The window matrix libraries are aggregated to obtain multiple window matrix libraries.
[0180] It should be explained that the image segmentation window is a square region used for image block processing. Preferably, the spatial size of the image segmentation window is 8 pixels × 8 pixels. Dividing the standard feature image into multiple standard feature windows based on the pre-constructed image segmentation window means that, based on the image segmentation window, the standard feature image is divided row by row and column by column in the horizontal and vertical directions to divide the standard feature image into multiple regularly arranged sub-block regions. For example, when the spatial resolution of the standard feature image is 1024 pixels × 1024 pixels, and the size of the image segmentation window is 8 pixels × 8 pixels, then 128 sub-windows can be divided in the horizontal and vertical directions respectively, resulting in 128 × 128 sub-block regions. The sub-block regions are the standard feature windows, and the window pixels are the pixels in the standard feature windows.
[0181] Understandably, mapping the grayscale values of multiple windows onto the standard feature image means filling the corresponding grayscale values of each standard feature window into the corresponding row and column positions of the empty matrix based on the index positions of each standard feature window in the horizontal and vertical directions of the standard feature image. For example, if the standard feature image is divided into 128 standard feature windows along both the horizontal and vertical directions, an empty matrix of size 128×128 is constructed. The grayscale value of the standard feature window located in the first row and first column of the standard feature image is filled into the first row and first column position of the empty matrix; the grayscale value of the standard feature window located in the first row and second column is filled into the first row and second column position of the standard window matrix, and so on, until all window grayscale values are filled, resulting in a standard window matrix. Thus, the spatial position of each window grayscale value in the standard window matrix is consistent with the spatial position of the corresponding standard feature window in the standard feature image.
[0182] It should be understood that the method for obtaining multiple defect window matrices based on the defect feature image set of the feature image library is the same as the method for obtaining multiple standard window matrices using the standard feature image set of the feature image library, and will not be described again here.
[0183] S4. Perform the following operations on each window matrix library in the multiple window matrix libraries: train and group multiple standard window matrices and multiple defective window matrices in the window matrix library to obtain training matrix set, defective matrix set, positive verification matrix set, negative verification matrix set, positive adversarial matrix set and negative adversarial matrix set.
[0184] It should be explained that the training matrix set is a collection of standard window matrices used to train the discriminant model, the defect matrix set is a collection of defect window matrices used to train the discriminant model, the positive validation matrix set is a collection of standard window matrices used to validate the effectiveness of the defect identification model, the negative validation matrix set is a collection of defect window matrices used to validate the effectiveness of the defect identification model, the positive adversarial matrix set is a collection of standard window matrices used to train the generative adversarial network, and the negative adversarial matrix set is a collection of defect window matrices used to train the generative adversarial network.
[0185] For example, if there are 1000 standard window matrices and 1000 defective window matrices, according to a preset partitioning rule (e.g., 50% of the standard window matrices are used to train the discriminant model, 30% are used to verify the effectiveness of the defect identification model, and 20% are used to train the generative adversarial network; similarly, 50% of the defective window matrices are used to train the discriminant model, 30% are used to verify the effectiveness of the defect identification model, and 20% are used to train the generative adversarial network), then the 1000 standard window matrices are grouped for training to obtain 500 training matrix sets, 300 positive verification matrix sets, and 200 positive adversarial matrix sets; and the 1000 defective window matrices are grouped for training to obtain 500 defective matrix sets, 300 negative verification matrix sets, and 200 negative adversarial matrix sets. The specific partitioning rules are manually set by the technicians at the printing factory.
[0186] S5. Train the pre-built discriminant model using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain the defect identification model. Construct a generative adversarial network based on the pre-built VAE encoder and defect identification model. Perform adversarial training on the generative adversarial network based on the positive adversarial matrix set and negative adversarial matrix set to obtain a complete adversarial network. Summarize the complete adversarial networks to obtain multiple complete adversarial networks, where each complete adversarial network corresponds one-to-one with the window matrix library.
[0187] In detail, the step of training a pre-constructed discriminant model using a training matrix set, a defect matrix set, a positive verification matrix set, and a negative verification matrix set to obtain a defect identification model includes:
[0188] For each standard window matrix in the training matrix set, perform the following operation:
[0189] The preset integer value is combined with the standard window matrix to obtain the normal training group;
[0190] By aggregating the standard training sets, multiple standard training sets are obtained;
[0191] Multiple defect training groups are obtained based on a preset set of zero values and defect matrices;
[0192] The discriminant model is trained using multiple regular training groups and multiple defective training groups to obtain an updated discriminant model;
[0193] For each standard window matrix in the positive validation matrix set, perform the following operation:
[0194] The standard window matrix is input into the updated discriminant model to obtain the discriminant value;
[0195] Summarize the discriminant values to obtain multiple discriminant values, and calculate the mean of positive discriminant values based on the multiple discriminant values;
[0196] Obtain the negative discriminant mean based on the negative validation matrix set and the updated discriminant model;
[0197] The model evaluation value is calculated based on the positive and negative discriminant means, using the following formula:
[0198]
[0199] in, This is the model evaluation value. and These are the positive and negative discriminant means, respectively.
[0200] Compare the model evaluation value with the preset error detection threshold. If the model evaluation value is less than the error detection threshold, the updated discriminant model is used as the defect identification model. Otherwise, the updated discriminant model is used as the discriminant model. Return to the step of training the discriminant model using multiple regular training groups and multiple defect training groups until the model evaluation value is less than the error detection threshold.
[0201] It should be explained that the preset integer value is 1, and the preset zero value is 0. For example, the normal training group is [standard window matrix, 1].
[0202] It is understood that the method for obtaining multiple defect training groups based on a preset set of zero values and defect matrices is the same as the method for obtaining multiple regular training groups using a preset set of integer values and training matrices, and will not be described in detail here.
[0203] It should be understood that the discriminant model is a deep learning model including, but not limited to, multilayer perceptrons and convolutional neural networks. Training the discriminant model using multiple regular training sets and multiple defective training sets to obtain an updated discriminant model means: using the standard window matrix from the regular training set and the defective window matrix from the defective training set as input data for training the discriminant model, and using the integer values from the regular training set and the zero values from the defective training set as output data for training the discriminant model. During training, the standard window matrix from the regular training set corresponds to integer values, and the defective window matrix from the defective training set corresponds to zero values. The discriminant model is then iteratively trained using multiple regular training sets and multiple defective training sets. The discriminant model gradually adjusts its network parameters by optimizing the loss function (e.g., mean squared error, weighted error, etc.), enabling the discriminant model to learn the mapping relationship between input and output data (between the standard window matrix and integer values, and between the defective window matrix and zero values). The discriminant model after training is the updated discriminant model. Furthermore, the training process of the above discriminant model is all publicly available prior art, and will not be described in detail here.
[0204] It should be explained that, when the standard window matrix is input into the updated discriminant model to obtain the discriminant value, it means that the standard window matrix is used as input data into the updated discriminant model, and the value output by the updated discriminant model based on the input data is used as the discriminant value. The positive discriminant mean is the average of multiple discriminant values.
[0205] It is understood that the method for obtaining the negative discriminant mean based on the negative validation matrix set and the updated discriminant model is the same as the method for obtaining the positive discriminant mean using the positive validation matrix set and the updated discriminant model, and will not be described again here.
[0206] It should be understood that the model evaluation value reflects the training effect of the updated discriminant model; the higher the model evaluation value, the worse the training effect of the updated discriminant model. The error judgment threshold is manually set by the technicians of the printing factory; optionally, the error judgment threshold is 0.02.
[0207] In detail, the step of performing adversarial training on the generative adversarial network based on the positive adversarial matrix set and the negative adversarial matrix set to obtain a complete adversarial network includes:
[0208] Extract standard window matrices sequentially from the set of positive adversarial matrices, and perform the following operations on the extracted standard window matrices:
[0209] The generative adversarial network is trained using a standard window matrix to obtain an updated adversarial network;
[0210] The updated adversarial network is used as the generative adversarial network. The step of sequentially extracting standard window matrices from the set of positive adversarial matrices is repeated until all standard window matrices in the set of positive adversarial matrices have been extracted. The updated adversarial network is then used as the discriminative adversarial network.
[0211] The discriminative adversarial network is self-generated and trained based on the positive and negative adversarial matrix sets to obtain the complete adversarial network.
[0212] It should be explained that a Generative Adversarial Network (GAN) is a deep learning model consisting of a generative model and a discriminative model. In this embodiment of the invention, a VAE encoder serves as the generative model of the GAN, and a defect detection model serves as the discriminative model. The VAE encoder is a variational autoencoder. The variational autoencoder includes an encoder and a decoder, both of which are network structures composed of multi-layer neural networks. The encoder maps the standard window matrix in the positive adversarial matrix set to a latent distribution, and the decoder maps the latent variables extracted from the latent distribution back to matrix form, thereby reconstructing the original matrix. The latent distribution is a multidimensional normal distribution with independent dimensions, and the number of dimensions of the latent distribution is less than the number of dimensions of the matrix, thus achieving dimensionality reduction and feature compression of the matrix. The latent variables are multidimensional vectors randomly sampled from a latent distribution. Random sampling from the latent distribution means that for each dimension of the latent distribution, random sampling is performed according to the probability density function of the normal distribution corresponding to that dimension (the probability of random sampling follows the probability density function of the normal distribution; for example, the randomly sampled value is likely to be near the mean of the normal distribution). This results in a random value being sampled in each dimension. These random values are then combined to obtain a multidimensional vector, which is the latent variable. This process is repeated a predetermined number of times to obtain multiple latent variables. The decoder decodes based on these latent variables to reconstruct a matrix that is consistent with the original matrix in terms of numerical distribution and structural features. Specifically, the encoder maps the matrix to a latent distribution by performing convolution or fully connected operations on the input matrix. The encoding and decoding processes described above are existing technologies and will not be elaborated upon here.
[0213] Understandably, training the Generative Adversarial Network (GAN) using a standard window matrix to obtain an updated GAN refers to the following: The standard window matrix is input into the VAE encoder of the GAN. The encoder in the VAE encoder generates a latent distribution based on the standard window matrix. The decoder in the VAE encoder randomly samples multiple latent variables from the latent distribution and generates multiple reconstruction matrices based on these latent variables. Then, multiple standard window matrices are randomly selected from the set of positive adversarial matrices. All of these reconstruction matrices and standard window matrices are input into a defect identification model. The defect identification model determines which data in the matrices input to the defect identification model is fake data generated by the VAE encoder and which is real data from the multiple standard window matrices (an integer value output by the defect identification model represents real data, and a zero value represents fake data), and outputs the discrimination result. If the discrimination result is not equal to the true value, the model will not output the result. In practice, the defect identification model automatically corrects itself based on the actual results, gradually distinguishing between fake data generated by the VAE encoder and real data from multiple standard window matrices. Simultaneously, the VAE encoder also corrects itself based on the discrimination results output by the defect identification model, making the fake data generated by the VAE encoder increasingly closer to the real data from multiple standard window matrices. Ultimately, through the mutual adversarial interaction between the VAE encoder and the defect identification model, the generative ability of the VAE encoder and the discrimination ability of the defect identification model become increasingly stronger. Finally, when the VAE encoder and the defect identification model converge (i.e., after correcting the defect identification model and the VAE encoder using the actual results and discrimination results respectively, and the discrimination ability of the defect identification model and the generative ability of the VAE encoder hardly change), the adversarial training of the generative adversarial network is complete. The updated adversarial network is the generative adversarial network after adversarial training. The technique for adversarial training of the generative adversarial network is existing technology and will not be elaborated here. The distinguishing adversarial network refers to the updated adversarial network after all standard window matrices in the positive adversarial matrix set have participated in adversarial training.
[0214] It should be understood that once the Discriminant Adversarial Network (VAE) is trained, the VAE encoder in the VAE is sufficient to generate a reconstruction matrix that is almost identical to the standard window matrix corresponding to a real and defect-free printed image. Therefore, the VAE encoder can generate multiple reconstruction matrices based on the initial set of positive adversarial matrices. These multiple reconstruction matrices simulate various imaging changes that may occur in the actual production process, thereby expanding the standard window matrix corresponding to the standard printed image. This expands the training samples and further trains the defect identification model, thereby improving the defect identification model in the VAE to distinguish printed images with defects in various environments. Therefore, the self-generated training of the discriminative adversarial network based on the positive and negative adversarial matrix sets refers to: using the VAE encoder in the discriminative adversarial network to generate multiple reconstruction matrices based on multiple standard window matrices in the positive adversarial matrix set (the specific generation method is the same as the method of generating reconstruction matrices during the encoding and decoding process of the VAE encoder mentioned above); using multiple reconstruction matrices and integer values to generate multiple reconstruction training groups; using multiple defect window matrices and zero values in the negative adversarial matrix set to generate multiple reconstruction defect groups; and using multiple reconstruction training groups and multiple reconstruction defect groups to train the defect identification model in the discriminative adversarial network again. Finally, after the defect identification model in the discriminative adversarial network is trained, the discriminative adversarial network is completed. Furthermore, the methods for generating multiple reconstruction training groups using multiple reconstruction matrices and integer values, and for generating multiple reconstruction defect groups using multiple defect window matrices and zero values in the negative adversarial matrix set, are the same as the method for generating multiple regular training groups using multiple window matrices in the training matrix set. The method for retraining the defect identification model in the discriminative adversarial network using multiple reconstruction training groups and multiple reconstruction defect groups is the same as the method for training the discriminative model using multiple regular training groups and multiple defect training groups, and will not be repeated here.
[0215] S6. Receive printing inspection instructions, identify multiple images to be inspected based on the printing inspection instructions, and perform the following operations on each of the multiple images to be inspected: perform weight evaluation on the image to be inspected to obtain the feature matrix to be inspected and the weight coefficient group.
[0216] It should be explained that the printing inspection command is initiated by a technician in the printing factory. For example, Xiao Zhang is a technician in the printing factory. He needs to inspect a batch of newly produced printed materials and identify those with defects on the printing surface (dirt, missing print, color deviation, scratches, etc.) for reprinting. Therefore, Xiao Zhang initiates the printing inspection command, and then the industrial camera in the printing factory takes images of the surface of the batch of newly produced printed materials in sequence to obtain the multiple images to be inspected.
[0217] Specifically, the weight evaluation of the image to be detected to obtain the feature matrix to be detected and the weight coefficient set includes:
[0218] The first current offset rate, the second current offset rate, and the current grayscale mean are obtained based on the image to be detected.
[0219] Perform the following operation on each of the Q feature groups:
[0220] The current difference rate is calculated based on the feature group, the first current offset rate, the second current offset rate, and the current grayscale mean.
[0221] Summarize the current difference rates to obtain multiple current difference rates, and based on these multiple current difference rates, determine the first difference rate, the second difference rate, and the third difference rate.
[0222] The total difference is calculated based on the first difference rate, the second difference rate, and the third difference rate, where the total difference is the sum of the first difference rate, the second difference rate, and the third difference rate;
[0223] The first image weight is calculated based on the first difference rate and the sum of differences, using the following formula:
[0224]
[0225] in, The first image weight, and These are the first difference rate and the total difference, respectively;
[0226] The second image weight is calculated based on the second difference rate and the sum of differences, and the third image weight is calculated based on the third difference rate and the sum of differences.
[0227] Summarize the weights of the first image, the second image, and the third image to obtain a weight coefficient set;
[0228] Obtain the feature matrix to be detected based on the image to be detected.
[0229] It is understood that the method for obtaining the first current offset rate, the second current offset rate, and the current grayscale mean based on the image to be detected is the same as the method for obtaining the first grayscale offset rate, the second grayscale offset rate, and the printed grayscale mean using a standard printed image. The method for calculating the current difference rate based on the feature group, the first current offset rate, the second current offset rate, and the current grayscale mean is the same as the method for calculating the feature difference rate based on the feature group, the first grayscale offset rate, the second grayscale offset rate, and the printed grayscale mean. These will not be described again here.
[0230] It should be explained that the first difference rate, the second difference rate, and the third difference rate are the current difference rates that are sorted from smallest to largest, and are the first, second, and third smallest in the sorted order.
[0231] It is understood that the method for calculating the second image weight based on the second difference rate and the sum of differences, and the method for calculating the third image weight based on the third difference rate and the sum of differences, are the same as the method for calculating the first image weight based on the first difference rate and the sum of differences. The method for obtaining the feature matrix to be detected based on the image to be detected is the same as the method for obtaining the standard window matrix using a standard printed image, and will not be described again here.
[0232] S7. Based on the weight coefficient group and multiple completed adversarial networks, the feature matrix to be detected is identified to obtain the printing defect index. The printing defect indices are then summarized to obtain multiple printing defect indices.
[0233] In detail, the process of identifying the feature matrix to be detected based on a set of weighted coefficients and multiple complete adversarial networks to obtain a printing defect index includes:
[0234] Obtain a grayscale detection image based on the image to be detected;
[0235] Edge detection is performed on the grayscale detection image to obtain multiple edge pixels;
[0236] Multiple interlayer pixels and pixel areas were identified based on multiple edge pixels;
[0237] The average gray value of the edge is obtained based on multiple edge pixels, and the average gray value of the interlayer is obtained based on multiple interlayer pixels.
[0238] The first adversarial network is denoted as the first adversarial network, which corresponds to the first image weight in the weight coefficient group among multiple complete adversarial networks.
[0239] The first adversarial network is used to distinguish the feature matrix to be detected, and the first discrimination value is obtained.
[0240] A second discriminant value is determined based on the second image weights and multiple complete adversarial networks, and a third discriminant value is determined based on the third image weights and multiple complete adversarial networks.
[0241] The printing defect index is calculated based on pixel area, average edge grayscale, average interlayer grayscale, first image weight, second image weight, third image weight, first discrimination value, second discrimination value, and third discrimination value. The calculation formula is as follows:
[0242]
[0243] in, This is the printing defect index. , and These are the first image weights, the second image weights, and the third image weights, respectively. , and These are the first, second, and third discrimination values, respectively. and These are the average gray values at the edges and the average gray values of the interlayer, respectively. and These are the pixel area and the preset reference area, respectively. It is the hyperbolic tangent function. It is a natural constant. Refers to taking the absolute value.
[0244] It should be understood that the method for obtaining a grayscale detection image based on the image to be detected is the same as the method for converting a standard printed image to grayscale to obtain a grayscale printed image, and will not be described again here. The method of performing edge recognition on the grayscale detection image to obtain multiple edge pixels refers to using a pre-constructed edge recognition algorithm to perform edge recognition on the grayscale detection image. Optionally, the edge recognition algorithm is the Canny operator, and the technique of using a pre-constructed edge recognition algorithm to perform edge recognition on the grayscale detection image is existing technology, and will not be described again here. Edge pixels refer to a set of multiple pixels in the grayscale detection image that satisfy the Canny operator detection conditions and are located at positions where the grayscale gradient changes significantly. These multiple pixels are typically located at the boundary between the printed image and the printed background.
[0245] It should be explained that the determination of multiple interlayer pixels and pixel areas based on multiple edge pixels refers to: connecting the multiple edge pixels on the grayscale detection image to form a closed boundary, taking the internal region enclosed by the closed boundary as the target region, and taking the total number of pixels contained in the target region as the pixel area. Then, for each of the multiple edge pixels, the following operation is performed: based on the spatial distance relationship between pixels, searching for the internal pixel with the smallest spatial distance to the edge pixel in the target region, wherein the internal pixel is located inside the closed boundary and is not any of the multiple edge pixels. The searched internal pixel is taken as the interlayer pixel corresponding to the edge pixel. Finally, the interlayer pixels are summarized to obtain multiple interlayer pixels.
[0246] It is understood that the average edge grayscale value is the average of the grayscale values of multiple edge pixels, and the average interlayer grayscale value is the average of the grayscale values of multiple interlayer pixels. The step of using the first adversarial network to identify the feature matrix to be detected and obtaining the first identification value means: inputting the feature matrix to be detected into the defect identification model in the first adversarial network, and using the value output by the defect identification model based on the feature matrix to be detected as the first identification value. The method for determining the second identification value based on the second image weights and multiple complete adversarial networks, and the method for determining the third identification value based on the third image weights and multiple complete adversarial networks, are the same as the method for using the first adversarial network to identify the feature matrix to be detected and obtaining the first identification value, and will not be described again here.
[0247] It should be understood that, in this embodiment of the invention, by comparing the pixel area with a reference area and comparing the average grayscale value of the interlayer pixels with the average grayscale value of the edge pixels, a large difference between the pixel area and the reference area indicates that there is a printing omission or ink diffusion in the printed image. Conversely, a small difference between the average grayscale value of the interlayer pixels and the average grayscale value of the edge pixels indicates that the grayscale transition between the edge area and its inner area is not obvious, meaning that the edges of the printed image may exhibit ink smudging or blurring. Therefore, the printing defect index reflects the probability that the printed image on the surface of the printed material corresponding to the image to be detected has problems; the higher the printing defect index, the greater the probability that the printed image on the surface of the printed material corresponding to the image to be detected has problems.
[0248] S8. Based on multiple printing defect indices and multiple images to be inspected, multiple printing defect images are identified, and online inspection of printed materials is completed.
[0249] Specifically, the identification of multiple printing defect images based on multiple printing defect indices and multiple images to be inspected includes:
[0250] Perform the following operation on all printing defect indices among the multiple printing defect indices:
[0251] Compare the printing defect index with a preset defect threshold. If the printing defect index is greater than or equal to the defect threshold, then the image to be detected corresponding to the printing defect index among multiple images to be detected is recorded as a printing defect image.
[0252] The images of printing defects are compiled to obtain multiple images of printing defects.
[0253] It should be explained that the defect threshold is set by the technicians of the printing factory based on historical data. Optionally, the average value of the printing defect index corresponding to the images to be tested that have been manually verified to have defects on the surface of the printed matter in the past can be used as the defect threshold.
[0254] For example, after obtaining multiple images of printing defects, the staff of the printing factory can quickly locate the corresponding problematic printed products based on the multiple images, thereby quickly further inspecting or reprinting the problematic printed products and improving the efficiency of printing inspection.
[0255] To address the problems described in the background section, this invention provides a printed matter image library. This library includes multiple standard printed matter images and multiple defective printed matter images. By acquiring this image library, the training samples cover the appearance variations of printed matter under different production batches, printing environments, and imaging conditions. This improves the adaptability of subsequent models to various imaging environments and provides diverse basic data support for subsequent feature classification and model training. Furthermore, feature classification is performed on the printed matter image library to obtain multiple feature image libraries, including a standard feature image set and a defective feature image set. This embodiment constructs multiple feature image libraries containing standard feature image sets and defect feature image sets, enabling group management of printed images under different feature distribution conditions. This allows subsequent models to model separately for different imaging characteristics, improving the model's ability to distinguish printing defect features under different poses, lighting conditions, and printing states. Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, including multiple standard window matrices and multiple defect window matrices. Thus, this embodiment effectively reduces the dimensionality of input data by converting the original high-resolution image into multiple window matrices, while preserving the grayscale statistical features of local regions. This allows the model to learn based on local structural features, thereby reducing computational complexity. While reducing computational complexity, this invention improves sensitivity to local defect features. For each window matrix library, the following operations are performed: multiple standard window matrices and multiple defect window matrices in the window matrix library are grouped for training, resulting in a training matrix set, a defect matrix set, a positive verification matrix set, a negative verification matrix set, a positive adversarial matrix set, and a negative adversarial matrix set. The pre-built discriminant model is then trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain a defect identification model. Therefore, this embodiment of the invention trains the pre-built discriminant model using the training matrix set, defect matrix set, and verification matrix set, enabling the defect identification model to learn the differences between the standard window matrix and the defect window matrix. Online detection provides a stable and reliable preliminary detection model. A generative adversarial network (GAN) is constructed based on a pre-built VAE encoder and defect identification model. The GAN is then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network (CAN). These CANs are then aggregated to obtain multiple CANs. Each CAN corresponds one-to-one with a window matrix library. Thus, this embodiment of the invention constructs a GAN using a VAE encoder and a defect identification model, and trains it adversarially using a positive adversarial matrix set. This enables the VAE encoder to generate diverse reconstruction matrices using the potential distribution of standard window matrices, simulating various imaging variations that may occur in actual production processes, thereby expanding the feature distribution of standard samples.This invention significantly improves the accuracy and robustness of the defect identification model in detecting printing defects under complex working conditions. It receives printing inspection instructions, identifies multiple images to be inspected based on these instructions, and performs the following operations on each image: weight evaluation of the image to be inspected to obtain a feature matrix and a set of weight coefficients; identification of the feature matrix based on the weight coefficients and multiple complete adversarial networks to obtain a printing defect index. As can be seen, this embodiment analyzes the image to be inspected, matches it with image features in multiple previously constructed feature groups, uses the complete adversarial network corresponding to the feature group most similar to the image to be inspected to detect defects, and weights and fuses the outputs of each complete adversarial network according to weight coefficients determined by similarity, ultimately obtaining a printing defect index that comprehensively reflects the degree of defect in the image to be inspected. This avoids misjudgment caused by a single model under conditions of mismatched image features, effectively improving the accuracy and robustness of printing defect detection under various environmental conditions. By summarizing printing defect indices, multiple printing defect indices are obtained. Based on these indices and multiple images to be inspected, multiple printing defect images are identified, completing the online inspection of printed materials. It is evident that this embodiment of the invention, by automatically identifying multiple printing defect images, enables workers to quickly locate printed materials with quality problems, achieving rapid screening and processing of abnormal printed materials, thereby significantly improving the efficiency of online printing inspection and increasing the automation level of printing inspection. Therefore, this invention can improve the accuracy and robustness of printing defect detection and enhance the efficiency of printing inspection.
[0256] like Figure 2 The diagram shown is a functional block diagram of an online inspection system for printed materials based on machine vision, provided in an embodiment of the present invention.
[0257] The machine vision-based online inspection system 100 for printed materials described in this invention can be installed in an electronic device. Depending on the functions implemented, the machine vision-based online inspection system 100 for printed materials may include a printed image classification module 101, an image matrix training module 102, an adversarial network construction module 103, and a printed image detection module 104. The module described in this invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.
[0258] The printed image classification module 101 is used to obtain a printed image library, wherein the printed image library includes: multiple standard printed images and multiple defective printed images. The printed image library is used to perform feature classification to obtain multiple feature image libraries, wherein the feature image libraries include: a set of standard feature images and a set of defective feature images.
[0259] The image matrix training module 102 is used to compress and window multiple feature image libraries to obtain multiple window matrix libraries. The window matrix libraries include multiple standard window matrices and multiple defect window matrices. For each window matrix library, the following operations are performed: the multiple standard window matrices and multiple defect window matrices in the window matrix library are trained and grouped to obtain a training matrix set, a defect matrix set, a positive verification matrix set, a negative verification matrix set, a positive adversarial matrix set, and a negative adversarial matrix set. The pre-constructed discrimination model is trained using the training matrix set, the defect matrix set, the positive verification matrix set, and the negative verification matrix set to obtain a defect identification model.
[0260] The adversarial network construction module 103 is used to construct a generative adversarial network based on a pre-built VAE encoder and defect identification model, perform adversarial training on the generative adversarial network based on a positive adversarial matrix set and a negative adversarial matrix set to obtain a complete adversarial network, and summarize the complete adversarial networks to obtain multiple complete adversarial networks, wherein each complete adversarial network corresponds one-to-one with a window matrix library.
[0261] The printed image detection module 104 is used to receive printing detection instructions, identify multiple images to be detected based on the printing detection instructions, and perform the following operations on each of the multiple images to be detected: perform weight evaluation on the image to be detected to obtain a feature matrix to be detected and a set of weight coefficients; identify the feature matrix to be detected based on the set of weight coefficients and multiple complete adversarial networks to obtain a printing defect index; summarize the printing defect indices to obtain multiple printing defect indices; identify multiple printing defect images based on the multiple printing defect indices and the multiple images to be detected, and complete the online detection of printed matter.
[0262] In detail, the modules in the machine vision-based online inspection system 100 for printed materials described in this embodiment of the invention employ the same methods as described above. Figure 1 The method uses the same technical means as the online inspection method for printed materials based on machine vision described in the previous article and can produce the same technical effect, so it will not be repeated here.
[0263] like Figure 3 The diagram shown is a schematic representation of an electronic device for implementing a machine vision-based online inspection method for printed materials, according to an embodiment of the present invention.
[0264] The electronic device 1 may include a processor 10, a memory 11 and a bus 12, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a machine vision-based online inspection method for printed matter.
[0265] The memory 11 includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as the portable hard drive of the electronic device 1. In other embodiments, the memory 11 can be an external storage device of the electronic device 1, such as a plug-in portable hard drive, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 1. Furthermore, the memory 11 includes both internal storage units and external storage devices of the electronic device 1. The memory 11 can be used not only to store application software and various types of data installed on the electronic device 1, such as the code of a machine vision-based online inspection method for printed materials, but also to temporarily store data that has been output or will be output.
[0266] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., a machine vision-based online inspection method for printed materials) and calls data stored in the memory 11 to perform various functions of the electronic device 1 and process data.
[0267] The bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 12 can be divided into an address bus, a data bus, a control bus, etc. The bus 12 is configured to realize the connection and communication between the memory 11 and at least one processor 10, etc.
[0268] Figure 3 Only electronic devices with components are shown; it will be understood by those skilled in the art that... Figure 3The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0269] For example, although not shown, the electronic device 1 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0270] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, a Bluetooth interface, etc.), which is typically used to establish communication connections between the electronic device 1 and other electronic devices.
[0271] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), and optionally, a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device 1 and to display a visual user interface.
[0272] The machine vision-based online inspection method program for printed materials stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When run in the processor 10, it can achieve the following:
[0273] Obtain a printed matter image library, which includes: multiple standard printed matter images and multiple defective printed matter images;
[0274] The printed image library is classified by features to obtain multiple feature image libraries, which include: a standard feature image set and a defect feature image set;
[0275] Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, which include: multiple standard window matrices and multiple defect window matrices;
[0276] Perform the following operation on each of the multiple window matrix libraries:
[0277] Multiple standard window matrices and multiple defective window matrices in the window matrix library are trained and grouped to obtain training matrix set, defective matrix set, positive verification matrix set, negative verification matrix set, positive adversarial matrix set, and negative adversarial matrix set;
[0278] The pre-constructed discrimination model is trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain the defect identification model;
[0279] Generative Adversarial Networks (GANs) are constructed based on pre-built VAE encoders and defect identification models. The GANs are then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network.
[0280] The completed adversarial networks are summarized, resulting in multiple completed adversarial networks, each corresponding one-to-one with a window matrix library;
[0281] Receive a printing inspection command, identify multiple images to be inspected based on the printing inspection command, and perform the following operations on each of the multiple images to be inspected:
[0282] The image to be detected is weighted and evaluated to obtain the feature matrix to be detected and the weight coefficient set;
[0283] Based on the weight coefficient group and multiple complete adversarial networks, the printing defect index is obtained by identifying the feature matrix to be detected.
[0284] By summing up the printing defect indices, multiple printing defect indices are obtained.
[0285] Based on multiple printing defect indices and multiple images to be inspected, multiple printing defect images are identified, and online inspection of printed materials is completed.
[0286] Specifically, the processor 10's implementation method for the above instructions can be found in [reference needed]. Figures 1 to 3 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0287] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0288] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor of an electronic device, can perform the following:
[0289] Obtain a printed matter image library, which includes: multiple standard printed matter images and multiple defective printed matter images;
[0290] The printed image library is classified by features to obtain multiple feature image libraries, which include: a standard feature image set and a defect feature image set;
[0291] Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, which include: multiple standard window matrices and multiple defect window matrices;
[0292] Perform the following operation on each of the multiple window matrix libraries:
[0293] Multiple standard window matrices and multiple defective window matrices in the window matrix library are trained and grouped to obtain training matrix set, defective matrix set, positive verification matrix set, negative verification matrix set, positive adversarial matrix set, and negative adversarial matrix set;
[0294] The pre-constructed discrimination model is trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain the defect identification model;
[0295] Generative Adversarial Networks (GANs) are constructed based on pre-built VAE encoders and defect identification models. The GANs are then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network.
[0296] The completed adversarial networks are summarized, resulting in multiple completed adversarial networks, each corresponding one-to-one with a window matrix library;
[0297] Receive a printing inspection command, identify multiple images to be inspected based on the printing inspection command, and perform the following operations on each of the multiple images to be inspected:
[0298] The image to be detected is weighted and evaluated to obtain the feature matrix to be detected and the weight coefficient set;
[0299] Based on the weight coefficient group and multiple complete adversarial networks, the printing defect index is obtained by identifying the feature matrix to be detected.
[0300] By summing up the printing defect indices, multiple printing defect indices are obtained.
[0301] Based on multiple printing defect indices and multiple images to be inspected, multiple printing defect images are identified, and online inspection of printed materials is completed.
[0302] In the embodiments provided by this invention, it should be understood that the disclosed devices, systems, and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and actual implementations may have other classification methods.
[0303] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0304] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0305] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0306] 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 it. 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 spirit and scope of the technical solutions of the present invention.
Claims
1. A machine vision-based online inspection method for printed materials, characterized in that, The method includes: Obtain a printed matter image library, which includes: multiple standard printed matter images and multiple defective printed matter images; The printed image library is classified by features to obtain multiple feature image libraries, which include: a standard feature image set and a defect feature image set; Multiple feature image libraries are compressed and windowed to obtain multiple window matrix libraries, which include: multiple standard window matrices and multiple defect window matrices; Perform the following operation on each of the multiple window matrix libraries: Multiple standard window matrices and multiple defective window matrices in the window matrix library are trained and grouped to obtain training matrix set, defective matrix set, positive verification matrix set, negative verification matrix set, positive adversarial matrix set, and negative adversarial matrix set; The pre-constructed discrimination model is trained using the training matrix set, defect matrix set, positive verification matrix set, and negative verification matrix set to obtain the defect identification model; Generative Adversarial Networks (GANs) are constructed based on pre-built VAE encoders and defect identification models. The GANs are then trained adversarially using positive and negative adversarial matrix sets to obtain a complete adversarial network. The completed adversarial networks are summarized, resulting in multiple completed adversarial networks, each corresponding one-to-one with a window matrix library; Receive a printing inspection command, identify multiple images to be inspected based on the printing inspection command, and perform the following operations on each of the multiple images to be inspected: The image to be detected is weighted and evaluated to obtain the feature matrix to be detected and the weight coefficient set; Based on the weight coefficient group and multiple complete adversarial networks, the printing defect index is obtained by identifying the feature matrix to be detected. By summing up the printing defect indices, multiple printing defect indices are obtained. Based on multiple printing defect indices and multiple images to be inspected, multiple printing defect images are identified, and online inspection of printed materials is completed.
2. The online inspection method for printed materials based on machine vision as described in claim 1, characterized in that, The process of performing feature classification on the printed image library yields multiple feature image libraries, including: Perform the following operation on each of the multiple standard printed images in the printed image library: A standard printed image is converted to grayscale to obtain a grayscale printed image, wherein the grayscale printed image includes: multiple grayscale pixels, and each grayscale pixel includes: a printed grayscale value; Identify the top left, top right, bottom left, bottom right, and center printing points of the grayscale printed image; The first grayscale offset rate is calculated based on the top left printing point, bottom right printing point, and center printing point, using the following formula: in, The first grayscale offset rate, , and These are the printing gray values of the upper left printing point, the lower right printing point, and the center printing point, respectively. The second grayscale offset rate is calculated based on the upper right printing point, the lower left printing point, and the center printing point. The average grayscale value is determined based on multiple grayscale pixels in a grayscale printed image. The average grayscale value is the average of the grayscale values of multiple grayscale pixels. The first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value are summarized separately to obtain multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple average printed grayscale values. Among them, the first grayscale offset rate, the second grayscale offset rate, and the average printed grayscale value all correspond one-to-one with the standard printed image. Multiple standard printed images and multiple defective printed images are classified based on multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple printing grayscale averages to obtain multiple feature image libraries.
3. The online inspection method for printed materials based on machine vision as described in claim 2, characterized in that, The method classifies multiple standard printed matter images and multiple defective printed matter images based on multiple first grayscale offset rates, multiple second grayscale offset rates, and multiple printing grayscale averages to obtain multiple feature image libraries, including: The first grayscale offset range is determined based on multiple first grayscale offset rates, wherein the maximum value of the first grayscale offset range is the largest first grayscale offset rate among multiple first grayscale offset rates, and the minimum value of the first grayscale offset range is the smallest first grayscale offset rate among multiple first grayscale offset rates. Based on the preset number of categories, the first grayscale offset range is sampled at equal intervals to obtain a first reference offset rates, where a is the number of categories; Based on multiple second grayscale offset rates and the number of categories, a second reference offset rate is determined, and based on multiple printing grayscale averages and the number of categories, a reference grayscale average is determined. Based on a first reference offset, a second reference offset, and a reference gray-scale mean, Q feature groups are identified, where Q = a 3 Each feature group consists of a first reference offset, a second reference offset, and a reference grayscale mean. Q image storage devices were identified based on Q feature groups; Extract the i-th standard printed image from multiple standard printed images, where the initial value of i is 1; Perform the following operation on each of the Q feature groups: The feature difference rate is calculated based on the feature group, the first gray-scale offset rate corresponding to the i-th standard printed image in multiple first gray-scale offset rates, the second gray-scale offset rate corresponding to the i-th standard printed image in multiple second gray-scale offset rates, and the printing gray-scale mean corresponding to the i-th standard printed image in multiple printing gray-scale mean values. Compare the feature difference rate with the preset difference threshold. If the feature difference rate is less than or equal to the difference threshold, then store the i-th standard printed image in the image memory corresponding to the feature group in the Q image memory to obtain the updated memory. Let I = i + 1, take I as i, and return to the step of extracting the i-th standard printed image from multiple standard printed images until I = 0, where 0 is the number of printed images in the multiple standard printed images; The update memories corresponding to the feature groups are summarized to obtain Q update memories; Q standard feature image sets are extracted from Q update memories, wherein each standard feature image set corresponds one-to-one with an update memory, and each standard feature image set includes multiple standard feature images. Based on multiple defective printed images, obtain multiple first defect offset rates, multiple second defect offset rates, and multiple printing defect averages; Based on multiple defective printed images, multiple first defect offset rates, multiple second defect offset rates, multiple printing defect averages, Q feature groups, Q image storage devices, and difference thresholds, a set of Q defect feature images is identified. The set of defect feature images includes: multiple defect feature images. Perform the following operation on each of the Q feature groups: The feature image library is obtained by summarizing the standard feature image sets corresponding to the feature group in the Q standard feature image sets and the defect feature image sets corresponding to the feature group in the Q defect feature image sets. By compiling the feature image database, multiple feature image databases are obtained.
4. The online inspection method for printed materials based on machine vision as described in claim 3, characterized in that, The compression and windowing of multiple feature image libraries yields multiple window matrix libraries, including: Perform the following operation on each of the multiple feature image libraries: Extract standard feature images sequentially from the standard feature image set in the feature image library, and perform the following operations on the extracted standard feature images: The standard feature image is divided into multiple standard feature windows based on a pre-constructed image partitioning window. Each standard feature window includes multiple window pixels. Perform the following operation on each of the multiple standard feature windows: The window grayscale value is calculated based on multiple window pixels in the standard feature window, where the window grayscale value is the average of the printed grayscale values of multiple window pixels. Summarize the grayscale values of the windows to obtain grayscale values for multiple windows; The gray values of multiple windows are mapped to their positions on a standard feature image to obtain a standard window matrix; By summing the standard window matrices corresponding to the standard feature images, multiple standard window matrices are obtained; Multiple defect window matrices are obtained from the defect feature image set based on the feature image library; By aggregating multiple standard window matrices and multiple defective window matrices, a window matrix library is obtained; The window matrix libraries are aggregated to obtain multiple window matrix libraries.
5. The online inspection method for printed materials based on machine vision as described in claim 4, characterized in that, The method involves training a pre-constructed discrimination model using a training matrix set, a defect matrix set, a positive verification matrix set, and a negative verification matrix set to obtain a defect identification model, including: For each standard window matrix in the training matrix set, perform the following operation: The preset integer value is combined with the standard window matrix to obtain the normal training group; By aggregating the standard training sets, multiple standard training sets are obtained; Multiple defect training groups are obtained based on a preset set of zero values and defect matrices; The discriminant model is trained using multiple regular training groups and multiple defective training groups to obtain an updated discriminant model; For each standard window matrix in the positive validation matrix set, perform the following operation: The standard window matrix is input into the updated discriminant model to obtain the discriminant value; Summarize the discriminant values to obtain multiple discriminant values, and calculate the mean of positive discriminant values based on the multiple discriminant values; Obtain the negative discriminant mean based on the negative validation matrix set and the updated discriminant model; The model evaluation value is calculated based on the positive and negative discriminant means; Compare the model evaluation value with the preset error detection threshold. If the model evaluation value is less than the error detection threshold, the updated discriminant model is used as the defect identification model. Otherwise, the updated discriminant model is used as the discriminant model. Return to the step of training the discriminant model using multiple regular training groups and multiple defect training groups until the model evaluation value is less than the error detection threshold.
6. The online inspection method for printed materials based on machine vision as described in claim 5, characterized in that, The adversarial training of the generative adversarial network based on the positive and negative adversarial matrix sets yields a complete adversarial network, including: Extract standard window matrices sequentially from the set of positive adversarial matrices, and perform the following operations on the extracted standard window matrices: The generative adversarial network is trained using a standard window matrix to obtain an updated adversarial network; The updated adversarial network is used as the generative adversarial network. The step of sequentially extracting standard window matrices from the set of positive adversarial matrices is repeated until all standard window matrices in the set of positive adversarial matrices have been extracted. The updated adversarial network is then used as the discriminative adversarial network. The discriminative adversarial network is self-generated and trained based on the positive and negative adversarial matrix sets to obtain the complete adversarial network.
7. The online inspection method for printed materials based on machine vision as described in claim 6, characterized in that, The step of weight evaluation of the image to be detected, resulting in the feature matrix to be detected and the weight coefficient set, includes: The first current offset rate, the second current offset rate, and the current grayscale mean are obtained based on the image to be detected. Perform the following operation on each of the Q feature groups: The current difference rate is calculated based on the feature group, the first current offset rate, the second current offset rate, and the current grayscale mean. Summarize the current difference rates to obtain multiple current difference rates, and based on these multiple current difference rates, determine the first difference rate, the second difference rate, and the third difference rate. The total difference is calculated based on the first difference rate, the second difference rate, and the third difference rate, where the total difference is the sum of the first difference rate, the second difference rate, and the third difference rate; The first image weight is calculated based on the first difference rate and the sum of differences. The second image weight is calculated based on the second difference rate and the sum of differences, and the third image weight is calculated based on the third difference rate and the sum of differences. Summarize the weights of the first image, the second image, and the third image to obtain a weight coefficient set; Obtain the feature matrix to be detected based on the image to be detected.
8. The online inspection method for printed materials based on machine vision as described in claim 7, characterized in that, The process of identifying the feature matrix to be detected based on a weighted coefficient group and multiple completed adversarial networks yields a printing defect index, including: Obtain a grayscale detection image based on the image to be detected; Edge detection is performed on the grayscale detection image to obtain multiple edge pixels; Multiple interlayer pixels and pixel areas were identified based on multiple edge pixels; The average gray value of the edge is obtained based on multiple edge pixels, and the average gray value of the interlayer is obtained based on multiple interlayer pixels. The first adversarial network is denoted as the first adversarial network, which corresponds to the first image weight in the weight coefficient group among multiple complete adversarial networks. The first adversarial network is used to distinguish the feature matrix to be detected, and the first discrimination value is obtained. A second discriminant value is determined based on the second image weights and multiple complete adversarial networks, and a third discriminant value is determined based on the third image weights and multiple complete adversarial networks. The printing defect index is calculated based on pixel area, average edge grayscale, average interlayer grayscale, first image weight, second image weight, third image weight, first discrimination value, second discrimination value, and third discrimination value. The calculation formula is as follows: in, This is the printing defect index. , and These are the first image weights, the second image weights, and the third image weights, respectively. , and These are the first, second, and third discrimination values, respectively. and These are the average gray values at the edges and the average gray values of the interlayer, respectively. and These are the pixel area and the preset reference area, respectively. It is the hyperbolic tangent function. It is a natural constant. Refers to taking the absolute value.
9. The online inspection method for printed materials based on machine vision as described in claim 8, characterized in that, The process of identifying multiple printing defect images based on multiple printing defect indices and multiple images to be inspected includes: Perform the following operation on all printing defect indices among the multiple printing defect indices: Compare the printing defect index with a preset defect threshold. If the printing defect index is greater than or equal to the defect threshold, then the image to be detected corresponding to the printing defect index among multiple images to be detected is recorded as a printing defect image. The images of printing defects are compiled to obtain multiple images of printing defects.
10. A machine vision-based online inspection system for printed materials, characterized in that, The system includes: The printing image classification module is used to obtain a printing image library, which includes multiple standard printing images and multiple defective printing images. The printing image library is classified by features to obtain multiple feature image libraries, which include a standard feature image set and a defective feature image set. The image matrix training module is used to compress and window multiple feature image libraries to obtain multiple window matrix libraries. The window matrix library includes multiple standard window matrices and multiple defect window matrices. For each window matrix library, the following operations are performed: the multiple standard window matrices and multiple defect window matrices in the window matrix library are grouped for training to obtain a training matrix set, a defect matrix set, a positive verification matrix set, a negative verification matrix set, a positive adversarial matrix set, and a negative adversarial matrix set. The pre-constructed discriminant model is trained using the training matrix set, the defect matrix set, the positive verification matrix set, and the negative verification matrix set to obtain a defect identification model. The adversarial network construction module is used to build a generative adversarial network based on a pre-built VAE encoder and defect identification model. The generative adversarial network is trained adversarially based on a positive adversarial matrix set and a negative adversarial matrix set to obtain a complete adversarial network. The complete adversarial networks are summarized to obtain multiple complete adversarial networks. Each complete adversarial network corresponds one-to-one with the window matrix library. The printed image detection module receives printing detection instructions, identifies multiple images to be detected based on these instructions, and performs the following operations on each of the multiple images to be detected: performs weight evaluation on the image to be detected to obtain a feature matrix to be detected and a set of weight coefficients; identifies the feature matrix to be detected based on the set of weight coefficients and multiple complete adversarial networks to obtain a printing defect index; summarizes the printing defect indices to obtain multiple printing defect indices; and identifies multiple printing defect images based on the multiple printing defect indices and the multiple images to be detected, thus completing the online detection of printed materials.