Printed character defect detection method and device, electronic equipment and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-27
- Publication Date
- 2026-08-11
AI Technical Summary
为此,本申请提出一种印刷字符缺陷检测方法、装置、电子设备和存储介质,以解决无法精准确定缺陷信息的问题
第一获取模块,用于针对待检测图像执行分割操作,获取第一字符图像;
Smart Images

Figure CN122551366A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of printed character detection technology, and particularly relates to a method, apparatus, electronic device and storage medium for detecting defects in printed characters. Background Technology
[0002] During the character printing process, defects such as overprinting, underprinting, and black and white lines are inevitable due to malfunctions such as inkjet device blockage or dripping, which seriously affect the printing effect.
[0003] Generally, character inspection tools can be used to perform defect detection on characters. However, these tools can usually only determine whether a character has a defect, but cannot accurately determine the location, area, or other information about the defect, making it difficult to assist in subsequent defect processing. Summary of the Invention
[0004] This application aims to address at least one of the technical problems existing in the prior art. To this end, this application proposes a method, apparatus, electronic device, and storage medium for detecting defects in printed characters, to solve the problem of the inability to accurately determine defect information.
[0005] Firstly, this application provides a method for detecting defects in printed characters, including: Perform segmentation on the image to be detected to obtain the first character image; For each first character image, perform a binarization operation to obtain the second character image; Based on the template image corresponding to the second character image, defect detection is performed on the second character image to obtain defect information; the defect information includes defect type, defect region location, and defect region area.
[0006] According to the printing character defect detection method of this application, a first character image is obtained by performing a segmentation operation on the image to be detected; a second character image is obtained by performing a binarization operation on each first character image; and a defect detection is performed on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location, and defect region area. This allows for defect detection to be performed on each character in the image to be detected using the template image to obtain defect information such as defect type, defect region location, and defect region area, which is helpful for subsequent defect processing.
[0007] According to one embodiment of this application, for each first character image, a binarization operation is performed to obtain a second character image, including: For each first character image, a binarization operation is performed on the first character image based on a first operation threshold to obtain the third character image; If the character width of a character in the third character image is greater than or equal to the first width threshold, a binarization operation is performed on the third character image based on the second operation threshold to obtain the second character image; the second operation threshold is less than the first operation threshold.
[0008] According to one embodiment of this application, based on the template image corresponding to the second character image, defect detection is performed on the second character image to obtain defect information, including: Get the character width of the template image; For each pixel unit in the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width; the pixel unit can be a pixel row or a pixel column. Based on the defect detection strategy corresponding to the unit type, defect detection is performed on the second character image based on the number of pixels of the corresponding pixel unit in the second character image to obtain defect information.
[0009] According to one embodiment of this application, for each pixel unit of the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width, including: If the number of pixels in a pixel unit is less than or equal to the character width, the pixel unit is determined to be a first type unit; or If the number of pixels in a pixel unit is greater than the character width but less than twice the character width, the pixel unit is determined to be a second type of unit. or If the number of pixels in a pixel unit is greater than twice the character width, the pixel unit is determined to be a third type of unit.
[0010] According to one embodiment of this application, based on the defect detection strategy corresponding to the unit type, defect detection is performed on the second character image according to the number of pixels of the pixel unit at the corresponding position in the second character image to obtain defect information, including: Based on the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit, determine whether there is a defect in the pixel unit; In the case where at least one pixel unit in the second character image is defective, the defect type, defect region location, and defect region area are determined based on the pixel unit's location information and the number of pixels.
[0011] According to one embodiment of this application, after performing defect detection on the second character image based on the template image corresponding to the second character image, the method includes: If the second character image has defects, obtain the adjacent character images of the second character image; Defect verification is performed on the second character image based on adjacent character images; the defect verification is used to verify the authenticity of the second character image.
[0012] According to one embodiment of this application, defect verification is performed on a second character image based on adjacent character images, including: Obtain the overlapping area between the second character image and the adjacent character images; If the defect areas of the second character image and the adjacent character image are both located within the overlapping area, and the defect areas of the second character image and the adjacent character image overlap, then the defect verification result of the second character image is determined to be true.
[0013] Secondly, this application provides a printing character defect detection device, comprising: The first acquisition module is used to perform segmentation operations on the image to be detected to acquire the first character image; The operation module is used to perform a binarization operation on each first character image to obtain the second character image; The detection module is used to perform defect detection on the second character image based on the template image corresponding to the second character image, and obtain defect information; the defect information includes defect type, defect area location and defect area area.
[0014] According to the printed character defect detection device of this application, a first character image is obtained by performing a segmentation operation on the image to be detected; a second character image is obtained by performing a binarization operation on each first character image; and a defect detection is performed on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location, and defect region area. This allows for defect detection of each character in the image to be detected using the template image to obtain defect information such as defect type, defect region location, and defect region area, which is helpful for subsequent defect processing. Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the printing character defect detection method described in the first aspect.
[0015] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the printing character defect detection method of the first aspect described above.
[0016] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the printing character defect detection method described in the first aspect.
[0017] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0018] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is one of the flowcharts illustrating the printing character defect detection method provided in the embodiments of this application; Figure 2 This is a schematic diagram illustrating the process of detecting character defects using relevant technologies; Figure 3 This is a second schematic flowchart of the printing character defect detection method provided in the embodiments of this application; Figure 4 This is a schematic diagram of the printed character defect detection device provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0021] The following description, in conjunction with the accompanying drawings, details the printing character defect detection method, apparatus, electronic device, and storage medium provided in this application through specific embodiments and application scenarios.
[0022] Among them, the method for detecting defects in printed characters can be applied to a terminal, specifically executed by the hardware or software in the terminal.
[0023] The terminal includes, but is not limited to, portable communication devices such as mobile phones or tablets with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads). It should also be understood that, in some embodiments, the terminal may not be a portable communication device, but rather a desktop computer with touch-sensitive surfaces (e.g., touchscreen displays and / or touchpads).
[0024] The following embodiments describe a terminal including a display and a touch-sensitive surface. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and joystick.
[0025] The printing character defect detection method provided in this application embodiment can be executed by an electronic device or a functional module or entity in an electronic device that can implement the printing character defect detection method. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras, and wearable devices. The printing character defect detection method provided in this application embodiment is described below using an electronic device as the execution subject.
[0026] like Figure 1 As shown, the printed character defect detection method includes steps 110, 120 and 130.
[0027] Step 110: Perform a segmentation operation on the image to be detected to obtain the first character image.
[0028] In actual execution, the image to be detected can be an image of a printed product, and the image to be detected can include at least one printed character.
[0029] In some embodiments, the image to be detected can be acquired using an image acquisition device. The image acquisition device can be deployed at the finished product exit of the printing equipment, or any theoretically feasible location; this application does not impose specific limitations on this.
[0030] In actual execution, each first character image may include one character to be detected.
[0031] In some embodiments, each character to be detected in the image can be obtained based on an object detection algorithm, and a segmentation operation can be performed on each character to be detected based on a segmentation algorithm to obtain a first character image. The object detection algorithm can be the YOLO algorithm, SSD algorithm, R-CNN algorithm, or any theoretically feasible algorithm, and this application does not impose any specific limitations on it.
[0032] In actual execution, the number of first character images is at least 1.
[0033] Step 120: For each first character image, perform a binarization operation to obtain the second character image.
[0034] In some embodiments, after acquiring the first character image, a binarization operation can be performed on the first character image based on a preset binarization threshold to acquire the second character image.
[0035] In some embodiments, after performing a binarization operation, a binarization effect verification can be performed on the operation result. If the operation result passes the binarization effect verification, the operation result is determined as the second character image; if the operation result fails the binarization effect verification, the operation result is binarized again.
[0036] Step 130: Based on the template image corresponding to the second character image, perform defect detection on the second character image to obtain defect information; the defect information includes defect type, defect region location and defect region area.
[0037] In some embodiments, for each character, a template image for that character can be generated in advance. The template image can be an image that does not contain any defects.
[0038] In some embodiments, for each character, the template image of that character may include a standard character information set. This standard character information set includes information such as the character pixel start point, character pixel end point, number of character pixels, number of nearest minimum pixels, number of nearest maximum pixels, average grayscale value of the character pixels, and background grayscale value for each pixel row and each pixel column of that character. "Nearest" refers to the range of two pixels to the left and right of the current pixel row or column. For example, the number of nearest minimum pixels in the 10th column on the X-axis is the smallest number of pixels within columns 8 to 12.
[0039] In some embodiments, after acquiring the second character image, the character in the second character image can be determined based on a recognition algorithm, and a template image corresponding to that character can be obtained from a template library.
[0040] In some embodiments, defect detection can be performed on the corresponding pixel row in the second character image based on each pixel row in the template image, and / or on the corresponding pixel column in the second character image based on each pixel column in the template image, to obtain the defect type, defect region location, and defect region area.
[0041] In some embodiments, for each second character image, after obtaining the defect information of the second character image, the authenticity verification of the defect information can be performed to reduce false judgments and improve the accuracy and correctness of defect detection.
[0042] According to the printed character defect detection method of this application embodiment, a first character image is obtained by performing a segmentation operation on the image to be detected; a second character image is obtained by performing a binarization operation on each first character image; and a defect detection is performed on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location, and defect region area. The template image is used to perform defect detection on each character in the image to be detected to obtain defect information such as defect type, defect region location, and defect region area, so as to facilitate subsequent defect processing.
[0043] In some embodiments, for each first character image, a binarization operation is performed on the first character image based on a first operation threshold to obtain a third character image; if the character width of the character in the third character image is greater than or equal to a first width threshold, a binarization operation is performed on the third character image based on a second operation threshold to obtain a second character image; the second operation threshold is less than the first operation threshold.
[0044] In actual implementation, an automatic thresholding algorithm (i.e., the automatic Otsu algorithm) can be used to obtain the first and second operation thresholds. Both the first and second operation thresholds can be binarized thresholds.
[0045] In practice, character width characterizes the thickness of the strokes of a character in a character image. For example, character width can be the average number of character pixels across all pixel rows in a character image.
[0046] In actual execution, the first width threshold can be a preset value.
[0047] In some embodiments, if the character width of a character in the third character image is greater than or equal to a first width threshold, a binarization operation is performed on the third character image. For example, if the first width threshold is 3.5 and the character width of a character in the third character image is 4, a binarization operation is performed on the third character image.
[0048] In some embodiments, if the character width of a character in a third character image is less than a first width threshold, the third character image is determined to be the second character image.
[0049] According to the printed character defect detection method of this application embodiment, a first character image is obtained by performing a segmentation operation on the image to be detected; for each first character image, a binarization operation is performed on the first character image based on a first operation threshold to obtain a third character image; if the character width of the character in the third character image is greater than or equal to a first width threshold, a binarization operation is performed on the third character image based on a second operation threshold to obtain a second character image; based on the template image corresponding to the second character image, defect detection is performed on the second character image to obtain defect information such as defect type, defect region location, and defect region area, so as to effectively highlight the defects of the characters in the image through multiple binarization operations and avoid excessive pixel interference caused by image affine sampling.
[0050] In some embodiments, the character width of the template image is obtained; for each pixel unit of the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width; the pixel unit is a pixel row or a pixel column; according to the defect detection strategy corresponding to the unit type, defect detection is performed on the second character image based on the number of pixels in the corresponding pixel unit in the second character image to obtain defect information.
[0051] In actual execution, the cell type of a pixel unit can characterize the thickness of the strokes within that pixel unit.
[0052] In some embodiments, each unit type corresponds to a defect metric. Therefore, for each pixel unit, defect detection can be performed on the second character image based on the defect detection strategy corresponding to the unit type of that pixel unit.
[0053] In some embodiments, for each pixel unit of the template image, a defect detection strategy corresponding to the unit type can be used to detect the number of pixels of the corresponding pixel unit in the second character image based on the standard character information set of the pixel unit, determine whether the pixel unit is abnormal, and if the pixel unit is abnormal, obtain defect information such as defect type, defect area location and defect area.
[0054] According to the printed character defect detection method of this application embodiment, the character width of the template image is obtained; for each pixel unit of the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width; the pixel unit is a pixel row or pixel column; according to the defect detection strategy corresponding to the unit type, based on the number of pixels in the corresponding pixel unit in the second character image, defect detection is performed on the second character image to obtain defect information such as defect type, defect area location and defect area, so as to perform defect detection on each character in the image to be detected through the template image and obtain defect information such as defect type, defect area location and defect area, so as to facilitate subsequent defect processing.
[0055] In some embodiments, if the number of pixels in a pixel unit is less than or equal to the character width, the pixel unit is determined to be a first type of unit; or if the number of pixels in a pixel unit is greater than the character width but less than twice the character width, the pixel unit is determined to be a second type of unit; or if the number of pixels in a pixel unit is greater than twice the character width, the pixel unit is determined to be a third type of unit.
[0056] In some embodiments, for each pixel unit in the template image, if the number of pixels in the pixel unit is less than or equal to the character width, it indicates that the character stroke represented by the pixel unit is thinner than the average stroke thickness of the character (e.g., the tip of radicals such as left-falling stroke and right-falling stroke in the character), and the pixel unit is determined to be a first type of unit.
[0057] In some embodiments, for each pixel unit in the template image, the number of pixels in the pixel unit is greater than the character width but less than twice the character width, indicating that the character stroke represented by the pixel unit is thicker than the average stroke thickness of the character, but thinner than the stroke thickness of the third type of unit.
[0058] In some embodiments, for each pixel unit in the template image, if the number of pixels in the pixel unit is greater than twice the character width, it indicates that the character stroke represented by the pixel unit is thicker than the stroke thickness of the second type of unit (e.g., character folds, hooks, etc.).
[0059] In some embodiments, the presence of a defect in a pixel unit is determined based on the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit; if at least one pixel unit in the second character image has a defect, the defect type, defect region location, and defect region area are determined based on the position information and number of pixels of the pixel unit.
[0060] In some embodiments, for each pixel unit, if the pixel unit is of the first type and the number of pixel units at the corresponding position in the second character image is less than 1 (i.e., the character strokes in the second character image are truncated by white lines), the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit is of the first type and the number of character pixels of the pixel unit at the corresponding position in the second character image is greater than or equal to 3.5 times the number of character pixels of the pixel unit in the template image (i.e., the character strokes in the second character image are truncated by black lines), the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0061] In some embodiments, for each pixel unit, if the pixel unit's unit type is a second type unit and the number of character pixels of the corresponding pixel unit in the second character image is less than 0.3 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit's unit type is a second type unit and the number of character pixels of the corresponding pixel unit in the second character image is greater than or equal to 2.5 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0062] In some embodiments, for each pixel unit, if the pixel unit's unit type is a third type unit and the number of character pixels of the corresponding pixel unit in the second character image is less than 0.5 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit's unit type is a third type unit and the number of character pixels of the corresponding pixel unit in the second character image is greater than or equal to twice the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0063] According to the printed character defect detection method of this application embodiment, the character width of the template image is obtained; for each pixel unit of the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width; the pixel unit is a pixel row or pixel column; according to the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit, it is determined whether the pixel unit has a defect; if at least one pixel unit in the second character image has a defect, the defect type, defect area location and defect area are determined based on the position information and number of pixels of the pixel unit, so as to perform defect detection on each character in the image to be detected through the template image and obtain defect information such as defect type, defect area location and defect area, so as to facilitate subsequent defect processing.
[0064] In some embodiments, after performing defect detection on the second character image based on the template image corresponding to the second character image, if the second character image has defects, the adjacent character images of the second character image are obtained; defect verification is performed on the second character image based on the adjacent character images; the defect verification is used to verify the authenticity of the second character image.
[0065] In related technologies, such as Figure 2 As shown, when performing defect detection on the "4" in the image to be detected, a "black line defect" is detected because the detection box includes part of "E", but in fact, this defect is not a real defect.
[0066] In actual execution, for each second character image, the adjacent character image is the image of the character that is to the left and / or right of the character in that second character image.
[0067] In some embodiments, if the second character image has a defect, the overlapping area between the second character image and the adjacent character image is obtained, and the defect verification of the second character image is performed based on the overlapping area.
[0068] According to the printed character defect detection method of this application, a first character image is obtained by performing a segmentation operation on the image to be detected; a second character image is obtained by performing a binarization operation on each first character image; a defect detection is performed on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location and defect region area; if the second character image has defects, adjacent character images of the second character image are obtained; a defect verification is performed on the second character image based on the adjacent character images; the defect verification is used to verify the authenticity of the second character image to reduce false judgments and improve the accuracy and correctness of defect detection.
[0069] In some embodiments, the overlapping area between the second character image and the adjacent character image is obtained; if the defect areas of the second character image and the adjacent character image are both located within the overlapping area, and the defect areas of the second character image and the adjacent character image overlap, the defect verification result of the second character image is determined to be true.
[0070] In some embodiments, for a second character image and an adjacent character image, if the ratio of the intersection area of the defective region and the overlapping region of the character image to the area of the overlapping region is greater than or equal to a first area ratio threshold, the defective region of the character image is determined to be located within the overlapping region. For example, if the first area ratio threshold is 0.75, the intersection area of the defective region and the overlapping region of the second character image is 88, and the area of the overlapping region is 100, the defective region of the second character image is determined to be located within the overlapping region.
[0071] In some embodiments, if the ratio of the intersection area of the defective regions of the second character image and the adjacent character image to the union area of the defective regions of the second character image and the adjacent character image is greater than or equal to a second area ratio threshold, it is determined that the defective regions of the second character image and the adjacent character image overlap. For example, if the second area ratio threshold is 0.65, the intersection area of the defective regions of the second character image and the adjacent character image is 75, and the union area of the defective regions of the second character image and the adjacent character image is 100, it is determined that the defective regions of the second character image and the adjacent character image overlap.
[0072] In some embodiments, if the defect verification result of the second character image is determined to be true, the union region of the defect regions of the second character image and the adjacent character images can be updated as the defect region.
[0073] In some embodiments, if at least one of the defect regions of the second character image and the adjacent character image is not located in the overlapping region, or if the defect regions of the second character image and the adjacent character image do not overlap, the defect verification result of the second character image is determined to be false, and the defect information of the second character image is deleted.
[0074] According to the printed character defect detection method of this application, a first character image is obtained by performing a segmentation operation on the image to be detected; a second character image is obtained by performing a binarization operation on each first character image; a defect detection is performed on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location and defect region area; if the second character image has defects, adjacent character images of the second character image are obtained; a defect verification is performed on the second character image based on the adjacent character images; the defect verification is used to verify the authenticity of the second character image to reduce false judgments and improve the accuracy and correctness of defect detection.
[0075] To better understand the printing character defect detection method provided in the embodiments of this application, further explanation is provided below. It should be understood that the following discussion is merely exemplary.
[0076] This application provides a method for detecting defects in printed characters, the specific steps of which are as follows: Figure 3 As shown: Step 310: Perform a segmentation operation on the image to be detected to obtain the first character image.
[0077] In actual execution, the image to be detected can be an image of a printed product, and the image to be detected can include at least one printed character.
[0078] In some embodiments, the image to be detected can be acquired using an image acquisition device. The image acquisition device can be deployed at the finished product exit of the printing equipment, or any theoretically feasible location; this application does not impose specific limitations on this.
[0079] In actual execution, each first character image may include one character to be detected.
[0080] In some embodiments, each character to be detected in the image can be obtained based on an object detection algorithm, and a segmentation operation can be performed on each character to be detected based on a segmentation algorithm to obtain a first character image. The object detection algorithm can be the YOLO algorithm, SSD algorithm, R-CNN algorithm, or any theoretically feasible algorithm, and this application does not impose any specific limitations on it.
[0081] In actual execution, the number of first character images is at least 1.
[0082] Step 320: For each first character image, perform a binarization operation on the first character image based on a first operation threshold to obtain a third character image; if the character width of the character in the third character image is greater than or equal to a first width threshold, perform a binarization operation on the third character image based on a second operation threshold to obtain a second character image; the second operation threshold is less than the first operation threshold.
[0083] In actual implementation, an automatic thresholding algorithm (i.e., the automatic Otsu algorithm) can be used to obtain the first and second operation thresholds. Both the first and second operation thresholds can be binarized thresholds.
[0084] In practice, character width characterizes the thickness of the strokes of a character in a character image. For example, character width can be the average number of character pixels across all pixel rows in a character image.
[0085] In actual execution, the first width threshold can be a preset value.
[0086] In some embodiments, if the character width of a character in the third character image is greater than or equal to a first width threshold, a binarization operation is performed on the third character image. For example, if the first width threshold is 3.5 and the character width of a character in the third character image is 4, a binarization operation is performed on the third character image.
[0087] In some embodiments, if the character width of a character in a third character image is less than a first width threshold, the third character image is determined to be the second character image.
[0088] Step 330: Obtain the template image of the second character image.
[0089] In some embodiments, for each character, a template image for that character can be generated in advance. The template image can be an image that does not contain any defects.
[0090] In some embodiments, for each character, the template image of that character may include a standard character information set. This standard character information set includes information such as the character pixel start point, character pixel end point, number of character pixels, number of nearest minimum pixels, number of nearest maximum pixels, average grayscale value of the character pixels, and background grayscale value for each pixel row and each pixel column of that character. "Nearest" refers to the range of two pixels to the left and right of the current pixel row or column. For example, the number of nearest minimum pixels in the 10th column on the X-axis is the smallest number of pixels within columns 8 to 12.
[0091] In some embodiments, after acquiring the second character image, the character in the second character image can be determined based on a recognition algorithm, and a template image corresponding to that character can be obtained from a template library.
[0092] In some embodiments, defect detection can be performed on the corresponding pixel row in the second character image based on each pixel row in the template image, and / or on the corresponding pixel column in the second character image based on each pixel column in the template image, to obtain the defect type, defect region location, and defect region area.
[0093] Step 340: If the number of pixels in a pixel unit is less than or equal to the character width, determine the pixel unit as a first type unit; or if the number of pixels in a pixel unit is greater than the character width but less than twice the character width, determine the pixel unit as a second type unit; or if the number of pixels in a pixel unit is greater than twice the character width, determine the pixel unit as a third type unit.
[0094] In actual execution, the cell type of a pixel unit can characterize the thickness of the strokes within that pixel unit.
[0095] In some embodiments, for each pixel unit in the template image, if the number of pixels in the pixel unit is less than or equal to the character width, it indicates that the character stroke represented by the pixel unit is thinner than the average stroke thickness of the character (e.g., the tip of radicals such as left-falling stroke and right-falling stroke in the character), and the pixel unit is determined to be a first type of unit.
[0096] In some embodiments, for each pixel unit in the template image, the number of pixels in the pixel unit is greater than the character width but less than twice the character width, indicating that the character stroke represented by the pixel unit is thicker than the average stroke thickness of the character, but thinner than the stroke thickness of the third type of unit.
[0097] In some embodiments, for each pixel unit in the template image, if the number of pixels in the pixel unit is greater than twice the character width, it indicates that the character stroke represented by the pixel unit is thicker than the stroke thickness of the second type of unit (e.g., character folds, hooks, etc.).
[0098] Step 350: Determine whether a pixel unit has a defect based on the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit; if at least one pixel unit in the second character image has a defect, determine the defect type, defect area location, and defect area area based on the pixel unit's location information and the number of pixels.
[0099] In some embodiments, for each pixel unit, if the pixel unit is of the first type and the number of pixel units at the corresponding position in the second character image is less than 1 (i.e., the character strokes in the second character image are truncated by white lines), the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit is of the first type and the number of character pixels of the pixel unit at the corresponding position in the second character image is greater than or equal to 3.5 times the number of character pixels of the pixel unit in the template image (i.e., the character strokes in the second character image are truncated by black lines), the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0100] In some embodiments, for each pixel unit, if the pixel unit's unit type is a second type unit and the number of character pixels of the corresponding pixel unit in the second character image is less than 0.3 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit's unit type is a second type unit and the number of character pixels of the corresponding pixel unit in the second character image is greater than or equal to 2.5 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0101] In some embodiments, for each pixel unit, if the pixel unit's unit type is a third type unit and the number of character pixels of the corresponding pixel unit in the second character image is less than 0.5 times the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a white line defect. If the pixel unit's unit type is a third type unit and the number of character pixels of the corresponding pixel unit in the second character image is greater than or equal to twice the number of character pixels of the pixel unit in the template image, then the pixel unit is determined to have a defect, and the defect type is determined to be a black line defect.
[0102] Step 360: Obtain the overlapping area between the second character image and the adjacent character image; if the defect areas of the second character image and the adjacent character image are both located within the overlapping area, and the defect areas of the second character image and the adjacent character image overlap, determine that the defect verification result of the second character image is true.
[0103] In actual execution, for each second character image, the adjacent character image is the image of the character that is to the left and / or right of the character in that second character image.
[0104] In some embodiments, for a second character image and an adjacent character image, if the ratio of the intersection area of the defective region and the overlapping region of the character image to the area of the overlapping region is greater than or equal to a first area ratio threshold, the defective region of the character image is determined to be located within the overlapping region. For example, if the first area ratio threshold is 0.75, the intersection area of the defective region and the overlapping region of the second character image is 88, and the area of the overlapping region is 100, the defective region of the second character image is determined to be located within the overlapping region.
[0105] In some embodiments, if the ratio of the intersection area of the defective regions of the second character image and the adjacent character image to the union area of the defective regions of the second character image and the adjacent character image is greater than or equal to a second area ratio threshold, it is determined that the defective regions of the second character image and the adjacent character image overlap. For example, if the second area ratio threshold is 0.65, the intersection area of the defective regions of the second character image and the adjacent character image is 75, and the union area of the defective regions of the second character image and the adjacent character image is 100, it is determined that the defective regions of the second character image and the adjacent character image overlap.
[0106] In some embodiments, if the defect verification result of the second character image is determined to be true, the union region of the defect regions of the second character image and the adjacent character images can be updated as the defect region.
[0107] In some embodiments, if at least one of the defect regions of the second character image and the adjacent character image is not located in the overlapping region, or if the defect regions of the second character image and the adjacent character image do not overlap, the defect verification result of the second character image is determined to be false, and the defect information of the second character image is deleted.
[0108] This application also provides a printing character defect detection device.
[0109] like Figure 4 As shown, the printed character defect detection device 400 includes: a first acquisition module 410, an operation module 420, and a detection module 430.
[0110] The first acquisition module 410 is used to perform a segmentation operation on the image to be detected to acquire a first character image; Operation module 420 is used to perform binarization operation on each first character image to obtain the second character image; The detection module 430 is used to perform defect detection on the second character image based on the template image corresponding to the second character image, and obtain defect information; the defect information includes defect type, defect area location and defect area area.
[0111] According to the embodiments of this application, the printed character defect detection device obtains a first character image by performing a segmentation operation on the image to be detected; performs a binarization operation on each first character image to obtain a second character image; and performs defect detection on the second character image based on the template image corresponding to the second character image to obtain defect information such as defect type, defect region location, and defect region area. This allows for defect detection of each character in the image to be detected using the template image, obtaining defect information such as defect type, defect region location, and defect region area, which facilitates subsequent defect processing.
[0112] In some embodiments, the operation module 420 includes: The first acquisition unit is used to perform a binarization operation on each first character image based on a first operation threshold to acquire a third character image; The second acquisition unit is used to perform a binarization operation on the third character image based on a second operation threshold to acquire the second character image when the character width of the character in the third character image is greater than or equal to a first width threshold; the second operation threshold is less than the first operation threshold.
[0113] In some embodiments, the detection module 430 includes: The third acquisition unit is used to acquire the character width of the template image; The first determining unit is used to determine the unit type of each pixel unit in the template image based on the number of pixels in the pixel unit and the character width; the pixel unit can be a pixel row or a pixel column. The detection unit is used to perform defect detection on the second character image based on the number of pixels of the pixel unit at the corresponding position in the second character image, according to the defect detection strategy corresponding to the unit type, and to obtain defect information.
[0114] In some embodiments, the first determining unit is configured to: If the number of pixels in a pixel unit is less than or equal to the character width, the pixel unit is determined to be a first type unit; or If the number of pixels in a pixel unit is greater than the character width but less than twice the character width, the pixel unit is determined to be a second type of unit. or If the number of pixels in a pixel unit is greater than twice the character width, the pixel unit is determined to be a third type of unit.
[0115] In some embodiments, the detection unit is used for: Based on the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit, determine whether there is a defect in the pixel unit; In the case where at least one pixel unit in the second character image is defective, the defect type, defect region location, and defect region area are determined based on the pixel unit's location information and the number of pixels.
[0116] In some embodiments, the printed character defect detection device 400 further includes: The second acquisition module is used to acquire adjacent character images of the second character image when the second character image has defects; The verification module is used to perform defect verification on the second character image based on adjacent character images; the defect verification is used to verify the authenticity of the second character image.
[0117] In some embodiments, the verification module includes: The fourth acquisition unit is used to acquire the overlapping area between the second character image and the adjacent character image; The second determining unit determines that the defect verification result of the second character image is true when the defect areas of the second character image and the adjacent character image are both located in overlapping areas and the defect areas of the second character image and the adjacent character image overlap.
[0118] The printed character defect detection device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.
[0119] The printed character defect detection device in this application embodiment can be a device with an operating system. This operating system can be a Microsoft (Windows) operating system, an Android operating system, an iOS operating system, or other possible operating systems; this application embodiment does not specifically limit it.
[0120] The printed character defect detection device 400 provided in this application embodiment can achieve... Figures 1 to 3 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0121] In some embodiments, such as Figure 5 As shown, this application embodiment also provides an electronic device 500, including a processor 501, a memory 502, and a computer program stored in the memory 502 and executable on the processor 501. When the program is executed by the processor 501, it implements the various processes of the above-described printing character defect detection method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0122] It should be noted that the computer equipment in this application embodiment includes the mobile electronic equipment and non-mobile electronic equipment described above.
[0123] This application also provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described printing character defect detection method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0124] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0125] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for detecting defects in printed characters.
[0126] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0127] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described printing character defect detection method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0128] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0129] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0131] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0132] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0133] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for detecting defects in printed characters, characterized in that, include: Perform segmentation on the image to be detected to obtain the first character image; For each of the first character images, perform a binarization operation to obtain the second character image; Based on the template image corresponding to the second character image, perform defect detection on the second character image to obtain defect information; The defect information includes the defect type, the location of the defect area, and the area of the defect area.
2. The method for detecting defects in printed characters according to claim 1, characterized in that, The step of performing a binarization operation on each of the first character images to obtain the second character image includes: For each of the first character images, a binarization operation is performed on the first character image based on a first operation threshold to obtain the third character image; If the character width of a character in the third character image is greater than or equal to a first width threshold, a binarization operation is performed on the third character image based on a second operation threshold to obtain a second character image; the second operation threshold is less than the first operation threshold.
3. The method for detecting defects in printed characters according to claim 1, characterized in that, The step of performing defect detection on the second character image based on the template image corresponding to the second character image to obtain defect information includes: Get the character width of the template image; For each pixel unit of the template image, the unit type of the pixel unit is determined based on the number of pixels in the pixel unit and the character width; the pixel unit is either a pixel row or a pixel column. Based on the defect detection strategy corresponding to the unit type, defect detection is performed on the second character image according to the number of pixels of the pixel unit at the corresponding position in the second character image to obtain defect information.
4. The method for detecting defects in printed characters according to claim 3, characterized in that, For each pixel unit of the template image, determining the unit type of the pixel unit based on the number of pixels in the pixel unit and the character width includes: If the number of pixels in the pixel unit is less than or equal to the character width, the pixel unit is determined to be a first type unit; or If the number of pixels in the pixel unit is greater than the character width but less than twice the character width, the pixel unit is determined to be a second type unit. or If the number of pixels in the pixel unit is greater than twice the character width, the pixel unit is determined to be a third type unit.
5. The method for detecting defects in printed characters according to claim 3, characterized in that, The step of performing defect detection on the second character image based on the number of pixels of the pixel unit at the corresponding position in the second character image, according to the defect detection strategy corresponding to the unit type, and obtaining defect information, includes: Based on the defect detection strategy corresponding to the unit type and the number of pixels in the pixel unit, determine whether the pixel unit has a defect; In the case where at least one of the pixel units in the second character image is defective, the defect type, defect region location, and defect region area are determined based on the position information of the pixel unit and the number of pixels.
6. The method for detecting defects in printed characters according to any one of claims 1-5, characterized in that, After performing defect detection on the second character image based on the template image corresponding to the second character image, the method includes: If the second character image has a defect, obtain the adjacent character images of the second character image; Defect verification is performed on the second character image based on the adjacent character images; the defect verification is used to verify the authenticity of the second character image.
7. The method for detecting defects in printed characters according to claim 6, characterized in that, Perform defect verification on the second character image based on the adjacent character images, including: Obtain the overlapping area between the second character image and the adjacent character image; If the defect regions of the second character image and the adjacent character image are both located within the overlapping region, and the defect regions of the second character image and the adjacent character image overlap, then the defect verification result of the second character image is determined to be true.
8. A printing character defect detection device, characterized in that, include: The first acquisition module is used to perform segmentation operations on the image to be detected to acquire the first character image; The operation module is used to perform a binarization operation on each of the first character images to obtain the second character image; The detection module is used to perform defect detection on the second character image based on the template image corresponding to the second character image, and obtain defect information; The defect information includes the defect type, the location of the defect area, and the area of the defect area.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the printed character defect detection method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the printed character defect detection method according to any one of claims 1-7.