Character print defect detection method, system, medium, and program product

CN122473798BActive Publication Date: 2026-09-18HANGZHOU HUICUI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610943950.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-06-29
Publication Date
2026-09-18
Estimated Expiration
2046-06-29

AI Technical Summary

Technical Problem

刚性模板匹配无法区分这种“正常波动”和“真实缺陷”,易导致过检(将良品判为不良)

Benefits of technology

检测鲁棒性大幅提升:通过融合多张良品图像构建的自适应概率模板,本质上是学习了字符在正常生产波动下的统计分布。这使得系统能够容忍良品固有的微小变化,显著降低了因单一模板不完美或工艺正常波动导致的过检率(False Reject Rate)。模板中的标准差信息σj,n为差异判定提供了自适应的、本地化的容差范围。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122473798B_ABST
    Figure CN122473798B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of computer vision, and discloses a character printing defect detection method, system, medium and program product. The method comprises the following steps: based on multiple good character printing images, an adaptive character template is constructed for each character unit, and a corresponding verification parameter set is set for each character unit; a pre-processed and image-registered to-be-detected character printing image is collected, pixel-level difference detection is performed on the to-be-detected character unit in the to-be-detected character printing image according to the adaptive character template, and a difference image containing suspected character missing and suspected character multi-ink information is generated; region cascade analysis processing is performed on the difference image, real defect regions are filtered and confirmed level by level, the confirmed real defect regions are quantified, and the quality of the character unit and the to-be-detected character printing image is judged according to the verification parameter set. The present application can realize high-robustness, high-precision and intelligent automatic detection of character printing quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, specifically to methods, systems, media, and program products for detecting character printing defects. Background Technology

[0002] In modern industrial production, the printing quality of characters on product packaging, labels, printed circuit boards (PCBs), various nameplates, and electronic components is a crucial aspect of product quality control. As the primary carrier of information, the integrity, clarity, and accuracy of printed characters directly impact product traceability, user experience, and brand image. Traditional character printing quality inspection relies mainly on manual visual inspection. This method suffers from inherent drawbacks such as low efficiency, high labor intensity, susceptibility to subjective factors, inconsistent standards, and inability to achieve continuous operation, making it difficult to meet the demands of modern industrial production characterized by high speed, high precision, and large-scale manufacturing.

[0003] With the rapid development of machine vision technology, automated optical inspection (AOI) systems based on computer vision have become the mainstream solution in the industrial quality inspection field. In the specific scenario of character printing inspection, the core tasks typically include: character region localization and segmentation, character feature extraction, and defect identification and classification. Among these, defect types are diverse, commonly including: missing characters (such as incomplete strokes), excess ink (such as ink overflow or splatter), blurriness (such as unclear printing), dirt (such as foreign matter contamination), positional misalignment, and font errors. How to stably, accurately, and efficiently detect various defects under these complex conditions is a key challenge in technological implementation.

[0004] Numerous researchers and engineers have proposed various character detection schemes based on machine vision. The most similar implementation to the invention in this application can be summarized as a "rigid comparison method based on a standard template." The core idea of ​​this method is to establish a "perfect" reference template (golden template), and then compare the image to be detected pixel-by-pixel or feature-by-feature with the reference template, determining whether defects exist based on the difference value.

[0005] The specific process of a typical existing technical solution A is as follows: Template creation stage: During system initialization, the operator selects a manually verified "good product" image as the standard template image. Through manual or simple threshold segmentation and edge detection methods, in Select each character region that needs to be detected using the box above. ,in , This represents the total number of characters. For each character region... Further binarization processing can be performed to obtain a binary template. .

[0006] Image acquisition and alignment stage: During online inspection, industrial cameras acquire images of the products to be inspected. Since the product position may undergo slight changes (translation, rotation), the system will first use image registration techniques (such as SIFT / SURF based on feature points, or methods based on gray-level cross-correlation) to register the product. and Perform global alignment to obtain the aligned image to be inspected. .

[0007] Region extraction and comparison stage: This stage extracts and compares the character regions defined in the template stage. Direct mapping to the aligned image Extract the corresponding character region to be inspected. Then, With the corresponding template area or its binary image Compare them.

[0008] Defect identification stage: Comparison typically uses pixel-level difference calculation. For example, after binarizing both, an XOR operation is performed: in, This is the area to be inspected. The binarization result, This represents a pixel-by-pixel XOR operation. In a difference image, white pixels (with a value of 1) are the difference points. Statistics. Total area of ​​white pixels Combine it with the total area of ​​the region The ratio is defined as the difference rate. : A fixed threshold is preset. ,if If the character is found to be defective, it is considered defective; otherwise, it is considered acceptable.

[0009] Another similar improvement, B, introduces the concept of feature similarity during alignment. Instead of directly comparing pixels, it extracts the Histogram of Oriented Gradients (HOG), Local Binary Pattern (LBP), or deep learning feature vectors for each character region. and Then calculate the cosine distance or Euclidean distance between the eigenvectors. : Similarly, a threshold is set to determine whether a match exists. This method is somewhat robust to changes in lighting and non-rigid deformation, but the core remains "one-to-one" rigid template matching.

[0010] Although the above prior technical solutions have made progress in automatic detection, the following key shortcomings are still exposed in actual industrial deployment: Excessive dependence on template unicity and "absolute good products": Solutions A and B heavily rely on a single standard template image. Once the template image itself has undetectable tiny defects, or the character position and shape are not optimal during template making (e.g., at the tolerance boundary), systematic misjudgment will occur in all subsequent detections. In addition, in actual production, even for all good products, due to the inherent fluctuations of the printing process (such as tiny changes in ink volume and differences in surface texture of the substrate), the character shape will also have normal variations within a reasonable tolerance range. Rigid template matching cannot distinguish between such "normal fluctuations" and "real defects", which easily leads to over-inspection (judging good products as defective).

[0011] Rigidity and insufficient adaptability of global threshold setting: Both the pixel difference rate and the feature distance , the final determination relies on a globally fixed threshold . However, different characters have different complexity (such as "一" and "警"), with different stroke thicknesses and areas, so their acceptable difference ranges should inherently be different. The same character at different printing positions (such as the edge and the center) is also affected by the process to different degrees. A fixed threshold cannot achieve refined and adaptive determination, and it is difficult to balance both sensitivity and specificity.

[0012] Lack of in-depth analysis on the physical characteristics of defect areas: Simple statistics on the total number of different pixels or calculation of overall feature distance loses spatial distribution information. A small, isolated difference point (which may be noise) and a connected, large-area difference region (which is likely to be a defect) may have the same value in existing solutions, thereby causing misjudgment. Existing solutions cannot effectively distinguish "pseudo-differences" caused by imaging noise and slight position offset from "real defects" caused by actual missing printing or excess ink.

[0013] Limited anti-interference ability, especially under complex backgrounds: When the product background is complex, the contrast between the character color and the background is not high, or there is reflection, simple binarization or basic feature extraction methods are prone to failure, leading to inaccurate character segmentation, and thus losing the basis for subsequent comparison.

[0014] Cumbersome template making and maintenance: Each new product or new printing layout requires manual careful making and verification of the standard template, which is time-consuming and labor-intensive. When production line switching is frequent, the agility of system deployment is affected. Summary of the Invention

[0015] In view of the above-mentioned shortcomings mentioned in the background technology, the purpose of this invention is to provide a character printing defect detection scheme based on adaptive template matching and regional cascade analysis. This invention aims to: (1) construct a robust "adaptive character template" that can accommodate normal process fluctuations by fusing multiple good product images, thereby reducing the dependence on a single template; (2) introduce a configurable set of verification parameters based on character characteristics to replace a single global threshold, thereby achieving differentiated and refined defect judgment; (3) design a multi-stage, regional cascade analysis process, filtering out false differences layer by layer from the whole to the local, from pixels to morphology, focusing on real defects, and calculating their precise physical properties (such as area, location, and type); (4) improve the stability and anti-interference ability of the system under complex imaging conditions; and (5) simplify the initialization process and improve the usability and adaptability of the system.

[0016] Specifically, a first aspect of the present invention provides a method for detecting character printing defects, the method comprising an offline learning phase and an online detection phase: The offline learning phase includes: S1, define a character detection region in at least one pre-processed good character printing image, and segment the characters in each character detection region to obtain the position information of the character unit; S2, Based on multiple images of printed characters of good quality, construct an adaptive character template for each character unit. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character grayscale. The statistical distribution information of the character grayscale includes a grayscale mean map and a grayscale standard deviation map. S3, set a corresponding set of verification parameters for each character unit; The online detection phase includes: S4. Acquire a preprocessed and image-registered printed image of the character to be detected. Perform pixel-level difference detection on the character units to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected missing characters and suspected characters with excess ink. S5, perform regional cascade analysis on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and judge the quality of the character unit and the printed image of the character to be detected according to the verification parameter set.

[0017] A second aspect of the present invention provides a character printing defect detection system, the system comprising: The template building and configuration module is used to execute the offline learning phase, including: The region definition and segmentation unit is used to define character detection regions in at least one pre-processed good-quality character printing image, and to segment characters within each character detection region to obtain the position information of the character units; An adaptive template generation unit is used to construct an adaptive character template for each character unit based on multiple good-quality character printing images. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character grayscale. The statistical distribution information of the character grayscale includes a grayscale mean map and a grayscale standard deviation map. The parameter configuration unit is used to set the corresponding set of verification parameters for each character unit. The online detection and judgment module is used to perform the online detection phase, including: The image acquisition and registration unit is used to acquire printed images of the characters to be detected, and to perform preprocessing and image registration. The difference detection unit is used to perform pixel-level difference detection on the character unit to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected character missing and suspected character excess ink. The cascade analysis and judgment unit is used to perform regional cascade analysis processing on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and judge the quality of the character unit and the printed image of the character to be detected according to the set of verification parameters.

[0018] A third aspect of the invention also provides a medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.

[0019] A fourth aspect of the present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method as described in any of the preceding claims.

[0020] Compared with the prior art, the present invention has the following significant advantages: Significantly improved robustness: The adaptive probability template, constructed by fusing multiple images of good products, essentially learns the statistical distribution of characters under normal production fluctuations. This allows the system to tolerate inherent minor variations in good products, significantly reducing the false rejection rate caused by imperfections in a single template or normal process fluctuations. The standard deviation information σ in the template... j,n It provides an adaptive, localized tolerance range for difference determination.

[0021] Improved detection accuracy and intelligence: Utilizes a configurable set of verification parameters Θ set for each character unit. j,nThis replaces the rigid global threshold. Combined with a regional cascade analysis process, the system can mimic the judgment logic of human quality inspectors, comprehensively evaluating differences from multiple dimensions such as area, shape, and location probability, effectively distinguishing between real defects and false differences (such as edge burrs and minor misalignments). This significantly improves the True Positive Rate while maintaining a low false alarm rate.

[0022] Enhanced Defect Analysis Depth: This invention not only provides a binary "pass / fail" judgment, but also outputs a quantitative report of defects, including precise area (actual physical units), location, type, and morphological classification. This provides valuable data support for process improvement (such as determining whether the problem is with printing pressure or ink), achieving a leap from "quality inspection" to "quality analysis."

[0023] Improved system adaptability and usability: During the initialization phase, templates are automatically generated by collecting multiple good samples, reducing reliance on a single "perfect template" and simplifying the template creation process. While the verification parameter settings are more detailed, they offer a more intuitive and flexible control method. The system's adaptability to complex backgrounds and lighting changes is also enhanced by probabilistic models and statistical tests.

[0024] Optimization of computational efficiency: Cascaded analysis is an "early discard" strategy that can quickly eliminate a large amount of obvious noise and false defects in the early stages (such as area filtering), avoiding complex subsequent calculations on all differing pixels. This optimizes the overall computational efficiency while ensuring accuracy, meeting the needs of online real-time detection. Attached Figure Description

[0025] Figure 1 This is a schematic flowchart of a character printing defect detection method disclosed in an embodiment of the present invention; Figure 2 This is a schematic diagram of the adaptive character template construction process disclosed in an embodiment of the present invention; Figure 3 This is a schematic diagram of the regional cascading analysis process disclosed in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a character printing defect detection system disclosed in an embodiment of the present invention; Figure 5 This is a schematic diagram of the cascaded analysis and determination unit disclosed in an embodiment of the present invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] Please see Figure 1 This invention provides a method for detecting character printing defects, the method comprising an offline learning stage and an online detection stage: The offline learning phase includes: S1, define a character detection region in at least one pre-processed good character printing image, and segment the characters in each character detection region to obtain the position information of the character unit; In this step, the operator uses a human-computer interaction interface to select any pre-processed good product character printing image (e.g., the first one selected from multiple good product images). Above, select the character or text area that needs to be quality checked. These areas are defined as the detection area. ,in , This represents the total number of detection regions, and each detection region can contain one or more characters.

[0028] In each detection area An adaptive character segmentation algorithm is executed internally. This algorithm does not rely on a single global threshold, but instead combines local thresholding segmentation (such as the Sauvola algorithm) with connected component analysis. Specifically, candidate character connected components are first obtained through local thresholding methods, and then the morphological features of each connected component C are calculated, including its area. Aspect Ratio of the Circumscribed Rectangle Duty cycle (fill ratio) These features are compared with predefined character shape priors (e.g., minimum / maximum area a character should have, reasonable aspect ratio range, etc.) to filter out true character sub-regions. Finally, for the j-th detection region, its contained features are obtained. The precise position information of each character unit is usually obtained using its smallest bounding rectangle. It means that among them The character units identified in all detection areas constitute the target set for this detection task.

[0029] It should be noted that for cases with particularly complex backgrounds or severe character overlap, character segmentation methods based on deep learning semantic segmentation models (such as U-Net) can be used as an alternative. Pre-training a model that can directly segment character pixel regions from an image offers higher accuracy and better resistance to interference, but requires pixel-level labeled data for training.

[0030] S2, Based on multiple images of printed characters of good quality, construct an adaptive character template for each character unit. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character grayscale. The statistical distribution information of the character grayscale includes a grayscale mean map and a grayscale standard deviation map. As an example, when constructing the adaptive character template, the corresponding character units in multiple good-quality printed character images are aligned, and the pixel grayscale of the aligned character units is statistically analyzed to form a grayscale mean map and a grayscale standard deviation map to characterize the normal printing fluctuation range of characters.

[0031] Traditional methods rely on a single gold template image, making them highly sensitive to the perfection of the template itself and normal fluctuations in the manufacturing process. This invention proposes an adaptive character template construction method based on a probabilistic statistical model to overcome this limitation.

[0032] Please see Figure 2 First, M images need to be collected ( (e.g., M=10-20) Character printing images that have been manually confirmed as good products They are then subjected to uniform preprocessing to obtain a preprocessed image set. The preprocessing includes grayscale conversion, illumination homogenization (such as applying top-hat transform), and noise filtering (such as Gaussian filtering). The preprocessing aims to reduce irrelevant interference and highlight the character area.

[0033] Use image registration techniques (such as feature point matching) to collect all good product images Align to In the reference coordinate system. For each defined character unit. Precisely crop the corresponding image blocks from each aligned, high-quality image. Subsequently, an adaptive character template containing the following core statistical information is constructed for each character unit. : Foreground Probability Diagram This image represents the probability that each pixel (x, y) within a character unit belongs to the character portion (foreground) under normal production conditions. The calculation method is as follows: First, each good product image block... Perform optimal binarization within its own region to obtain a binary image. (Where 1 represents foreground and 0 represents background). Then, the foreground probability map is calculated using the following formula: ;in, The closer the value is to 1, the more likely the pixel is to be printed as a character in almost all good products, indicating a high level of confidence. A value fluctuating around 0.5 indicates that the position is at the edge of a character and may be printed or missed at times under normal process variations.

[0034] Grayscale mean image This image records the average grayscale value of each pixel within a character unit across multiple good prints, representing the typical printing effect at that location.

[0035] Grayscale standard deviation chart This graph quantifies the dispersion of grayscale values ​​for each pixel across multiple good products, representing the natural range of normal process fluctuations. Standard deviation. The larger the standard deviation, the greater the variation in printing quality between good products, and the greater the tolerance should be given during online inspection; conversely, the smaller the standard deviation, the stricter the requirements.

[0036] Ultimately, adaptive character templates It is a data structure that contains the positions of character units. And the three core statistical graphs mentioned above: , , .

[0037] It's worth noting that besides using pixel-level probabilistic maps and statistical models, deep autoencoders or generative adversarial networks (GANs) can also be employed to learn feature representations of good-quality characters. In the offline phase, a reconstruction network is trained using multiple good-quality images; during online detection, the character to be detected is input into the network, and its output (reconstructed character) is compared to the input. The latent space learned by the network can capture the essential features of the character more abstractly and may be more robust to noise and non-linear variations. However, this approach requires more data and computational resources.

[0038] S3, set a corresponding set of verification parameters for each character unit; In this step, the present invention abandons the single global judgment threshold in traditional methods and instead targets each character unit. Configure a separate set of detailed verification parameters This enables differentiated and refined detection. The set can be configured by experienced engineers based on character characteristics and quality standards, and may include: Difference sensitivity threshold A lenient threshold for initial difference detection. Minimum defect area. This is used to filter imaging noise and minor imperfections; areas smaller than this value will be ignored. Morphological filtering parameters include, for example, elongation thresholds. and density threshold This is used to distinguish between genuine stroke defects and pseudo-defects caused by slight positional misalignment. Classification threshold: such as the missing stroke threshold. And the threshold for determining multiple inks This is used to make a final judgment based on the severity of different defect types. (Location weight map) Assign different importance weights to different regions of a character (such as the center of a stroke and the edge).

[0039] The online detection phase includes: S4. Acquire a preprocessed and image-registered printed image of the character to be detected. Perform pixel-level difference detection on the character units to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected missing characters and suspected characters with excess ink. As an example, pixel-level difference detection is performed on the character units to be detected in the printed image of the character to be detected based on the adaptive character template, generating a difference image containing information on suspected character missingness and suspected character excess ink, including: The grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean map and grayscale standard deviation map of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel. Combined with the probability distribution information of the character foreground, the pixels determined to be abnormal are marked, thereby generating a difference image containing suspected missing character information and suspected extra ink information of the character.

[0040] Images of the product to be inspected are captured using an industrial camera. And perform the same preprocessing as the offline stage to obtain Using the registration references saved during the offline phase, Quickly and accurately align to the template coordinate system. After alignment, adjust according to each adaptive character template. Location information stored in Extracting the corresponding image block from the image to be inspected. .

[0041] Next, pixel-level difference detection based on a statistical model is performed. For For each pixel (x, y) in the template, its grayscale value is q. Calculate its grayscale reference model relative to the corresponding position in the template. The degree of deviation is measured using standardized scores. : ;in, It is a very small protection value used to prevent division by zero errors. If If the grayscale value of the pixel exceeds the normal fluctuation range, it is considered an abnormal pixel. Here, k is a preset coefficient, ranging from 2.5 to 3.5, corresponding to the high confidence interval of a normal distribution.

[0042] It should be noted that, in addition to using Alternatively, Mahalanobis distance or image differencing combined with adaptive thresholding can be used. For example, calculating the image patch to be detected. With grayscale mean map The absolute difference image, then used with Binarization is performed using a local threshold as a reference. The calculation formula is: , among them To adjust the parameters.

[0043] Furthermore, an improved scheme is provided, specifically: comparing the grayscale information of each pixel in the character unit to be detected with the grayscale mean map and grayscale standard deviation map of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel, including: Based on the deviation between the pixel grayscale information and the corresponding grayscale mean, and combined with the corresponding grayscale standard deviation, the basic anomaly determination value of the pixel is calculated. Based on the spatial position information of the pixel in the character unit, the abnormal pixel distribution in the region where the pixel is located is analyzed to obtain the corresponding spatial clustering determination quantity; and, based on the defect type corresponding to the pixel, the corresponding type determination quantity is determined. The basic anomaly determination quantity, the spatial aggregation determination quantity, and the type determination quantity are combined, and the pixel is determined as an abnormal pixel based on the combination result.

[0044] In this improved scheme, when performing pixel-level difference detection on the character unit to be detected based on the adaptive character template, the process of determining whether a pixel belongs to an abnormal pixel is improved in order to improve the accuracy of abnormal pixel determination.

[0045] Specifically, the grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean image and grayscale standard deviation image of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel. The specific determination process includes the following steps: First, for any pixel in the character unit to be detected, the grayscale information of that pixel is acquired and compared with the mean grayscale value of the corresponding position in the adaptive character template to determine the deviation of the pixel's grayscale from the normal character printing state. Simultaneously, combined with the grayscale standard deviation information corresponding to that position, the grayscale deviation relationship is scaled to construct the basic anomaly determination metric for that pixel (see the aforementioned details). The calculation formula is as follows. The basic anomaly determination quantity is used to characterize the degree to which the pixel deviates from the normal printing state in a grayscale statistical sense.

[0046] Then, combining the spatial location information of the pixel within the character unit, the abnormal pixel distribution in the region where the pixel is located is analyzed. Specifically, based on the spatial relationship between the pixel and its neighboring pixels, it is determined whether the pixel is located in a region where abnormal pixels are concentrated, and a corresponding spatial clustering determination metric is constructed accordingly. The spatial clustering determination metric is used to reflect the clustering characteristics of abnormal pixels at the spatial structure level, in order to distinguish between isolated anomalies caused by random noise and abnormal distributions with structural features.

[0047] For example: the spatial clustering determination factor can be expressed as: .in, This indicates the spatial clustering determination value of the pixel; This indicates the number of abnormal pixels in the neighborhood of this pixel; This indicates the total number of pixels in the neighborhood. A larger spatial clustering threshold indicates that the pixel is located in an area where anomalous pixels are concentrated; a smaller spatial clustering threshold indicates that the pixel is more likely to be an isolated anomalous pixel.

[0048] Furthermore, a corresponding type determination quantity is constructed based on the defect type corresponding to the pixel. The defect types include suspected character missing and suspected character extra ink. Different defect types correspond to different type determination quantities, which are used to characterize the differences between different defect types in the anomaly determination process.

[0049] For example: different type weight coefficients can be pre-set for different defect types, and these type weight coefficients can be used as the type determination factor for that pixel. For example: ;in, This indicates the type determination value for the pixel; This indicates the type weight coefficient corresponding to the suspected character with multiple ink lines; This represents the type weighting coefficient corresponding to the suspected missing character. The type weighting coefficient can be preset or adjusted according to different character printing processes or quality requirements to reflect the differences in the anomaly judgment process of different defect types.

[0050] After obtaining the basic anomaly determination factor, spatial clustering determination factor, and type determination factor, these multiple determination factors are combined to form a comprehensive determination result for the pixel. For example, the three determination factors can be weighted and combined to form the comprehensive determination result for the pixel. For example, the comprehensive determination result for the pixel can be expressed as: .in, This indicates the overall judgment result for that pixel; Indicates the basic anomaly determination quantity; Indicates the spatial clustering determination quantity; Indicates type determination quantity; These are preset weighting coefficients used to adjust the influence of different judgment quantities in the overall judgment.

[0051] After calculating the comprehensive judgment result, the comprehensive judgment result is compared with a preset anomaly judgment threshold. When the comprehensive judgment result exceeds the anomaly judgment threshold, the pixel is determined to be an abnormal pixel; when the comprehensive judgment result does not exceed the anomaly judgment threshold, the pixel is determined to be a normal pixel.

[0052] At the same time, combined with the foreground probability diagram Preliminary classification of abnormal pixels: like If the pixel is determined to be background (i.e., brighter grayscale) in the current image, it is marked as "suspected missing" (the character should be printed but it is not). If the pixel is determined to be in the foreground (i.e., the grayscale is darker), it is marked as "suspected over-inking" (the area that should be the background has been over-inked).

[0053] By summing up all the labeled pixels, a raw difference image with preliminary classification labels is generated. .

[0054] S5, perform regional cascade analysis on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and judge the quality of the character unit and the printed image of the character to be detected according to the verification parameter set.

[0055] As an example, a region cascade analysis is performed on the difference image to progressively filter and confirm the true defect regions, including: Connectivity analysis is performed on the difference regions formed by suspected missing character pixels and suspected extra ink pixels in the difference image, and the difference regions are initially screened according to the preset minimum defect area parameter to remove non-real defect regions caused by imaging noise or small fluctuations, thereby retaining candidate real defect regions.

[0056] Original difference image It contains real defects, but also contains a significant amount of imaging noise, edge burrs, and spurious differences caused by slight positional shifts. This invention further introduces a region cascade analysis process (see...). Figure 3 As shown in the figure, it mimics the judgment logic of human quality inspectors from coarse to fine, filtering layer by layer to focus on real defects.

[0057] Level 1: Filtering based on the area of ​​connected components.

[0058] To each Connectivity analysis was performed on the "suspected missing" and "suspected excessive" pixels to obtain a series of candidate defect regions. Calculate the actual pixel area of ​​each connected component. According to the aforementioned settings Decisively eliminate all This step effectively filters out the vast majority of salt-and-pepper noise and minor, meaningless imaging flaws in the area.

[0059] Level 2: Filtering based on morphological features.

[0060] For candidate defect regions filtered by area, calculate their morphological description features: elongation : ,in and This represents the lengths of the principal and secondary axes of the connected region. The larger this value, the more elongated the region.

[0061] Tightness : ,in This is the perimeter of the connected region. The closer this value is to 1, the closer the shape is to a circle (more compact); the smaller the value, the looser and more irregular the shape.

[0062] Define the following rule: If a connected component simultaneously satisfies and This indicates that the area is elongated and loosely shaped. This morphological feature closely resembles the "burrs" or "ghosting" of character edges caused by slight, within-tolerance positional shifts during the printing process, rather than actual stroke breaks or foreign matter contamination. Therefore, such areas are marked as "tolerable positional deviations" and filtered at this level. This step cleverly distinguishes between morphological defects and positional tolerances, greatly reducing the pass rate.

[0063] It should be noted that in the second-level filtering, in addition to elongation and density, more complex shape descriptors, such as Hu invariant moments, can be introduced to match the model of pre-defined tolerable offset defects, filtering out those with high similarity. Alternatively, a machine learning classifier (such as a support vector machine, SVM) can be used to classify each connected component, determining whether it is a real defect or a pseudo-defect. The classifier's features include area, shape, and statistical values ​​on the probability graph.

[0064] Level 3: Validation based on adaptive template probability.

[0065] For the connected components remaining after the first two levels of rigorous screening, we need to use the prior knowledge in the template for final verification. This involves mapping each connected component back to the foreground probability graph. Calculate the average foreground probability of all pixels covered by the defect region. .

[0066] For a region that is "suspected to be missing", if A value that is very high (e.g., >0.8) means that in almost all good products, this area belongs to the character portion, so the current absence is very likely a genuine defect. Conversely, if... A value of medium (e.g., between 0.4 and 0.6) indicates that the area itself is in the ambiguous zone of the character edge, and there are fluctuations between good products. The current "missing" is likely still within the normal process fluctuation range, and release can be considered.

[0067] By combining Settings and The relevant probability thresholds can enable more accurate judgments that better reflect actual production conditions.

[0068] The connected components that remained after the above three-level cascade analysis were ultimately confirmed as the real defects.

[0069] As an example, the quality judgment of the character unit and the printed image of the character to be detected based on the set of verification parameters includes: Based on the set of verification parameters, the number, area and type of the confirmed real defect areas in each character unit are comprehensively evaluated. First, the pass / fail judgment result of the corresponding character unit is determined. Then, based on the judgment results of multiple character units, the overall quality of the printed image of the character to be tested is judged.

[0070] For each real defect, a quantitative analysis is performed to calculate its physical area (converted according to camera calibration), center of gravity position, defect type (missing / excessive ink), and morphological category (dot / line / block).

[0071] Based on information about all real defects on each character unit, combined with a set of verification parameters customized for that character unit. (like , Position weight (etc.), to calculate the quality score The calculation formula is, for example: ;in, It is the area of ​​the defect. It is its positional weight. If If a character unit fails to meet the required standard, it is deemed unqualified. Ultimately, the final judgment result for the entire product or inspection area can be derived by combining the judgment results of all character units based on preset rules (such as "one-vote veto" or "allowing a maximum of X characters to be defective").

[0072] The character printing defect detection scheme based on adaptive template matching and regional cascade analysis provided by this invention replaces the fixed image template by constructing a probabilistic statistical model and adopts a multi-level progressive intelligent analysis process, which realizes high robustness, high precision and intelligent automatic detection of character printing quality. It effectively solves the problems of high over-detection rate and poor adaptability of traditional methods and has good industrial application value.

[0073] Please see Figure 4 This invention also provides a character printing defect detection system 200, the system comprising: Template building and configuration module 201, used to execute the offline learning phase, includes: The region definition and segmentation unit 2011 is used to define a character detection region in at least one pre-processed good character printing image, and segment characters within each character detection region to obtain the position information of the character unit; The adaptive template generation unit 2012 is used to construct an adaptive character template for each character unit based on multiple good-quality character printing images. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character gray level. The statistical distribution information of the character gray level includes a gray level mean map and a gray level standard deviation map. The parameter configuration unit 2013 is used to set the corresponding set of verification parameters for each character unit. The online detection and judgment module 202 is used to perform the online detection phase, including: The image acquisition and registration unit 2021 is used to acquire printed images of the characters to be detected, and to perform preprocessing and image registration. The difference detection unit 2022 is used to perform pixel-level difference detection on the character unit to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected character missing and suspected character excess ink. The cascade analysis and judgment unit 2023 is used to perform regional cascade analysis processing on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and judge the quality of the character unit and the printed image of the character to be detected according to the set of verification parameters.

[0074] As an example, the adaptive template generation unit 2012 is specifically used for: By aligning corresponding character units in multiple good-quality printed character images and statistically analyzing the pixel grayscale of the aligned character units, a grayscale mean map and a grayscale standard deviation map are generated to characterize the normal printing fluctuation range of characters.

[0075] As an example, the difference detection unit 2022 is specifically used for: The grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean map and grayscale standard deviation map of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel. Combined with the probability distribution information of the character foreground, the pixels determined to be abnormal are marked, thereby generating a difference image containing suspected missing character information and suspected extra ink information of the character.

[0076] As an example, the difference detection unit 2022 is specifically used for: Based on the deviation between the pixel grayscale information and the corresponding grayscale mean, and combined with the corresponding grayscale standard deviation, the basic anomaly determination value of the pixel is calculated. Based on the spatial position information of the pixel in the character unit, the abnormal pixel distribution in the region where the pixel is located is analyzed to obtain the corresponding spatial clustering determination quantity; and, based on the defect type corresponding to the pixel, the corresponding type determination quantity is determined. The basic anomaly determination quantity, the spatial aggregation determination quantity, and the type determination quantity are combined, and the pixel is determined as an abnormal pixel based on the combination result.

[0077] As an example, please refer to Figure 5 The cascade analysis and judgment unit 2023 includes a cascade analysis subunit 20231, which is used for: Connectivity analysis is performed on the difference regions formed by suspected missing character pixels and suspected extra ink pixels in the difference image, and the difference regions are initially screened according to the preset minimum defect area parameter to remove non-real defect regions caused by imaging noise or small fluctuations, thereby retaining candidate real defect regions.

[0078] As an example, please refer to Figure 5 The cascaded analysis and judgment unit 2023 further includes a comprehensive judgment electronic unit 20232, which is used for: Based on the set of verification parameters, the number, area and type of the confirmed real defect areas in each character unit are comprehensively evaluated. First, the pass / fail judgment result of the corresponding character unit is determined. Then, based on the judgment results of multiple character units, the overall quality of the printed image of the character to be tested is judged.

[0079] This invention also provides a medium having a computer program stored thereon, which, when executed by a processor, implements the method as described in any of the preceding claims.

[0080] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the method described in any of the preceding claims.

[0081] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for detecting character printing defects, characterized in that... The method includes an offline learning phase and an online testing phase: the offline learning phase includes: S1, define a character detection region in at least one pre-processed good character printing image, and segment the characters in each character detection region to obtain the position information of the character unit; S2, Based on multiple images of printed characters of good quality, construct an adaptive character template for each character unit. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character grayscale. The statistical distribution information of the character grayscale includes a grayscale mean map and a grayscale standard deviation map. S3, set a corresponding set of verification parameters for each character unit; The online detection phase includes: S4. Acquire a preprocessed and image-registered printed image of the character to be detected. Perform pixel-level difference detection on the character units to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected missing characters and suspected characters with excess ink. S5, perform region cascade analysis on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and judge the quality of the character unit and the printed image of the character to be detected according to the set of verification parameters. When constructing the adaptive character template, the corresponding character units in multiple good-quality character printing images are aligned, and the pixel grayscale of the aligned character units is statistically analyzed to form a grayscale mean map and a grayscale standard deviation map to characterize the normal printing fluctuation range of characters. Based on the adaptive character template, pixel-level difference detection is performed on the character units to be detected in the printed image of the character to be detected, generating a difference image containing information on suspected character missingness and suspected character excess ink, including: The grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean map and grayscale standard deviation map of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel. Combined with the probability distribution information of the character foreground, the pixels determined to be abnormal are marked, thereby generating a difference image containing suspected missing character information and suspected extra ink information of the character. The grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean image and grayscale standard deviation image of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel, including: Based on the deviation between the pixel grayscale information and the corresponding grayscale mean, and combined with the corresponding grayscale standard deviation, the basic anomaly determination value of the pixel is calculated. Based on the spatial position information of the pixel in the character unit, the abnormal pixel distribution in the region where the pixel is located is analyzed to obtain the corresponding spatial clustering determination quantity; and, based on the defect type corresponding to the pixel, the corresponding type determination quantity is determined. The basic anomaly determination quantity, the spatial aggregation determination quantity, and the type determination quantity are combined, and the pixel is determined as an abnormal pixel based on the combination result.

2. The method for detecting character printing defects according to claim 1, characterized in that: Perform region cascade analysis on the difference images to progressively filter and confirm the true defect regions, including: Connectivity analysis is performed on the difference regions formed by suspected missing character pixels and suspected extra ink pixels in the difference image, and the difference regions are initially screened according to the preset minimum defect area parameter to remove non-real defect regions caused by imaging noise or small fluctuations, thereby retaining candidate real defect regions.

3. The method for detecting character printing defects according to claim 1, characterized in that: The quality of the printed image of the character unit and the character to be detected is determined based on the set of verification parameters, including: Based on the set of verification parameters, the number, area and type of the confirmed real defect areas in each character unit are comprehensively evaluated. First, the pass / fail judgment result of the corresponding character unit is determined. Then, based on the judgment results of multiple character units, the overall quality of the printed image of the character to be tested is judged.

4. A character printing defect detection system, characterized in that: The system includes: The template building and configuration module is used to execute the offline learning phase, including: The region definition and segmentation unit is used to define character detection regions in at least one pre-processed good-quality character printing image, and to segment characters within each character detection region to obtain the position information of the character units; An adaptive template generation unit is used to construct an adaptive character template for each character unit based on multiple good-quality character printing images. The adaptive character template includes at least the spatial position of the character unit, the probability distribution information of the character foreground, and the statistical distribution information of the character grayscale. The statistical distribution information of the character grayscale includes a grayscale mean map and a grayscale standard deviation map. The parameter configuration unit is used to set the corresponding set of verification parameters for each character unit. The online detection and judgment module is used to perform the online detection phase, including: The image acquisition and registration unit is used to acquire printed images of the characters to be detected, and to perform preprocessing and image registration. The difference detection unit is used to perform pixel-level difference detection on the character unit to be detected in the printed image of the character to be detected according to the adaptive character template, and generate a difference image containing information on suspected character missing and suspected character excess ink. The cascade analysis and judgment unit is used to perform regional cascade analysis processing on the difference image, filter and confirm the real defect area step by step, quantify the defects of the confirmed real defect area, and make quality judgment on the character unit and the printed image of the character to be detected according to the set of verification parameters. The adaptive template generation unit is specifically used for: By aligning corresponding character units in multiple good-quality printed character images and statistically analyzing the pixel grayscale of the aligned character units, a grayscale mean map and a grayscale standard deviation map are formed to characterize the normal printing fluctuation range of characters. The difference detection unit is specifically used for: The grayscale information of each pixel in the character unit to be detected is compared with the grayscale mean map and grayscale standard deviation map of the corresponding position in the adaptive character template to determine whether the pixel belongs to an abnormal pixel. Combined with the probability distribution information of the character foreground, the pixels determined to be abnormal are marked, thereby generating a difference image containing suspected missing character information and suspected extra ink information of the character. The difference detection unit is specifically used for: Based on the deviation between the pixel grayscale information and the corresponding grayscale mean, and combined with the corresponding grayscale standard deviation, the basic anomaly determination value of the pixel is calculated. Based on the spatial position information of the pixel in the character unit, the abnormal pixel distribution in the region where the pixel is located is analyzed to obtain the corresponding spatial clustering determination quantity; and, based on the defect type corresponding to the pixel, the corresponding type determination quantity is determined. The basic anomaly determination quantity, the spatial aggregation determination quantity, and the type determination quantity are combined, and the pixel is determined as an abnormal pixel based on the combination result.

5. A medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the method as described in any one of claims 1-3.

6. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, it implements the method as described in any one of claims 1-3.