Printing defect detection method, computer device and storage medium

By segmenting, matching, refining and comparing text contours, the over-detection problem of complex text detection in the existing technology is solved, and the accuracy and efficiency of printing defect detection are improved.

CN115829904BActive Publication Date: 2025-10-10HON HAI PRECISION INDUSTRY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111092202.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2025-10-10
Estimated Expiration
2041-09-17

AI Technical Summary

Technical Problem

Existing printing defect detection technology based on defect area ratio is prone to over-detection when detecting complex characters with many strokes, and the detection method based on Hu moments has difficulty in interpreting the shape characteristics of characters, resulting in insufficient detection accuracy.

Method used

By obtaining a flawless image and an image to be inspected, the text is segmented using OCR technology, and image feature matching and binarization processing are combined to refine the text contours. A mask image is generated through bitwise AND operations, and the number of text contours is compared to determine defects and reduce the over-kill rate.

Benefits of technology

The accuracy of printing defect detection is improved, the over-kill rate is reduced, the detection efficiency is improved, and the verification steps for setting thresholds are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115829904B_ABST
    Figure CN115829904B_ABST
Patent Text Reader

Abstract

The application provides a printing defect detection method, a computer device and a storage medium, and the method comprises the following steps: acquiring a non-defect image and a to-be-detected image; acquiring a first image of each character in the non-defect image; acquiring a second image of each character from the to-be-detected image according to the first image of each character; acquiring a third image of each character based on the first image of each character and acquiring a fourth image of each character based on the second image of each character; acquiring a fifth image of each character based on the third image of each character; acquiring a sixth image of any character according to the fourth image and the fifth image of the character; and determining a detection result of any character according to the fifth image and the sixth image of the character. The application can assist in defect detection and improve the accuracy of detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of optical defect detection, and in particular to a printing defect detection method, a computer device, and a storage medium. Background Art

[0002] Existing printing defect detection technology based on structural similarity and defect area ratio works well for characters with fewer strokes, such as numbers and English, because the range of variation in character area is smaller. However, when detecting complex characters with more strokes, such as Chinese and Japanese Kanji, over-detection occurs because the shape defects of the characters do not meet the standard for visual detection of defects by the human eye. Detection methods based on Hu moments, on the other hand, have the disadvantage of not easily interpreting the shape characteristics of characters. This results in a lack of clear direction for subsequent pre-processing adjustments to reduce over-detection. Summary of the Invention

[0003] In view of the above, it is necessary to provide a printing defect detection method, a computer device and a storage medium that can assist in printing defect detection, reduce the overkill rate and thus improve the accuracy of detection.

[0004] The printing defect detection method includes: acquiring a flawless image and an image to be detected; performing first image processing on the flawless image to obtain a first image of each character in the flawless image; acquiring a second image of each character from the image to be detected based on the first image of each character, and establishing an association between the first image of each character and the second image of each character; performing second image processing on the first image of each character to obtain a third image of each character, and performing second image processing on the second image of each character to obtain a fourth image of each character; performing third image processing on the third image of each character to obtain a fifth image of each character; obtaining a sixth image of any character based on the fourth image of any character and the fifth image of any character; and determining the detection result of any character in the image to be detected based on the fifth image of any character and the sixth image of any character.

[0005] Optionally, the first image processing includes: determining a first position of each character in the flawless image, and segmenting each character in the flawless image according to the first position of each character.

[0006] Optionally, based on the first image of each character, an image feature matching algorithm is used to obtain the second image of each character from the image to be detected.

[0007] Optionally, the second image processing includes: performing image binarization according to a preset binarization threshold.

[0008] Optionally, the third image processing includes: using an image thinning algorithm to thin the text outline.

[0009] Optionally, obtaining the sixth image of any character based on the fourth image of any character and the fifth image of any character includes: performing a bitwise AND operation on the fourth image of any character and the fifth image of any character to obtain a mask image of the fourth image of any character and the fifth image of any character, and using the mask image as the sixth image of any character.

[0010] Optionally, determining the detection result of any character in the image to be detected based on the fifth image of any character and the sixth image of any character includes: determining the number of character contours in the fifth image of any character to obtain the first number of contours of any character; and determining the number of character contours in the sixth image of any character to obtain the second number of contours of any character; comparing the first number of contours of any character with the second number of contours of any character; when the first number of contours of any character and the second number of contours of any character are different, determining that any character in the image to be detected is a defective character; and when the first number of contours of any character and the second number of contours of any character are the same, determining that any character in the image to be detected is a flawless character.

[0011] The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the printing defect detection method is implemented.

[0012] The computer device includes a memory and at least one processor. The memory stores at least one instruction. When the at least one instruction is executed by the at least one processor, the printing defect detection method is implemented.

[0013] Compared with the existing technology, the printing defect detection method, computer device and storage medium can assist in printing defect detection, reduce the overkill rate produced by the detection method based on the defect area ratio, thereby improving the detection accuracy, and can also reduce the verification steps of setting the threshold value, thereby improving the detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0015] Figure 1 This is a flow chart of the printing defect detection method provided in an embodiment of the present application.

[0016] Figure 2 This is an architectural diagram of a computer device provided in an embodiment of the present application.

[0017] Figure 3 These are example images of the letter "A" provided in the embodiments of the present application.

[0018] Figure 4 This is a flowchart of step S7 provided in an embodiment of the present application.

[0019] Description of main component symbols

[0020] Computer device 3 Printed defect detection system 30 Memory 31 Processor 32

[0021] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0022] In order to more clearly understand the above-mentioned objectives, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features therein can be combined with each other in the absence of conflict.

[0023] The following description sets forth many specific details to facilitate a full understanding of the present application. The embodiments described are only a portion of the embodiments of the present application, not all of the embodiments. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present application without creative effort are intended to fall within the scope of protection of the present application.

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application.

[0025] See Figure 1 FIG. 1 is a flow chart of a printing defect detection method according to a preferred embodiment of the present application.

[0026] In this embodiment, the printing defect detection method can be applied to a computer device (eg Figure 2 In the computer device 3) shown, for a computer device that needs to perform printing defect detection, the function for printing defect detection provided by the method of the present application can be directly integrated on the computer device, or run on the computer device in the form of a software development kit (SDK).

[0027] As shown in Figure 1 The printing defect detection method specifically includes the following steps, and the order of the steps in the flowchart can be changed according to different requirements, and some steps can be omitted.

[0028] Step S1, the computer device acquires a defect-free image and a to-be-detected image.

[0029] In an embodiment, the computer device can acquire a defect-free image and a to-be-detected image in response to user input. The defect-free image and the to-be-detected image can also be pre-stored in the memory of the computer device or pre-stored in other devices in communication connection with the computer device.

[0030] In this embodiment, the defect-free image can be a rectangular standard sample (Golden Sample) image of a certain printed matter produced by a factory, that is, the arrangement direction of the text in the defect-free image does not need to be corrected. In this embodiment, the text contained in the defect-free image can refer to, for example, Chinese characters, numbers, English letters, etc.

[0031] In this embodiment, the to-be-detected image can be a rectangular image taken for the certain printed matter to be detected.

[0032] In an embodiment, the to-be-detected image and the defect-free image are of the same size.

[0033] Step S2, the computer device performs first image processing on the defect-free image to obtain a first image of each text in the defect-free image.

[0034] In an embodiment, the first image processing includes determining a first position of each text in the defect-free image and segmenting each text in the defect-free image according to the first position of each text.

[0035] In an embodiment, the computer device can use optical character recognition (OCR) technology to recognize the text in the defect-free image and then confirm the first position of each text in the defect-free image. For example, the computer device can frame each text in the defect-free image with a first rectangular frame, each text corresponding to a first rectangular frame, and each first rectangular frame containing the complete image of one text in the defect-free image.

[0036] In one embodiment, the computer device may use the character segmentation function of the OCR software to segment each character in the flawless image according to the first position of each character to obtain the first image of each character in the flawless image. For example, the computer device segments each character in the flawless image along the edge of the first rectangular frame to obtain the first image of each character. Figure 3 As shown in FIG, a first image 3A of the letter "A" in a flawless image is obtained.

[0037] In step S3 , the computer device obtains the second image of each character from the image to be detected based on the first image of each character, and establishes an association between the first image of each character and the second image of each character.

[0038] In one embodiment, the computer device uses an image feature matching algorithm to take the first image of each character as the target image, identify the target image from the image to be detected, and cut out the identified target image from the image to be detected, thereby obtaining the second image of each character that matches the first image of each character. It should be noted that, since each character has a unique first image in step S2, a one-to-one correspondence is established between the first image of each character and the second image of each character, and the first image of each character is the same size as the second image of each character. For example Figure 3 As shown, a second image 3B of the letter "A" is obtained from the image to be inspected based on the first image 3A of the letter "A" in the flawless image.

[0039] In step S4 , the computer device performs the second image processing on the first image of each character to obtain a third image of each character, and performs the second image processing on the second image of each character to obtain a fourth image of each character.

[0040] In one embodiment, the second image processing includes: performing image binarization according to a preset binarization threshold, and the preset binarization threshold can be determined by an OTSU Thresholding algorithm.

[0041] The second image processing of the first image of each character includes: using the Otsu algorithm to determine a first binarization threshold (e.g., 100) of the first image of each character; when the pixel value at any position in the first image of each character is greater than or equal to the first binarization threshold, binarizing the pixel at any position to 255; when the pixel value at any position in the first image of each character is less than the first binarization threshold, binarizing the pixel at any position to 0. For exampleFigure 3 As shown, the first image 3A of the letter "A" in the flawless image is binarized according to the first binarization threshold 100 to obtain a third image 3C of the letter "A".

[0042] The second image processing on the second image of each character includes: determining a second binarization threshold (e.g., 130) of the second image of each character by using the Otsu algorithm, binarizing a pixel at any position in the second image of each character to 255 when a pixel value at the position is greater than or equal to the second binarization threshold; and binarizing the pixel at the position to 0 when the pixel value at the position is less than the second binarization threshold. For example Figure 3 As shown, the first image 3B of the letter "A" in the image to be detected is binarized according to the second binarization threshold 130 to obtain a fourth image 3D of the letter "A".

[0043] It should be noted that, as Figure 3 As shown, the pixel value of the character contour in each binarized image (i.e., the third image of each character and the fourth image of each character) obtained after binarizing the first image of each character and the second image of each character according to the preset binarization threshold is 255.

[0044] In step S5, the computer device performs third image processing on the third image of each character to obtain a fifth image of each character.

[0045] In one embodiment, the third image processing includes: refining the character contour by using an image thinning algorithm. The computer device performs skeleton extraction on the character contour in the binarized image by using the image thinning algorithm, and maintains the connectivity of the character contour. For example Figure 3 As shown, the third image 3C of the letter "A" in the flawless image is thinned to obtain a fifth image 3E via image thinning, and the pixel value of the thinned character contour is 255.

[0046] In step S6, the computer device obtains a sixth image of any character according to the fourth image of the character and the fifth image of the character.

[0047] In one embodiment, the obtaining of the sixth image of any character according to the fourth image of the character and the fifth image of the character includes: performing a bitwise AND operation on the fourth image of the character and the fifth image of the character to obtain a mask image of the fourth image of the character and the fifth image of the character, and taking the mask image as the sixth image of the character. For exampleFigure 3 As shown, the sixth image 3F of the letter “A” is obtained by performing a bitwise AND operation on the fourth image 3D and the fifth image 3E of the letter “A”.

[0048] In this embodiment, the pixel value of the character outline in the sixth image of any one of the characters is 255.

[0049] In step S7 , the computer device determines a detection result of the arbitrary character in the image to be detected based on the fifth image of the arbitrary character and the sixth image of the arbitrary character.

[0050] In one embodiment, the determination of the detection result of any character in the image to be detected based on the fifth image of any character and the sixth image of any character includes: determining the number of character contours in the fifth image of any character to obtain the first number of contours of any character; and determining the number of character contours in the sixth image of any character to obtain the second number of contours of any character. The first number of contours of any character includes the first number of inner contours and the first number of outer contours of any character, and the second number of contours of any character includes the second number of inner contours and the second number of outer contours of any character. The computer device can use the CVfindContours function of the OpenCV algorithm to obtain the first number of contours and the second number of contours of any character, and then execute the following Figure 4 Step S70 is shown.

[0051] In step S70, the computer device compares the number of first contours of any character and the number of second contours of any character; when the number of first contours of any character and the number of second contours of any character are different, execute step S71; and when the number of first contours of any character and the number of second contours of any character are the same, execute step S72.

[0052] In one embodiment, the computer device first compares the first inner contour number and the second inner contour number of the any character, and then compares the first outer contour number and the second outer contour number of the any character; if and only if the first inner contour number and the second inner contour number of the any character are the same, and the first outer contour number and the second outer contour number of the any character are also the same, the computer device determines that the first contour number and the second contour number of the any character are the same. It should be noted that when the computer device determines that the first inner contour number and the second inner contour number of the any character are different, it may no longer compare the first outer contour number and the second outer contour number of the any character, and directly determine that the first contour number and the second contour number of the any character are different.

[0053] For example, see Figure 3 As shown, the number of the first inner contours of the letter "A" determined from the fifth image 3E is 1 and the number of the first outer contours is 1, and the number of the second inner contours of the letter "A" determined from the sixth image 3F is 1 and the number of the second outer contours is 2. Since the number of the first outer contours and the number of the second outer contours of the letter "A" are different, the number of the first contours of the letter "A" is different from the number of the second contours of the letter "A".

[0054] In step S71 , the computer device determines that any of the characters in the image to be detected is a defective character.

[0055] For example, it can be seen from step S70 that Figure 3 The letter "A" in the image to be detected is a defective character. It should be noted that when the number of first contours of any character is different from the number of second contours of any character, it can be confirmed that the character skeleton of any character in the image to be detected is broken, and therefore any character is a defective character.

[0056] In step S72 , the computer device determines that any of the characters in the image to be detected is a flawless character.

[0057] above Figure 1 The printing defect detection method of this application is introduced in detail. Figure 2 , the hardware device architecture for implementing the printing defect detection method is introduced.

[0058] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0059] See Figure 2 As shown, it is a schematic diagram of the structure of the computer device provided in the preferred embodiment of the present application. In the preferred embodiment of the present application, the computer device 3 includes a memory 31 and at least one processor 32. Those skilled in the art should understand that Figure 2 The structure of the computer device shown does not constitute a limitation of the embodiments of the present application, and can be either a bus structure or a star structure. The computer device 3 can also include more or less other hardware or software than shown in the figure, or a different component arrangement.

[0060] In some embodiments, the computer device 3 includes a terminal that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, a dedicated integrated circuit, a programmable gate array, a digital processor and an embedded device.

[0061] It should be noted that the computer device 3 is only an example. Other existing or future electronic products that are suitable for this application should also be included in the scope of protection of this application and included here by reference.

[0062] In some embodiments, the memory 31 is used to store program code and various data. For example, the memory 31 can be used to store flawless images and images to be inspected, as well as the printing defect detection system 30 installed in the computer device 3, and can achieve high-speed, automatic access to programs or data during the operation of the computer device 3. The memory 31 includes read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electronically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM), other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable storage medium capable of carrying or storing data.

[0063] In some embodiments, the at least one processor 32 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The at least one processor 32 is the control core (Control Unit) of the computer device 3, connecting the various components of the entire computer device 3 using various interfaces and lines. By running or executing programs or modules stored in the memory 31 and calling data stored in the memory 31, the processor executes various functions of the computer device 3 and processes data, such as executing the printing defect detection system 30 to implement the printing defect detection function.

[0064] In some embodiments, the printing defect detection system 30 is run in a computer device 3. The printing defect detection system 30 may include multiple functional modules composed of program code segments. The program code of each program segment in the printing defect detection system 30 may be stored in a memory 31 of the computer device 3 and executed by at least one processor 32 to implement Figure 1 The function of detecting printing defects is shown.

[0065] In this embodiment, the printing defect detection system 30 can be divided into multiple functional modules according to the functions it performs. A module as referred to in this application refers to a series of computer program segments that can be executed by at least one processor and can perform fixed functions, which are stored in a memory.

[0066] Although not shown, the computer device 3 may also include a power source (such as a battery) to power various components. Preferably, the power source may be logically connected to the at least one processor 32 via a power management device, thereby enabling the power management device to manage charging, discharging, and power consumption. The power source may also include one or more DC or AC power sources, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components. The computer device 3 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0067] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0068] The above-mentioned integrated unit implemented in the form of a software functional module can be stored in a computer-readable storage medium. The above-mentioned software functional module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a server, personal computer, etc.) or a processor to execute parts of the methods described in various embodiments of the present application.

[0069] In a further embodiment, in combination Figure 2 The at least one processor 32 can execute the operating system of the computer device 3 and various installed application programs (such as the printing defect detection system 30), program codes, etc., for example, the various modules mentioned above.

[0070] The memory 31 stores program code, and the at least one processor 32 can call the program code stored in the memory 31 to execute related functions. The program code stored in the memory 31 can be executed by the at least one processor 32, thereby realizing the functions of the various modules and achieving the purpose of printing defect detection.

[0071] In one embodiment of the present application, the memory 31 stores one or more instructions (ie, at least one instruction), and the at least one instruction is executed by the at least one processor 32 to implement Figure 1 The purpose of printing defect detection is shown.

[0072] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is only a logical function division, and other division methods may be used in actual implementation.

[0073] The modules described as separate components may or may not be physically separate, and 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 elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.

[0074] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0075] It is obvious to those skilled in the art that the present application is not limited to the details of the above-mentioned exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic characteristics of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes that fall within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claim involved. In addition, it is obvious that the word "comprising" does not exclude other units or, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. Words such as first, second, etc. are used to indicate names and do not indicate any particular order.

[0076] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.

Claims

1. A method for detecting printing defects, characterized in that: The method comprises: Acquire a flawless image and an image to be inspected; Performing text segmentation processing on the flawless image to obtain a first image of each text in the flawless image; According to the first image of each character, obtaining a second image of each character from the image to be detected, and establishing an association between the first image of each character and the second image of each character; performing image binarization processing on the first image of each character to obtain a third image of each character, and performing image binarization processing on the second image of each character to obtain a fourth image of each character; Performing image thinning processing on the third image of each character to obtain a fifth image of each character, wherein the image thinning processing includes extracting a skeleton of the character outline in the third image; Obtaining a sixth image of any character according to the fourth image of any character and the fifth image of any character based on a bitwise AND operation, comprising: obtaining a mask image of the fourth image of any character and the fifth image of any character, and using the mask image as the sixth image of any character; and Determining a detection result of the any character in the image to be detected according to the fifth image of the any character and the sixth image of the any character includes: Determine the number of character contours in the fifth image of the any character to obtain the number of first contours of the any character; and Determining the number of character contours in the sixth image of the any character to obtain the number of second contours of the any character; wherein the number of first contours of the any character includes the number of first inner contours and the number of first outer contours of the any character, and the number of second contours of the any character includes the number of second inner contours and the number of second outer contours of the any character; Comparing the number of first contours of any character with the number of second contours of any character; When the number of the first contours of any character is different from the number of the second contours of any character, determining that any character in the image to be detected is a defective character; When the number of the first contours of any character is the same as the number of the second contours of any character, it is determined that the any character in the image to be detected is a flawless character.

2. The printing defect detection method according to claim 1, characterized in that: The text segmentation process includes: The first position of each character in the flawless image is determined, and each character in the flawless image is segmented according to the first position of each character.

3. The printing defect detection method according to claim 1, characterized in that: According to the first image of each character, an image feature matching algorithm is used to obtain the second image of each character from the image to be detected.

4. The printing defect detection method according to claim 1, wherein: The image binarization process includes: performing image binarization according to a preset binarization threshold.

5. The printing defect detection method according to claim 1, characterized in that: The image thinning process includes: using an image thinning algorithm to thin the text outline.

6. The printing defect detection method according to claim 1, characterized in that: The step of obtaining the sixth image of any character based on the fourth image of any character and the fifth image of any character based on a bitwise AND operation includes: Perform a bitwise AND operation on the fourth image of any character and the fifth image of any character to obtain a mask image of the fourth image of any character and the fifth image of any character, and use the mask image as the sixth image of any character.

7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the printing defect detection method according to any one of claims 1 to 6 is implemented.

8. A computer device, characterized in that: The computer device includes a memory and at least one processor, wherein the memory stores at least one instruction, and when the at least one instruction is executed by the at least one processor, the printing defect detection method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Character defect detection method

    CN112763513A