Image defect detection method and device and computer readable storage medium

The gradient integral projection method detects the module connection position in the image, analyzes the peak and trough distributions, solves the problem of high cost of image ghost detection and achieves efficient and accurate ghost detection.

CN119919346APending Publication Date: 2025-05-02ZHEJIANG HUARAY TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411780181.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, the ghosting problem caused by improper printing methods or machine failures during image printing or printing process requires manual quality inspection and removal, resulting in high labor and time costs.

Method used

The gradient integral projection method is used to detect the connection positions of modules between two adjacent modules of different colors. By analyzing the peak and trough distributions of the gradient integral projection curve, we can judge whether there is ghosting in the image.

Benefits of technology

It realizes efficient detection of image ghosting, reduces the cost and time of manual quality inspection, and improves detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919346A_ABST
    Figure CN119919346A_ABST
Patent Text Reader

Abstract

The invention discloses an image defect detection method and device and a computer readable storage medium, and the method comprises the steps: obtaining a to-be-detected image, the to-be-detected image comprises a plurality of modules, the modules comprise a first color module and a second color module, and the first color and the second color are two different colors; and detecting a module connection position between two adjacent modules with different colors by using a gradient integral projection method to obtain a defect detection result that whether the to-be-detected image has ghosting or not. In this way, efficient detection of ghosting can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image defect detection method, device and computer-readable storage medium. Background Art

[0002] During the image printing or engraving process, the printed or engraved image may have ghosting problems due to improper printing or engraving methods or machine failure. This ghosting problem will affect the effective storage and normal recognition of the information in the image, so it is necessary to inspect and eliminate such images with ghosting defects.

[0003] Currently, image ghosting requires manual quality inspection and elimination, which results in high labor and time costs. Therefore, how to achieve efficient ghosting detection has become an urgent problem to be solved. Summary of the invention

[0004] The present application provides an image defect detection method, device and computer-readable storage medium, which can realize efficient ghosting detection.

[0005] In order to solve the above technical problems, the technical solution adopted in the present application is: to provide an image defect detection method, the method comprising: obtaining an image to be detected, the image to be detected comprising a plurality of modules, the modules comprising a first color module and a second color module, the first color and the second color being two different colors; using a gradient integral projection method to detect the module connection position between two adjacent modules of different colors, and obtaining a defect detection result of whether there is a ghosting in the image to be detected.

[0006] In some embodiments, the use of the gradient integral projection method to detect the module connection position between two adjacent modules of different colors to obtain a defect detection result of whether the image to be detected has ghosting includes: determining a first value interval based on the positions of the two adjacent modules of different colors in the image to be detected, and obtaining a first gradient integral projection operation area; using the first value interval and the first gradient integral projection operation area to perform gradient integral projection on the module connection position in a first direction to obtain a first gradient integral projection curve, wherein the first direction is a direction perpendicular to the ghosting detection direction; based on the distribution of peaks and troughs of the first gradient integral projection curve, using first ghosting position information corresponding to several module connection positions that meet a first preset ghosting feature condition as a defect detection result of the existence of a ghosting problem in the image to be detected, wherein the first preset ghosting feature condition is detecting that at least one trough exists between two peaks, or at least one peak exists between two troughs.

[0007] In some embodiments, the first ghosting position information includes a ghosting interval distance and an end of a ghosting area. After the first ghosting position information corresponding to a number of module connection positions that satisfy a first preset ghosting characteristic condition is obtained, and before the defect detection result that the image to be detected has a ghosting problem is obtained, the method further includes: obtaining a second value interval and a second gradient integral projection operation area based on the positions of the two adjacent modules of different colors in the image to be detected and the ghosting interval distance; performing a gradient integral projection in a second direction on the end of the ghosting area using the second value interval and the second gradient integral projection operation area to obtain a second gradient integral projection curve, wherein the second direction is a direction parallel to the ghosting detection direction; based on the distribution of peaks and troughs of the second gradient integral projection curve, excluding the first ghosting position information that does not satisfy the second preset ghosting characteristic condition from the first ghosting position information, determining a number of second ghosting position information where ghosting exists, and obtaining a defect detection result that the image to be detected has a ghosting problem, wherein the second preset ghosting characteristic condition is that there are two adjacent troughs in the second gradient integral projection curve.

[0008] In some embodiments, after determining that a number of second ghost position information indicating the existence of ghosting is obtained, the method further includes: marking the number of second ghost position information in the image to be detected, and counting the number of the second ghost position information in each first direction in the image to be detected; in response to the number of the second ghost position information being greater than or equal to a preset statistical number, determining that the image to be detected has ghosting, and obtaining a defect detection result indicating that the image to be detected has a ghosting problem.

[0009] In some embodiments, based on the distribution of wave crests and wave troughs of the first gradient integral projection curve, the first ghosting position information corresponding to the plurality of the module connection positions satisfying the first preset ghosting characteristic condition is used as the defect detection result of the image to be detected having a ghosting problem. Before the defect detection result, the method further includes: smoothing and / or filtering the first gradient integral projection curve; and / or, based on the distribution of wave crests and wave troughs of the second gradient integral projection curve, excluding the first ghosting position information that does not satisfy the second preset ghosting characteristic condition from the first ghosting position information, determining a plurality of second ghosting position information that have ghosting as the defect detection result of the image to be detected having a ghosting problem. Before the defect detection result, the method further includes: filtering the first gradient integral projection curve; and / or filtering the first ghosting position information that does not satisfy the second preset ghosting characteristic condition from the first ghosting position information. The method comprises: smoothing and / or filtering the gradient integral projection curve; and / or, before using the first value interval and the first gradient integral projection operation area to perform gradient integral projection in a first direction on the module connection position, the method comprises: determining the width of the module as the width of the first gradient integral projection operation area, and determining a preset proportional multiple of the width of the module as the height of the first gradient integral projection operation area; and / or, obtaining the second value interval and the second gradient integral projection operation area based on the positions of the two adjacent modules of different colors in the image to be detected and the ghost interval distance, comprising: using the ghost interval distance as the height of the first gradient integral projection operation area, and using half of the width of the module as the width of the first gradient integral projection operation area.

[0010] In some embodiments, before the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method to obtain the defect detection result of whether the image to be detected has ghosting, the method also includes: obtaining a first grayscale average value of all the first color modules, a second grayscale average value of all the second color modules, and a first grayscale difference between the first grayscale average value and the second grayscale average value; judging whether the first grayscale difference is less than a first preset grayscale difference; if so, obtaining a defect detection result that the image to be detected has a contrast problem; if not, executing the module connection position between two adjacent modules of different colors by using the gradient integral projection method The method further comprises: detecting the connection position of the module between two adjacent modules of different colors by using the gradient integral projection method, and / or obtaining the defect detection result of whether the image to be detected has ghosting, the method further comprises: obtaining the minimum grayscale value of the first color module and the maximum grayscale value of the second color module, and a second grayscale difference between the minimum grayscale value and the maximum grayscale value; determining whether the second grayscale difference is less than a second preset grayscale difference; if so, obtaining the defect detection result of the misalignment problem of the image to be detected; if not, executing the detection of the module connection position between two adjacent modules of different colors by using the gradient integral projection method.

[0011] In some embodiments, obtaining the first grayscale average value of all the first color modules and the second grayscale average value of all the second color modules includes: based on the number of modules in the image to be detected, dividing the image to be detected into equal intervals to obtain the image area of ​​each module, and calculating the grayscale value of each module; calculating the grayscale average value of the image area corresponding to all the first color modules as the first grayscale average value, and calculating the grayscale average value of the image area corresponding to all the second color modules as the second grayscale average value.

[0012] In some embodiments, the image to be detected is a two-dimensional code, and obtaining the image to be detected includes: obtaining an original image; identifying the original image using a two-dimensional code recognition algorithm to detect whether the two-dimensional code exists in the original image; if not, terminating the execution of the image defect detection method; if yes, obtaining four vertex coordinates of the two-dimensional code, and calculating the affine transformation matrix of the two-dimensional code based on the four vertex coordinates, and correcting the barcode area of ​​the two-dimensional code using the affine transformation matrix to obtain the image to be detected; and / or, the first color module is a white module, the second color module is a black module, and the image to be detected is an image of a white background with black code, after correcting the barcode area of ​​the two-dimensional code using the affine transformation matrix, the method also includes: if it is detected that the corrected two-dimensional code is an image of a black background with white code, then the image of the black background with white code is inverted to obtain the image to be detected; and / or, the image to be detected includes a quiet zone area, and the quiet zone area is a white background area extended outside the boundary of the two-dimensional code.

[0013] In order to solve the above-mentioned technical problems, another technical solution adopted in the present application is: to provide an image ghosting detection device, which includes a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image defect detection method in the above-mentioned technical solution.

[0014] In order to solve the above technical problems, another technical solution adopted in the present application is: providing a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the image defect detection method in the above technical solution.

[0015] Through the above scheme, the beneficial effect of the present application is: since the modules in the image to be detected include modules of two colors, the first color module and the second color module, there may be ghosting between the two modules of different colors. The present application uses the gradient integral projection method to detect the module connection position between two adjacent modules of different colors, and obtains the defect detection result of whether there is ghosting in the image to be detected, thereby realizing efficient detection of image ghosting through the gradient integral projection technology. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:

[0017] Figure 1a-1dIt is a schematic diagram of the engraving process;

[0018] Figure 2 It is a flow chart of an embodiment of an image defect detection method provided by the present application;

[0019] Figure 3 It is a flowchart of step S11 in an embodiment of the image defect detection method provided by the present application;

[0020] Figure 4 This application provides Figure 3 Schematic diagram of the effect of step S114 in the embodiment of the image defect detection method;

[0021] Figure 5 It is a flowchart of another embodiment of the image defect detection method provided by the present application;

[0022] Figure 6 A schematic diagram of the first and second gradient integral projection operation areas in step S22 of another embodiment of the image defect detection method provided by the present application;

[0023] Figure 7a and Figure 7b This is a schematic diagram of ghosting in another embodiment of the image defect detection method provided by the present application. Figure 7c and Figure 7d In another embodiment of the image defect detection method provided by the present application Figure 7a and Figure 7b A schematic diagram of a first gradient integral projection curve corresponding to a ghost;

[0024] Figure 8 It is a flowchart of another embodiment of the image defect detection method provided by the present application;

[0025] Fig. 9 It is a flow chart of an application embodiment of an image defect detection method provided by the present application;

[0026] Fig.10 It is a structural schematic diagram of an embodiment of an image defect detection device provided by the present application;

[0027] Fig.11 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION

[0028] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0029] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0030] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.

[0031] Since there may be ghosting between two modules of different colors, this application is applicable to all images to be detected composed of modules of different colors, including but not limited to barcode images such as one-dimensional codes and two-dimensional codes. Taking the image to be detected as a two-dimensional code as an example, a two-dimensional code is a graphic that uses a certain geometric figure to be distributed in a two-dimensional plane direction according to a certain rule, with white and black modules and black modules alternating in black and white, and records data symbol information. In the compilation of the code, the two-dimensional code cleverly uses the concept of "0" and "1" bit streams that constitute the internal logic basis of the computer, and uses a number of geometric shapes corresponding to binary to represent text numerical information, which is automatically read by an image input device or an optoelectronic scanning device to realize automatic information processing. The two-dimensional code has the characteristics of large storage capacity, high confidentiality, high traceability, strong damage resistance, large backup, and low cost. These characteristics are particularly suitable for forms, confidentiality, tracking, certificates, inventory counting, data backup, etc. However, in the process of engraving the two-dimensional code, the engraved two-dimensional code may have defects due to improper engraving methods or malfunctions in the engraving machine, such as scratches, distortion, ghosting and other engraving defects. This printing defect problem will affect the effective storage of the coded information in the barcode and the normal recognition of the barcode, and directly affect the meaning of the barcode printing. Therefore, it is necessary to detect and remove the barcode with printing defects to prevent the barcode with printing defects from flowing into the next processing step and wasting production costs. Figure 1a-1d , Figure 1a-1dThe following is a flow chart of the engraving process. Taking the QR code as an example, the engraving method of the QR code includes two steps. The first step is to draw a frame, that is, to divide the QR code into regions by drawing a frame. Each region corresponds to a module, and the image regions of several modules are obtained to obtain an unfilled QR code. Figure 1a As shown; Step 2: Filling, that is, filling the modules of the QR code with color one by one, such as Figure 1b As shown in FIG. 1 , a two-dimensional code without ghosting or a two-dimensional code with ghosting may be obtained in the end. Figure 1c As shown; there are ghosted QR codes, such as Figure 1d Especially when the repetitive accuracy of the QR code engraving machine is abnormal, the engraving positions of the first step of drawing the frame and the second step of filling will be offset, resulting in the engraved QR code having an engraved double image. The technical solution of this application is described in detail below:

[0032] See also Figure 2 , Figure 2 : is a flow chart of an embodiment of an image defect detection method provided by the present application, the method comprising:

[0033] S11: Acquire the image to be detected.

[0034] The image to be detected includes several modules, and the modules include a first color module and a second color module, wherein the first color and the second color are two different colors. Since the colors of the first color module and the second color module in the image to be detected are different, when the two are arranged adjacently, there may be ghosting at the module connection position between the two modules with different colors. Therefore, it is necessary to detect whether there is ghosting in the image to be detected. The acquisition method of the image to be detected can be obtained from several images to be detected pre-stored in the image database, or it can be obtained by recognizing the original image collected by taking pictures of the image using a camera in real time, which is not specifically limited here.

[0035] One-dimensional code, two-dimensional code and other barcode images include black and white modules, which may have ghosting problems. Therefore, in a specific embodiment, if the image to be detected is a two-dimensional code, the module is a black module and a white module that constitute the two-dimensional code, and the two-dimensional code can be a black code with a white background or a white code with a black background. Of course, the module included in the two-dimensional code image can be in the shape of a square, a circle, etc., and the color of the module can be set as needed, which is not specifically limited here. In another specific embodiment, if the image to be detected is a one-dimensional code, the module is a black module and a white module that constitute the one-dimensional code, and the module of the one-dimensional code can be in the shape of a rectangle, etc.

[0036] Take the image to be detected as a QR code as an example, please refer to Figure 3 , Figure 3This is a flow chart of step S11 in an embodiment of the image defect detection method provided by the present application. When acquiring the image to be detected, the following steps can be performed:

[0037] S111: Acquire the original image.

[0038] The original image is obtained by taking a photo of the image with a camera in real time. The original image may include a QR code, but there is also noise in other non-QR code areas, or the original image may not include a QR code. Therefore, after obtaining the original image, the QR code image needs to be identified from the original image.

[0039] S112: Using a two-dimensional code recognition algorithm to recognize the original image, and detecting whether there is a two-dimensional code in the original image.

[0040] The QR code recognition algorithm is used to recognize the QR code, and can be any existing QR code recognition algorithm, which will not be described in detail here. After acquiring the original image, the original image is recognized using the QR code recognition algorithm to detect whether there is a QR code in the original image. If so, the following step S114 is executed, indicating that there is a QR code in the original image, and subsequent steps can be executed to detect defects in the QR code; if not, the following step S113 is executed, indicating that there is no QR code in the original image or there are serious problems with the QR code that make it unrecognizable, thereby terminating the execution of this detection.

[0041] S113: End the execution of the image defect detection method.

[0042] The QR code in the original image is recognized by a QR code recognition algorithm. If it is detected that there is no QR code in the original image, the image defect detection method of the present application can be directly terminated, thereby improving the detection efficiency.

[0043] S114: Obtain the coordinates of four vertices of the two-dimensional code, and calculate the affine transformation matrix of the two-dimensional code based on the four vertex coordinates, and use the affine transformation matrix to correct the barcode area of ​​the two-dimensional code to obtain the image to be detected.

[0044] After detecting the presence of a QR code in the original image, the four vertex coordinates of the QR code can be obtained, and the affine transformation matrix of the QR code is calculated based on the four vertex coordinates, and the barcode area of ​​the QR code is corrected using the affine transformation matrix to obtain the image to be detected. The implementation of calculating the affine transformation matrix of the QR code based on the four vertex coordinates is any method that can be implemented in the prior art, and will not be repeated here. By correcting the QR code using the affine transformation matrix, a QR code image without angle and perspective transformation interference can be obtained as the image to be detected, thereby reducing angle interference and perspective transformation interference and improving the accuracy of image detection. It can be understood that the image to be detected is obtained by identifying the original image captured by taking a photo of the image with a camera in real time, and then steps S111-S112 need to be executed to determine whether the original image includes the image to be detected. If the image to be detected is obtained from a number of images to be detected pre-stored in the image database, then after the image to be detected is obtained, step S114 is directly executed to correct the image to be detected to obtain the image to be detected without angle and perspective transformation interference, so that the image defect detection method has no strict requirements on the imaging posture, placement angle and specific imaging size of the QR code, and has strong adaptability and versatility. Even when the image has a certain rotation angle or the imaging size changes in the field of view, the judgment result of this method can still be accurate. Please refer to Figure 4 , Figure 4 This application provides Figure 3 Schematic diagram of the effect of step S114 in the image defect detection method embodiment.

[0045] Since the QR code can be a black code with a white background or a white code with a black background, in order to speed up the detection speed, in a specific embodiment, the black-background-white code QR code can be converted into a white-background-black code QR code by inverting the image. If the first color module is a white module, the second color module is a black module, and the image to be detected is an image of a black code with a white background, after correcting the barcode area of ​​the QR code using the affine transformation matrix, if the corrected QR code is detected as an image of a black-background-white code, the image of the black-background-white code is inverted to obtain the image to be detected. The calculation formula for image inversion is as follows:

[0046] f(x,y)=255-f(x,y) (Formula 1)

[0047] Where f(x, y) is the grayscale value of pixel (x, y).

[0048] Therefore, by image inversion processing, the two-dimensional code image can be converted into a unified white-background black-code image, and there is no need to set a separate detection method for the black-background white-code image, making the ghosting detection method more convenient and quick.

[0049] In a specific embodiment, the image to be detected may include a quiet zone area, and the quiet zone area is a white background area extended outside the boundary of the image to be detected. The size of the quiet zone area can be customized as needed, including but not limited to the size of a module. Therefore, by setting the quiet zone area, it can be confirmed whether there is a ghosting problem in the outermost circle module of the image to be detected, thereby improving the accuracy of ghosting detection. Taking the image to be detected as a QR code as an example, the quiet zone area is the area outside the QR code area surrounded by the four vertices of the QR code connected. In the embodiment where the image to be detected includes the quiet zone area, the module connection position includes the area between the outermost circle module of the image to be detected and the quiet zone area.

[0050] It is understandable that the above steps of determining whether there is a QR code, affine transformation matrix processing, image inversion, and adding a silent zone can be used alone or in combination, or in combination with other embodiments, and are not specifically limited here. The image defect detection method of the present application can identify and detect whether there is a ghosting engraving abnormality in the QR code.

[0051] S12: Using a gradient integral projection method, the module connection position between two adjacent modules with different colors is detected to obtain a defect detection result of whether there is a ghost image in the image to be detected.

[0052] Taking the above-mentioned QR code engraving method as an example, ghosting is caused by the deviation of the engraving position of the two steps of framing and filling, so the QR code can be detected for ghosting. The connection between the black module and the white module of the QR code can be detected. If the image to be detected is a one-dimensional code, ghosting is detected only in one direction, and if the image to be detected is a QR code, ghosting can be detected in both horizontal and vertical directions. The module connection position is the connection between two modules of different colors. The module connection position between two adjacent modules of different colors is detected using the gradient integral projection method to obtain the defect detection result of whether there is ghosting in the image to be detected. Because there is at least one module connection position in the same image to be detected, after the module connection position between two adjacent modules of different colors is detected by the gradient integral projection method, at least one ghost position information is obtained, so that based on the at least one ghost position information, when the defect detection result of the image to be detected having a ghosting problem is obtained, it can be that there is at least one ghost position information, that is, it is determined that the image to be detected has a ghost, or it can be that there is a preset number of ghost position information, that is, it is determined that the image to be detected has a ghost, it can be that there is ghost position information in the horizontal direction and / or vertical direction, that is, it is determined that the image to be detected has a ghost, and so on, so that the ghost position information and / or whether the image to be detected has a ghost is used as the defect detection result.

[0053] When the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method to obtain the defect detection result of whether the image to be detected has ghosting, the module connection position between two adjacent modules of different colors can be detected by using the gradient integral projection method in various directions. The direction of the gradient integral projection can be any one or more combinations of a direction perpendicular to the ghosting detection direction, a direction parallel to the ghosting detection direction, and a direction at a preset angle to the ghosting detection direction, and the ghosting detection direction can also be a horizontal direction, a vertical direction, etc. For example, the horizontal direction is defined as the left-right direction, and the vertical direction is defined as the up-down direction. Then, when the ghost detection direction is horizontal ghost detection, when the direction of the gradient integral projection is a direction perpendicular to the ghost detection direction, the direction of the gradient integral projection is a vertical direction, and can be a vertical direction from top to bottom, or a vertical direction from bottom to top, so that ghosting in the horizontal direction can be detected by the gradient integral projection in the vertical direction; or when the ghost detection direction is horizontal ghost detection, when the direction of the gradient integral projection is a direction parallel to the ghost detection direction, the direction of the gradient integral projection is a horizontal direction, and can be a horizontal direction from left to right, or a horizontal direction from right to left, so that ghosting in the horizontal direction can be detected by the gradient integral projection in the horizontal direction. The principle of ghost detection when the ghost detection direction is vertical is similar to that of ghost detection, and will not be described in detail here.

[0054] In summary, since the modules in the image to be detected include modules of two colors, the first color module and the second color module, there may be ghost images between the two modules of different colors. The present application uses the gradient integral projection method to detect the module connection position between two adjacent modules of different colors, and obtains the defect detection result of whether there is ghost image in the image to be detected, thereby realizing efficient detection of image ghost image through gradient integral projection technology. And because the detection object is the module in the image, it is possible to detect whether there is an engraving anomaly in the internal module, and it is still possible to detect when there are problems such as missing or errors in the data in the middle of the image, and there will be no problems such as failure to detect due to different image content and graphics.

[0055] See also Figure 5 , Figure 5 : is a flow chart of another embodiment of the image defect detection method provided by the present application, the method comprising:

[0056] S21: Acquire the image to be detected.

[0057] The description of step S21 can refer to the above step S11 and will not be repeated here.

[0058] S22: Determine a first value interval based on the positions of two adjacent modules with different colors in the image to be detected, and obtain a first gradient integral projection operation area.

[0059] When the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method, the first gradient integral projection operation area can be used to perform gradient integral projection of the module connection position in a first direction, and the first direction is a direction perpendicular to the ghost detection direction. The image to be detected may have ghosts in the horizontal direction, the vertical direction, the horizontal direction and the vertical direction. Therefore, the ghost detection direction may include the horizontal direction, the vertical direction, the horizontal direction and the vertical direction. If the ghost detection direction is the horizontal direction, the first direction is the vertical direction, so the first gradient integral projection operation area can be used to perform gradient integral projection of the module connection position in the first direction to realize ghost detection in the horizontal direction; if the ghost detection direction is the vertical direction, the first direction is the horizontal direction, so the first gradient integral projection operation area can be used to perform gradient integral projection of the module connection position in the first direction to realize ghost detection in the vertical direction. The ghost detection principles in the horizontal and vertical directions are the same, and the detection results are independent. If ghosts exist in the horizontal direction and / or the vertical direction, it is determined that the image to be detected has ghosts.

[0060] The width of the first gradient integral projection operation area can be a width value set as required, including but not limited to being equal to the width of the module, 0.8 times, 1.1 times, and other first preset multiples of the width of the module. The height of the first gradient integral projection operation area can be a width value set as required, including but not limited to being equal to the width of the module, 0.9 times, 1.5 times, and other second preset multiples of the width of the module. The width of the first gradient integral projection operation area and the height of the first gradient integral projection operation area can be the same or different. The biggest feature of the ghost is that its edge is basically parallel to the module and the length is close to the module, so the first direction perpendicular to the ghost detection direction is used for gradient integral projection, and the ghost is feature extracted and located. However, considering that the image to be detected may have ghosts in both the horizontal and vertical directions at the same time, the first gradient integral projection operation area can be expanded. For example, when the ghost detection direction is the horizontal direction, the height of the first gradient integral projection operation area can be larger, so that the ghost detection is more accurate. In a specific embodiment, before performing gradient integral projection in the first direction on the module connection position using the first value interval and the first gradient integral projection operation area, the width of the module can be determined as the width of the first gradient integral projection operation area, and the preset ratio times of the width of the module can be determined as the height of the first gradient integral projection operation area, which can accurately determine the ghosting while reducing the amount of calculation. The preset ratio times include but are not limited to 1.5 times, 1.4 times, etc., and are not specifically limited here.

[0061] See also Figure 6 , Figure 6This is a schematic diagram of the first and second gradient integral projection operation areas in step S22 of another embodiment of the image defect detection method provided by the present application. Figure 6 The coordinate value of the upper left corner of the first gradient integral projection operation area is (x1, y1), and the coordinate value of the lower right corner is (x2, y2). The height of the first gradient integral projection operation area is the distance between y1 and y2, and the width of the first gradient integral projection operation area is the distance between x1 and x2.

[0062] The first value interval is the value range of the width and height of the first gradient integral projection operation area during gradient integral projection.

[0063] S23: Performing gradient integral projection in a first direction on the module connection position using the first value interval and the first gradient integral projection operation area to obtain a first gradient integral projection curve.

[0064] When the direction of the gradient integral projection is the vertical direction, the first gradient integral projection calculation formula is:

[0065]

[0066] Among them, x is the width value of the first gradient integral projection operation area, x1 is the minimum width value of the first gradient integral projection operation area, x2 is the maximum width value of the first gradient integral projection operation area, y is the height value of the first gradient integral projection operation area, y1 is the minimum height value of the first gradient integral projection operation area, y2 is the maximum height value of the first gradient integral projection operation area, and g(x) is the gradient integral projection value.

[0067] When the direction of the gradient integral projection is horizontal, the first gradient integral projection calculation formula is:

[0068]

[0069] Among them, x is the width value of the first gradient integral projection operation area, x1 is the minimum width value of the first gradient integral projection operation area, x2 is the maximum width value of the first gradient integral projection operation area, y is the height value of the first gradient integral projection operation area, y1 is the minimum height value of the first gradient integral projection operation area, y2 is the maximum height value of the first gradient integral projection operation area, and g(x) is the gradient integral projection value.

[0070] The first gradient integral projection curve can be obtained by performing gradient integral projection in a first direction on the module connection position using the first gradient integral projection operation area.

[0071] S24: Based on the distribution of the peaks and troughs of the first gradient integral projection curve, first ghost position information corresponding to a plurality of module connection positions that meet the first preset ghost feature condition is obtained.

[0072] Among them, the first preset ghosting characteristic condition is that at least one trough is detected between two peaks, or at least one peak is detected between two troughs. The first ghosting position information may include the position of the ghost in the image to be detected, the ghosting interval distance and the end of the ghosting area. The position of the ghost in the image to be detected is the boundary position of the ghost. If it is a ghosting in the horizontal direction, the boundary position of the ghosting is the left and right boundaries of the ghosting, and if it is a ghosting in the vertical direction, the boundary position of the ghosting is the upper and lower boundaries of the ghosting. The ghosting interval distance is the spacing between the two boundaries of the ghosting, for example, the position distance difference between the two peaks or the position distance difference between the two troughs. The ends of the ghosting area are the two ends of the ghosting area, and are also the two ends of the module connection position.

[0073] In a specific embodiment, based on the distribution of the peaks and troughs of the first gradient integral projection curve, the first ghost position information corresponding to the plurality of module connection positions that meet the first preset ghost feature condition is used as the defect detection result of the ghost problem in the image to be detected, and the first gradient integral projection curve can be smoothed and / or filtered. Since the first gradient integral projection curve may show certain deformation and other problems due to the random noise in the image to be detected and the interference of irregular scratches in the engraving process, the interference of factors such as random noise in the image can be weakened by simply smoothing and filtering the first gradient integral projection curve, thereby helping to accurately locate the peaks and troughs in the first gradient integral projection curve.

[0074] The first ghosting position information includes but is not limited to information such as the ghosting boundary and ghosting interval, wherein the ghosting boundary can be detected based on the pixel distribution and module distribution of the image to be detected, and the ghosting interval can characterize the degree of ghosting. The larger the ghosting interval, the more serious the ghosting. Therefore, during ghosting detection, the defect position can be accurately located and the degree of ghosting can be quantified.

[0075] Take the image to be detected as a QR code as an example. In the horizontal direction, the code engraving machine first draws the frame and then fills it. The engraved filling position may be biased to the left or right relative to the frame position. Figure 7a and Figure 7b , Figure 7a and Figure 7b This is a schematic diagram of ghosting in another embodiment of the image defect detection method provided by the present application. Figure 7c and Figure 7d In another embodiment of the image defect detection method provided by the present application Figure 7aand Figure 7b Schematic diagram of the first gradient integral projection curve corresponding to the ghost. When the filling position is biased to the left relative to the frame position, the module connection position with the black module on the left and the white module on the right may have a ghost image, such as Figure 7a As shown in the figure; when the filling position is biased to the right relative to the frame position, the module connection position with a white module on the left and a black module on the right may have a double image, such as Figure 7b As shown. Figure 7a and Figure 7b If there are ghosting in these two horizontal directions, and the ghosting detection direction is the horizontal direction, then the first direction is the vertical direction, and the first gradient integral projection operation area is used to perform gradient integral projection of the module connection position in the first direction, and the obtained first gradient integral projection curves are respectively Figure 7c and Figure 7d shown. Figure 7c The middle one is the first gradient integral projection curve obtained after the black module to the white module undergoes vertical gradient integral projection, wherein there is at least one trough between two peaks, indicating the existence of ghosting. Figure 7d ] is the first gradient integral projection curve obtained after vertical gradient integral projection from the white module to the black module, wherein there is at least one peak between two troughs, indicating the presence of ghosting. Figure 7a and Figure 7b The detection of ghosting can be based on the distribution of the peaks and troughs of the first gradient integral projection curve, and the first ghosting position information can include the left and right boundaries of the ghosting in the image to be detected, the distance between the ghosting intervals, and the ends of the ghosting area. Figure 7a , the positions of the two peaks in the first gradient integral projection curve are the left and right boundary positions of the ghost image in the image; Figure 7b The positions of the two troughs in the first gradient integral projection curve are the left and right boundary positions of the ghost image in the image.

[0076] By performing gradient integral projection of the module connection position in the first direction using the first gradient integral projection operation area in steps S22 to S24, it is possible to determine whether there is a ghost in the image to be detected. By finding the peaks and troughs in the first gradient integral projection curve, the position of the ghost in the image to be detected (left and right boundaries or upper and lower boundaries), the distance of the ghost interval, and the end of the ghost area can be determined.

[0077] S25: Based on the positions of two adjacent modules with different colors in the image to be detected and the distance between the ghosting intervals, a second value interval and a second gradient integral projection operation area are obtained.

[0078] The ghost at the module connection position has transverse notches at both ends of the module connection position. According to this feature, the position can be projected with a second gradient integral in the second direction to obtain a second gradient integral projection curve for more accurate ghost detection. Since the first gradient integral projection operation area is used to project the first direction of the module connection position with a gradient integral, the first ghost position information where ghosts may exist has been determined, and the range of the ghost area has been narrowed. In order to avoid misjudgment of the first ghost position information due to scratches or dirt on the surface of the image to be detected, the absence of ghosts is judged as ghosts, which wastes production costs, S25-S27 can be further executed to perform gradient integral projection from another direction to improve the accuracy of ghost detection.

[0079] The width of the second gradient integral projection operation area can be a width value set as needed, including but not limited to a third preset multiple such as 0.5 times and 0.4 times the width of the module. The height of the second gradient integral projection operation area can be a width value set as needed, including but not limited to a fourth preset multiple such as 0.9 times and 1.1 times the ghosting interval distance. The width of the second gradient integral projection operation area and the height of the second gradient integral projection operation area can be the same or different. In a specific embodiment, when the second gradient integral projection operation area is obtained based on the ghosting interval distance, the ghosting interval distance can be used as the height of the first gradient integral projection operation area, and half of the width of the module can be used as the width of the first gradient integral projection operation area, which can accurately determine the ghosting while reducing the amount of calculation.

[0080] The second value interval is the value range of the width and height of the second gradient integral projection operation area during gradient integral projection.

[0081] S26: Performing a gradient integral projection in a second direction on the end of the ghosting area using the second value interval and the second gradient integral projection operation area to obtain a second gradient integral projection curve.

[0082] The ends of the ghosting area are the two ends of the ghosting area, and are also the two ends of the module connection position, so the ends of the ghosting area include two positions. Figure 6 As shown, the second gradient integral projection operation area is the two ends of the ghost area.

[0083] The second direction is a direction parallel to the ghost detection direction, so that the accuracy of ghost detection can be improved by performing gradient integral projection detection on the image to be detected in two different directions.

[0084] If the ghost detection direction is horizontal, the first direction is vertical, and therefore the first gradient integral projection operation area can be used to perform gradient integral projection on the module connection position in the first direction to realize ghost detection in the horizontal direction. Meanwhile, the second direction is horizontal, and therefore the second gradient integral projection operation area can be used to perform gradient integral projection on the end of the ghost area in the second direction to further confirm the ghost detection in the horizontal direction. If the ghost detection direction is vertical, the first direction is horizontal, and therefore the first gradient integral projection operation area can be used to perform gradient integral projection on the module connection position in the first direction to realize ghost detection in the vertical direction. Meanwhile, the second direction is vertical, and therefore the second gradient integral projection operation area can be used to perform gradient integral projection on the end of the ghost area in the second direction to further confirm the ghost detection in the vertical direction.

[0085] The principle of using the second gradient integral projection operation area to perform gradient integral projection in the second direction on the end of the ghost area is the same as that of using the first gradient integral projection operation area to perform gradient integral projection in the first direction on the module connection position, except that the gradient integral projection operation area and the detection area are different. The second gradient integral projection calculation formula is the same as the first gradient integral projection formula, except that the value ranges of x and y are different, which will not be repeated here.

[0086] S27: Based on the distribution of peaks and troughs of the second gradient integral projection curve, the first ghost position information that does not meet the second preset ghost characteristic condition is excluded from the first ghost position information, and a number of second ghost position information where ghosts exist are determined to obtain a defect detection result in which the image to be detected has a ghost problem.

[0087] Among them, the second preset ghosting characteristic condition is that there are two adjacent troughs in the second gradient integral projection curve. By using the second gradient integral projection operation area to perform gradient integral projection in the second direction on the end of the ghosting area, the first ghosting position information that does not meet the second preset ghosting characteristic condition is further excluded from the first ghosting position information, and the first ghosting position remaining after excluding the first ghosting position information that does not meet the second preset ghosting characteristic condition is determined as a number of second ghosting position information where ghosting exists, and a defect detection result of the existence of ghosting problem in the image to be detected is obtained, which can improve the accuracy of ghosting detection. The second ghosting position information is the specific position of the ghosting in the image to be detected, and can include which module the ghosting is located in, such as the module in the row or column, etc.

[0088] In a specific embodiment, based on the distribution of the peaks and troughs of the second gradient integral projection curve, the first ghost position information that does not meet the second preset ghost characteristic condition is excluded from the first ghost position information, and a plurality of second ghost position information with ghosts are determined, and before obtaining the defect detection result that the image to be detected has a ghost problem, the second gradient integral projection curve can be smoothed and / or filtered. Since the second gradient integral projection curve may show certain deformation and other problems due to the interference of random noise in the image to be detected and irregular scratches in the engraving process, the interference of factors such as random noise in the image can be weakened by simply smoothing and filtering the second gradient integral projection curve, thereby helping to accurately locate the peaks and troughs in the second gradient integral projection curve.

[0089] In a specific embodiment, after determining that a number of second ghost position information where ghosting exists, the number of second ghost position information can be marked in the image to be detected, and the number of second ghost position information in each first direction in the image to be detected is counted; in response to the number of second ghost position information being greater than or equal to a preset statistical number, the image to be detected is determined to have ghosting, and a defect detection result is obtained that the image to be detected has a ghosting problem. The preset statistical number can be customized as needed, for example, the preset statistical number includes but is not limited to 2, 3, etc. By judging the number of second ghost position information, the interference of the engraved texture and dirt on the barcode can be eliminated.

[0090] It can be understood that the above-mentioned use of the first gradient integral projection operation area to perform gradient integral projection on the module connection position in the first direction and use of the second gradient integral projection operation area to perform gradient integral projection on the end of the ghost area in the second direction are used in combination. In other embodiments, only the first gradient integral projection operation area can be used to perform gradient integral projection on the module connection position in the first direction, and the second gradient integral projection operation area is not used to perform gradient integral projection on the end of the ghost area in the second direction.

[0091] Through the above method, the first gradient integral projection operation area is first used to perform gradient integral projection in the first direction on the module connection position to determine all first ghost position information where ghosts exist, and then the second gradient integral projection operation area is used to perform gradient integral projection in the second direction on the end of the ghost area, and more accurate second ghost position information indicating the existence of ghosts is screened out from the first ghost position information as a defect detection result of the ghosting problem in the image to be detected, so that the ghost detection is more accurate and the image position where the defect is located can be specifically located.

[0092] When there is an engraving deviation between the boundary position of a module itself and the internal area of ​​the module, the boundary and the interior of the module are not completely adjacent or connected, resulting in ghosting. In addition to being able to detect whether there is ghosting in the image, the present application can also detect whether there is a contrast problem in the image to be detected and whether there is a misalignment problem in the image to be detected. The contrast problem means that the contrast between the different colors of the module is very low and the image engraving is shallow. For the misalignment problem, when there is a deviation in the engraving position of a module relative to the entire image to be detected, deviation from the position where it should be is called misalignment.

[0093] In a specific embodiment, the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method. Before obtaining the defect detection result of whether the image to be detected has ghosting, the first grayscale average value of all first color modules, the second grayscale average value of all second color modules, and the first grayscale difference between the first grayscale average value and the second grayscale average value can be obtained; it is determined whether the first grayscale difference is less than the first preset grayscale difference; if so, a defect detection result of a contrast problem in the image to be detected is obtained; if not, the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method. Therefore, it can be detected whether the image to be detected has a contrast problem. If the image to be detected does not have a contrast problem, ghosting can be judged, which can improve the accuracy of ghosting detection. If the image to be detected has a contrast problem, the image detection method can be directly terminated, and the contrast problem in the image to be detected can be used as a defect detection result. Of course, the gradient integral projection method can also be used to detect the module connection position between two adjacent modules of different colors, and after obtaining the defect detection result of whether there is ghosting in the image to be detected, the first grayscale average value of all first color modules, the second grayscale average value of all second color modules, and the first grayscale difference between the first grayscale average value and the second grayscale average value are obtained; it is determined whether the first grayscale difference is less than the first preset grayscale difference; if so, a defect detection result of whether the image to be detected has a contrast problem is obtained, and if not, the defect detection result of whether the image to be detected has ghosting is output.

[0094] In a specific embodiment, the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method. Before obtaining the defect detection result of whether the image to be detected has ghosting, the minimum grayscale value of the first color module and the maximum grayscale value of the second color module, as well as the second grayscale difference between the minimum grayscale value and the maximum grayscale value can be obtained; it is determined whether the second grayscale difference is less than the second preset grayscale difference; if so, a defect detection result of a misalignment problem in the image to be detected is obtained; if not, the module connection position between two adjacent modules of different colors is detected by using the gradient integral projection method. Therefore, it can be detected whether the image to be detected has a misalignment problem. If the image to be detected does not have a misalignment problem, ghosting can be judged, which can improve the accuracy of ghosting detection. If the image to be detected has a misalignment problem, the subsequent image detection method can be directly terminated, and the misalignment problem in the image to be detected can be used as a defect detection result. Of course, the gradient integral projection method can also be used to detect the module connection position between two adjacent modules of different colors, and after obtaining the defect detection result of whether there is ghosting in the image to be detected, the minimum grayscale value of the first color module and the maximum grayscale value of the second color module, as well as the second grayscale difference between the minimum grayscale value and the maximum grayscale value are obtained; it is determined whether the second grayscale difference is less than the second preset grayscale difference; if so, a defect detection result of a misalignment problem in the image to be detected is obtained; if not, the defect detection result of whether there is ghosting in the image to be detected is output.

[0095] The above detection of contrast problem, misalignment problem and ghosting problem can be performed independently or in combination. For example, in a specific embodiment, the detection of contrast problem can be performed first, then the detection of misalignment problem, and finally the detection of ghosting problem. Figure 8 , Figure 8 : is a flow chart of another embodiment of the image defect detection method provided by the present application, the method comprising:

[0096] S31: Acquire the image to be detected.

[0097] The description of step S31 can refer to the above step S11 and will not be repeated here.

[0098] S32: Obtain a first grayscale average value of all first color modules, a second grayscale average value of all second color modules, and a first grayscale difference between the first grayscale average value and the second grayscale average value.

[0099] In a specific embodiment, when obtaining the first grayscale average value of all first color modules and the second grayscale average value of all second color modules, the image to be detected can be equally spaced based on the number of modules in the image to be detected to obtain the image area of ​​each module, and the grayscale value of each module is calculated; the grayscale average value of the image area corresponding to all first color modules is calculated as the first grayscale average value, and the grayscale average value of the image area corresponding to all second color modules is calculated as the second grayscale average value. When calculating the grayscale value of each module, the grayscale value calculation formula is:

[0100]

[0101] Among them, f(x,y) is the gray value of pixel (x,y), L i , R i is the left and right boundary position of module i, U i , D i is the upper and lower boundary position of module i, g i is the grayscale value of module i.

[0102] According to the calculated grayscale values ​​of each module, the grayscale average value of the first color module is calculated to obtain the first grayscale average value, and the grayscale average value of the second color module is calculated to obtain the second grayscale average value.

[0103] S33: Determine whether the first grayscale difference is less than a first preset grayscale difference.

[0104] The higher the contrast requirement, the larger the value of the first preset grayscale difference. The size of the first preset grayscale difference can be customized as needed, for example, 20, 30, 50, etc. When the image to be detected is a QR code, the first preset grayscale difference can be 20. Determine whether the first grayscale difference is less than the first preset grayscale difference. If so, execute step S34; if not, execute step S35 to further determine whether there is a misalignment problem in the image to be detected.

[0105] S34: Obtain a defect detection result indicating that the image to be detected has a contrast problem.

[0106] It is determined that the first grayscale difference is less than the first preset grayscale difference, indicating that the contrast of the image to be detected is low. The contrast problem of the image to be detected is used as a defect detection result, and the subsequent steps S35-S37 of detecting the misalignment problem and step S38 of detecting the ghosting problem may not be performed, thereby improving the detection efficiency.

[0107] S35: Acquire the minimum grayscale value of the first color module, the maximum grayscale value of the second color module, and a second grayscale difference between the minimum grayscale value and the maximum grayscale value.

[0108] After determining that the first grayscale difference is not less than the first preset grayscale difference, it indicates that there is no contrast problem in the image to be detected, so that the minimum grayscale value of the first color module and the maximum grayscale value of the second color module, as well as the second grayscale difference between the minimum grayscale value and the maximum grayscale value can be obtained, so as to further determine whether there is a misalignment problem in the image to be detected.

[0109] S36: Determine whether the second grayscale difference is less than a second preset grayscale difference.

[0110] The higher the accuracy requirement of misalignment judgment, the larger the value of the second preset grayscale difference. The size of the second preset grayscale difference can be customized as needed, for example, 20, 30, 50, etc. When the image to be detected is a QR code, the second preset grayscale difference can be 20. The size of the second preset grayscale difference and the first preset grayscale difference can be the same or different. Determine whether the second grayscale difference is less than the second preset grayscale difference. If so, execute step S37; if not, execute step S38.

[0111] S37: Obtain a defect detection result indicating that the image to be detected has a misalignment problem.

[0112] It is determined that the second grayscale difference is less than the second preset grayscale difference, indicating that there is a misalignment problem in the image to be detected. The misalignment problem in the image to be detected is taken as a defect detection result, and the subsequent step S38 of ghosting problem detection may not be performed, thereby improving detection efficiency.

[0113] S38: Execute the gradient integral projection method to detect the module connection position between two adjacent modules with different colors, and obtain the defect detection result of whether there is ghosting in the image to be detected.

[0114] For the description of step S38, please refer to the description of the above step S12, step S22-step S27, which will not be repeated here.

[0115] By performing contrast problem detection and error problem detection before ghosting detection, only images without contrast problem and error problem can be subjected to ghosting detection, thereby improving the accuracy of ghosting detection. Meanwhile, detection results can be directly obtained for images with contrast problem and error problem without performing subsequent ghosting detection, thereby improving detection efficiency.

[0116] In any of the above embodiments, after obtaining the defect detection result that the image to be detected has ghosting problems, contrast problems, and misalignment problems, an automatic alarm can be issued or the defect detection result can be fed back to the engraving machine. Therefore, through the automatic detection of contrast problems, misalignment problems, and ghosting problems of the engraving abnormalities, the automatic alarm and feedback of the engraving abnormalities can be realized, and even an automatic control logic closed loop can be formed under automated equipment such as computers, and the automatic adjustment and optimization of the engraving machine can be realized according to the specific defect types identified, so as to automatically improve the engraving quality. The automatic detection of contrast problems and the automatic detection of misalignment problems seem more obvious, easier to detect, and more necessary to detect than the automatic detection of ghosting problems, so the automatic detection of contrast problems and the automatic detection of misalignment problems are placed before the automatic detection of ghosting problems. It can be understood that the automatic detection of contrast problems, the automatic detection of misalignment problems, and the automatic detection of ghosting problems can be independent defect detections, and when there are multiple types of detections, the multiple types of detections can be adjusted as needed, and no specific limitation is made here.

[0117] Taking the image to be detected as a barcode such as a QR code as an example, the process of this application is described in a specific application scenario:

[0118] See also Fig. 9 , Fig. 9 It is a flow chart of an application embodiment of an image defect detection method provided by the present application.

[0119] The barcode recognition and positioning of the collected image corresponds to the above-mentioned steps S111 to obtain the original image and S112 to use the two-dimensional code recognition algorithm to recognize the original image, and detect whether there is a two-dimensional code in the original image. If there is no two-dimensional code in the original image, it means that the recognition fails, indicating that there is no barcode in the judgment image or the barcode is seriously engraved abnormally, and all processes are terminated, corresponding to the above-mentioned step S113. Therefore, when the two-dimensional code can no longer be recognized, it can be directly judged as a serious engraving abnormality or a serious engraving defect. At this time, it is not necessary to distinguish the specific defect type and directly alarm feedback; if there is a two-dimensional code in the original image, it means that the recognition is successful, and the subsequent barcode image correction continues. Barcode image correction is also the content corresponding to the above-mentioned step S114. The barcode can be processed by affine transformation matrix to obtain a two-dimensional code image without angle and perspective transformation interference; the black-background white code two-dimensional code can be converted into a white-background black code two-dimensional code by inverting the image; a quiet zone area can be added to the image to be detected to facilitate the ghost detection of the outermost circle module of the barcode. After the image is corrected, the module grayscale value can be calculated, corresponding to the above step S32. The module grayscale value judgment can detect contrast problems and misalignment problems. For the detection of contrast problems, the first grayscale difference (that is, the grayscale difference) is determined corresponding to the above step S33. Fig. 9Is meanW-meanB) less than the first preset grayscale difference (i.e. Fig. 9 The first preset grayscale difference is 20). When meanW-meanB<20, it is determined that the barcode contrast is low and the barcode is lightly engraved, and all processes are terminated, corresponding to the above step S34; when meanW-meanB≥20, it is further determined whether the barcode has a misalignment problem. The detection of the misalignment problem corresponds to the step S35-S36 to determine the second grayscale difference (that is, Fig. 9 minW-maxB) is less than the second preset grayscale difference (that is, Fig. 9 The second preset grayscale difference is 20). When minW-maxB<20, it is determined that the barcode module is incorrectly engraved or the module can be incorrect, and all processes are terminated, corresponding to the above step S37; when minW-maxB≥20, it is further determined whether the barcode has a ghosting problem. For the detection of ghosting problems, please refer to the above steps S12, S22-S28, S38 and other related descriptions, which will not be repeated here. This application embodiment only illustrates that horizontal ghosting detection can be performed first to determine whether there is a ghosting in the horizontal direction. If so, it is determined that there is a ghosting in the horizontal direction and all processes are terminated; if not, a vertical ghosting detection is performed to determine whether there is a ghosting in the vertical direction. If so, it is determined that there is a ghosting in the vertical direction and all processes are terminated; if not, the output barcode is engraved normally and all processes are terminated. In the above manner, barcode contrast problems, misalignment problems, ghosting problems and other engraving problems can be detected.

[0120] See also Fig.10 , Fig.10 It is a structural schematic diagram of an embodiment of an image defect detection device provided in the present application. The image defect detection device 100 includes a memory 101 and a processor 102 connected to each other, wherein the memory 101 is used to store a computer program. When the computer program is executed by the processor 102, it is used to implement the image defect detection method in the above-mentioned embodiment.

[0121] See also Fig.11 , Fig.11 It is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 110 is used to store a computer program 111. When the computer program 111 is executed by a processor, it is used to implement the image defect detection method in the above embodiment.

[0122] The computer-readable storage medium 110 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media that can store program codes.

[0123] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0124] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0125] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0126] The above are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. An image defect detection method, characterized in that: The method comprises: Acquire an image to be detected, wherein the image to be detected includes a plurality of modules, wherein the modules include a first color module and a second color module, and the first color and the second color are two different colors; The module connection position between two adjacent modules with different colors is detected by using the gradient integral projection method to obtain a defect detection result of whether the image to be detected has ghosting.

2. The image defect detection method according to claim 1, characterized in that: The method of using the gradient integral projection method to detect the module connection position between two adjacent modules with different colors to obtain a defect detection result of whether the image to be detected has a ghosting includes: Determine a first value interval based on the positions of the two adjacent modules with different colors in the image to be detected, and obtain a first gradient integral projection operation area; Performing gradient integral projection on the module connection position in a first direction by using the first value interval and the first gradient integral projection operation area to obtain a first gradient integral projection curve, wherein the first direction is a direction perpendicular to the ghosting detection direction; Based on the distribution of peaks and troughs of the first gradient integral projection curve, the first ghosting position information corresponding to several module connection positions that meet the first preset ghosting characteristic condition is used as a defect detection result of the existence of ghosting problem in the image to be detected, wherein the first preset ghosting characteristic condition is detecting that at least one trough exists between two peaks, or at least one peak exists between two troughs.

3. The image defect detection method according to claim 2, characterized in that: The first ghost position information includes the ghost interval distance and the end of the ghost area. After the first ghost position information corresponding to the plurality of module connection positions that meet the first preset ghost feature condition and before the defect detection result that the image to be detected has a ghost problem, the method further includes: Based on the positions of the two adjacent modules with different colors in the image to be detected and the distance of the ghost interval, a second value interval and a second gradient integral projection operation area are obtained; Performing gradient integral projection in a second direction on the end of the ghosting area using the second value interval and the second gradient integral projection operation area, to obtain a second gradient integral projection curve, wherein the second direction is a direction parallel to the ghosting detection direction; Based on the distribution of peaks and troughs of the second gradient integral projection curve, the first ghosting position information that does not meet the second preset ghosting characteristic condition is excluded from the first ghosting position information, and several second ghosting position information with ghosting are determined to obtain a defect detection result that the image to be inspected has a ghosting problem, wherein the second preset ghosting characteristic condition is the presence of two adjacent troughs in the second gradient integral projection curve.

4. The image defect detection method according to claim 3, characterized in that: After determining the plurality of second ghost position information where ghosts exist, the method further includes: Marking the plurality of second ghost position information in the image to be detected, and counting the number of the second ghost position information in each first direction in the image to be detected; In response to the number of the second ghost position information being greater than or equal to a preset statistical number, the image to be detected is determined to have a ghost, and a defect detection result indicating that the image to be detected has a ghost problem is obtained.

5. The image defect detection method according to claim 4, characterized in that: Before using first ghosting position information corresponding to a plurality of module connection positions that meet a first preset ghosting characteristic condition based on the distribution of peaks and troughs of the first gradient integral projection curve as a defect detection result of a ghosting problem in the image to be detected, the method further includes: performing smoothing and / or filtering processing on the first gradient integral projection curve; and / or, Based on the distribution of the peaks and troughs of the second gradient integral projection curve, the first ghosting position information that does not meet the second preset ghosting characteristic condition is excluded from the first ghosting position information, and a plurality of second ghosting position information where ghosting exists is determined, before obtaining the defect detection result that the image to be detected has a ghosting problem, the method further includes: performing smoothing and / or filtering processing on the second gradient integral projection curve; and / or, Before performing gradient integral projection in a first direction on the module connection position using the first value interval and the first gradient integral projection operation area, the method includes: Determining the width of the module as the width of the first gradient integral projection operation area, and determining a preset proportional multiple of the width of the module as the height of the first gradient integral projection operation area; and / or, The obtaining of a second value interval and a second gradient integral projection operation area based on the positions of the two adjacent modules with different colors in the image to be detected and the distance of the ghost interval includes: The ghost interval distance is used as the height of the first gradient integral projection operation area, and half of the width of the module is used as the width of the first gradient integral projection operation area.

6. The image defect detection method according to claim 5, characterized in that: Before detecting the module connection position between two adjacent modules of different colors by using the gradient integral projection method to obtain a defect detection result of whether the image to be detected has ghosting, the method further includes: Obtaining a first grayscale average value of all the first color modules, a second grayscale average value of all the second color modules, and a first grayscale difference between the first grayscale average value and the second grayscale average value; Determining whether the first grayscale difference is less than a first preset grayscale difference; If yes, a defect detection result is obtained that the image to be detected has a contrast problem; If not, then the module connection position between two adjacent modules with different colors is detected by using the gradient integral projection method; and / or, Before detecting the module connection position between two adjacent modules of different colors by using the gradient integral projection method to obtain a defect detection result of whether the image to be detected has ghosting, the method further includes: Acquire a minimum grayscale value of the first color module, a maximum grayscale value of the second color module, and a second grayscale difference between the minimum grayscale value and the maximum grayscale value; Determining whether the second grayscale difference is less than a second preset grayscale difference; If yes, a defect detection result is obtained that the image to be detected has a misalignment problem; If not, the module connection position between two adjacent modules with different colors is detected by using the gradient integral projection method.

7. The image defect detection method according to claim 6, characterized in that: The obtaining of a first grayscale average value of all the first color modules and a second grayscale average value of all the second color modules includes: Based on the number of modules of the image to be detected, the image to be detected is divided into equal intervals to obtain an image area of ​​each module, and the grayscale value of each module is calculated; The grayscale average value of the image areas corresponding to all the first color modules is calculated as the first grayscale average value, and the grayscale average value of the image areas corresponding to all the second color modules is calculated as the second grayscale average value.

8. The image defect detection method according to any one of claims 1 to 7, characterized in that: The image to be detected is a two-dimensional code, and obtaining the image to be detected includes: Get the original image; Using a two-dimensional code recognition algorithm to recognize the original image, and detecting whether the two-dimensional code exists in the original image; If not, then terminate the execution of the image defect detection method; If yes, then obtain the coordinates of the four vertices of the two-dimensional code, and calculate the affine transformation matrix of the two-dimensional code based on the four vertex coordinates, and use the affine transformation matrix to correct the barcode area of ​​the two-dimensional code to obtain the image to be detected; and / or, The first color module is a white module, the second color module is a black module, the image to be detected is an image of a black code on a white background, and after correcting the barcode area of ​​the two-dimensional code using the affine transformation matrix, the method further includes: If the corrected two-dimensional code is detected to be an image with a black background and a white code, the image with a black background and a white code is inverted to obtain the image to be detected; and / or, The image to be detected includes a quiet zone area, and the quiet zone area is a white background area extending outside the boundary of the two-dimensional code.

9. An image ghosting detection device, characterized in that: It comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the image defect detection method according to any one of claims 1 to 8.

10. A computer-readable storage medium for storing a computer program, characterized in that: When the computer program is executed by a processor, it is used to implement the image defect detection method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Barcode quality detection method and related device

    CN121121321A

  • Bar code quality detection method and related apparatus

    CN121121321B