Printing image alignment detection method and system based on template comparison
Through the multi-resolution comparison group detection method based on template comparison, the problem of slow speed and poor effect of printed images in the prior art is solved, and faster and more accurate alignment detection is achieved, which is suitable for printing quality control.
Patent Information
- Application Number
- CN202411865838.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-08
AI Technical Summary
The existing printed image alignment detection methods are slow to detect and the detection effect is difficult to fully guarantee.
The printed image alignment detection method based on template comparison is adopted, and the alignment detection is performed through a multi-resolution comparison group to adapt to the corresponding resolution. The specific steps include downsampling the image to be detected and the template image into multiple comparison groups, dividing it into multiple small blocks, performing affine transformation matching and error calculation, determining the number of alignments, and adjusting the resolution and the number of small blocks according to the threshold.
Improves the speed and accuracy of printed image alignment detection, and adapts to reduce calculation and resource consumption to ensure the correctness of the detection results.
Smart Images

Figure CN119784712A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a printing image alignment detection method and system based on template comparison. Background Art
[0002] As a main form of product packaging, printed materials have the advantages of exquisite appearance, cleanliness, low cost, and convenience. They have been widely used in many industries. They are characterized by diverse materials, complex processes, and high quality requirements. Various defects may occur in the production process of printed materials. The alignment of printed images is one of the main problems in printing defect detection. If the printed area is not completely aligned, defect detection basically cannot achieve the expected effect. Printing area alignment is a very critical and necessary link in printing defect detection, which has a great impact on the final defect detection effect.
[0003] At present, the existing alignment detection method of printed images mainly determines whether the printed image is aligned through the error between the printed image and the template image; the detection speed of the existing alignment detection method is slow and the detection effect is difficult to fully guarantee. Summary of the invention
[0004] In view of the above technical problems existing in the prior art, the present invention provides a printing image alignment detection method and system based on template comparison, which performs alignment detection through a comparison group of multiple resolutions and can adapt to the corresponding resolution.
[0005] The present invention discloses a printing image alignment detection method based on template comparison, comprising the following steps: step 101: down-sampling the image to be detected and the template image respectively, to obtain a plurality of comparison groups with successively increasing resolutions, wherein the comparison groups include the image down-sampled from the image to be detected and the template down-sampled from the template image; step 102: dividing the image and the template of the comparison group into a plurality of small blocks respectively; step 103: matching the first small block of the template with the second small block of the image, to obtain the third small block with the best match; step 104: matching the center points of the first small block with the center points of the third small block; step 105: obtaining the first small block to the affine transformation parameters of the third small block; step 106: according to the affine transformation parameters, perform affine transformation on the first point of the first small block to obtain the transformation point from the first point to the third small block, and calculate the error between the transformation point and the corresponding point of the third small block; step 107: obtain the alignment number of the first point whose error is less than the first threshold; step 108: determine whether the alignment number is greater than the second threshold; if the alignment number is greater than the second threshold, execute step 109: take the next comparison group with higher resolution, execute steps 102-108, and increase the number of small blocks; until the resolution of the comparison group is the highest, the image to be detected is aligned.
[0006] Preferably, if the alignment number is greater than or equal to the second threshold, step 110 is performed: the image to be detected is not aligned.
[0007] Preferably, step 110 specifically includes:
[0008] The size of the small block and / or the affine transformation parameters are adjusted, and steps 102-108 are performed until the number of times that the alignment quantity is less than or equal to the second threshold exceeds a third threshold continuously, and it is determined that the image to be detected is not aligned.
[0009] Preferably, if the images to be detected are not aligned, a comparison group with a higher resolution is no longer used for detection.
[0010] Preferably, the comparison groups include a first comparison group, a second comparison group, a third comparison group, a fourth comparison group and a fifth comparison group with successively increasing resolutions.
[0011] Preferably, the number of small blocks in the high-resolution comparison group is greater than that in the low-resolution comparison group.
[0012] Preferably, the affine transformation parameters from the template to the image points are calculated by randomly extracting a certain amount of points multiple times.
[0013] Preferably, the Euclidean distance from the transformed point to the corresponding point of the third small block is used as the error.
[0014] Preferably, the first threshold value ranges from 0.01 to 0.1 cm; the second threshold value ranges from 80% to 90%.
[0015] The present invention also provides a system for implementing the above method, comprising a downsampling module, a blocking module, a matching module, an error calculation module and a detection module;
[0016] The downsampling module is used to downsample the image to be detected and the template image respectively to obtain a plurality of comparison groups with successively increasing resolutions;
[0017] The block division module is used to divide the image and template of the comparison group into a plurality of small blocks respectively. The higher the resolution of the image of the comparison group, the more small blocks there are;
[0018] The matching module is used to match the first small block of the template with the second small block of the image to obtain the third small block with the best match; and to correspond the center points of the first small block and the third small block;
[0019] The error calculation module is used to extract the affine transformation parameters from the first small block to the third small block; according to the affine transformation parameters, perform affine transformation on the first point of the first small block to obtain the transformation point from the first point to the third small block, calculate the error between the transformation point and the corresponding point of the third small block; obtain the number of alignments of the first point whose error is less than a first threshold;
[0020] The detection module is used to, if the alignment number is greater than a second threshold, take the next comparison group with a higher resolution, call the blocking module, and increase the number of small blocks; until the resolution of the current comparison group is the highest, the image to be detected is aligned; if the alignment number is less than or equal to the second threshold, adjust the size of the small block and / or the affine transformation parameters, and call the blocking module until the number of times the alignment number is less than or equal to the second threshold continuously exceeds a third threshold, then the image to be detected is not aligned.
[0021] Compared with the prior art, the beneficial effects of the present invention are as follows: through multiple comparison groups with successively higher resolutions, when alignment is detected in a low-resolution comparison group, another comparison group with higher resolution is used to perform more detailed detection, and the resolution is adaptive; when the comparison group with a lower resolution detects that the image to be detected is not aligned, no more detailed calculations are performed, which can reduce the detection calculation amount and resource consumption of qualified printed products. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart of the printing image alignment detection method based on template comparison of the present invention;
[0023] Figure 2 It is a schematic diagram of dividing an image into multiple small blocks;
[0024] Figure 3 It is a system logic block diagram of the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] In the present disclosure, it should be understood that terms such as "include" or "have" are intended to indicate the presence of features, numbers, steps, behaviors, components, parts, or a combination thereof disclosed in the specification, and do not exclude the possibility that one or more other features, numbers, steps, behaviors, components, parts, or a combination thereof exist or are added.
[0027] In some of the processes described in the specification and claims of this application and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence, nor do they limit "first" and "second" to be different types.
[0028] It should also be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other.
[0029] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0030] The first aspect of the present invention provides a printing image alignment detection method based on template comparison, such as Figure 1 As shown, the following steps are included:
[0031] Step 101: downsample the image to be detected and the template image respectively to obtain a plurality of comparison groups with successively increasing resolutions. The comparison groups include images obtained by downsampling the detection image and templates obtained by downsampling the template image, and the downsampling parameters of the same comparison group are the same.
[0032] More specifically, the comparison group includes a first comparison group, a second comparison group, a third comparison group, a fourth comparison group, and a fifth comparison group with increasing resolutions. The first comparison group includes a first image and a first template, the second comparison group includes a second image and a second template, the third comparison group includes a third image and a third template, the fourth comparison group includes a fourth image and a fourth template, and the fifth comparison group includes a fifth image and a fifth template. The image to be detected can be collected by photographing or scanning.
[0033] Step 102: Divide the image and template of the comparison group into a plurality of small blocks respectively.
[0034] The image and template are evenly divided into multiple small blocks in the XY direction. The higher the resolution of the comparison group image, the more blocks there are. Figure 2 It shows the way of dividing the image into blocks, where four points in the X and Y directions form a small block.
[0035] Step 103: Match the first small block of the template with the second small block of the image to obtain a third small block with the best match.
[0036] Step 104: Align the center points of the first small block with the center points of the third small block.
[0037] Step 105: Obtain affine transformation parameters from the first small block to the third small block.
[0038] The affine transformation parameters from the template to the image points can be calculated by randomly extracting a certain amount of points multiple times, for example, extracting 50% of the points to calculate the affine transformation parameters. Affine transformation is a linear transformation on two-dimensional coordinates, which includes basic transformations such as rotation, scaling, and translation, and can be represented by a transformation matrix. In image processing and computer vision, affine transformation is widely used in scenarios such as image correction, stitching, and transformation. Affine transformation can solve the error caused by the difference in shooting angle between the image to be detected and the template image. In order to facilitate the explanation of the mapping relationship of the transformation, this manual affine transforms the first small block of the template to the third small block of the image; but it is not limited to this, and the third small block can also be affine transformed to the first small block of the template.
[0039] Step 106: Perform an affine transformation on the first point of the first small block according to the affine transformation parameters to obtain a transformation point from the first point to the third small block, and calculate an error between the transformation point and a corresponding point of the third small block.
[0040] The error may be obtained by taking the Euclidean distance from the transformed point to the corresponding point of the third small block, but is not limited thereto.
[0041] Step 107: Obtain the number of first point alignments whose errors are less than a first threshold.
[0042] If the error is less than the first threshold, the first point is considered to be aligned; the total number of first points in each first block whose error is less than the first threshold is taken as the number of alignments. The first threshold and the second threshold can be set based on experience, for example, the first threshold is 0.01-0.1 cm. The second threshold is 80%-90%.
[0043] Step 108: Determine whether the alignment quantity is greater than a second threshold, such as greater than 80%.
[0044] If the alignment number is greater than the second threshold, execute step 109: the detection result of the current comparison group is aligned, take the next comparison group with higher resolution, execute step 102, and increase the number of small blocks to calculate more image details; until the resolution of the current comparison group is the highest, the image to be detected is aligned.
[0045] If the alignment number is less than or equal to the second threshold, execute step 110: adjust the size of the small block and the affine transformation parameters, and execute step 102 until the number of times the alignment number is less than or equal to the second threshold exceeds the third threshold continuously, for example, the alignment number is less than or equal to the second threshold for three consecutive times, then the image to be detected is not aligned; in the case of misalignment, no more detailed calculations are required.
[0046] Through multiple comparison groups with successively higher resolutions, when alignment is detected in a low-resolution comparison group, another comparison group with higher resolution is used for more detailed detection, and the resolution is adaptive; when the comparison group with a lower resolution detects that the image to be detected is not aligned, no more detailed calculations are performed, which can reduce the detection calculation amount and resource consumption of qualified printed products.
[0047] In the low-resolution comparison group, fewer small blocks are used to cover a larger field of view, increase stability, and reduce the amount of calculation; in the high-resolution comparison group, more small blocks are used to focus on more details and improve positioning accuracy. The self-verification algorithm is used for the points of the small blocks to ensure the correctness and accuracy of the detection results. The present invention can not only greatly improve the speed, but also ensure that the results given are correct.
[0048] A second aspect of the present invention provides a system for implementing the above-mentioned printing image alignment detection method, such as Figure 3 As shown, it includes a downsampling module 1, a blocking module 2, a matching module 3, an error calculation module 4 and a detection module 5;
[0049] The downsampling module 1 is used to downsample the image to be detected and the template image respectively to obtain a plurality of comparison groups with successively increasing resolutions.
[0050] The block division module 2 is used to divide the image and template of the comparison group into a plurality of small blocks. The higher the resolution of the image of the comparison group, the more small blocks there are.
[0051] The matching module 3 is used to match the first small block of the template with the second small block of the image to obtain the third small block with the best match; and to correspond the center points of the first small block and the third small block.
[0052] The error calculation module 4 is used to extract the affine transformation parameters from the first small block to the third small block; according to the affine transformation parameters, the first point of the first small block is affine transformed to obtain the transformation point from the first point to the third small block, and the error between the transformation point and the corresponding point of the third small block is calculated; and the number of alignments of the first point whose error is less than the first threshold is obtained.
[0053] The detection module 5 is used to take the next comparison group with higher resolution if the alignment number is greater than the second threshold, call the blocking module 2, and increase the number of small blocks; until the resolution of the current comparison group is the highest, the image to be detected is aligned; if the alignment number is less than or equal to the second threshold, adjust the size of the small block and the affine transformation parameters, and call the blocking module 2 until the number of times the alignment number is less than or equal to the second threshold exceeds the third threshold continuously, then the image to be detected is not aligned.
[0054] The detection module 5 can realize self-verification of the detection result, which can not only greatly improve the speed but also ensure that the given result is correct.
[0055] The present invention uses the template image as a reference to perform defect detection on the image to be detected, more specifically alignment detection, and compares the image to be detected with the standard template image, including point-by-point comparison at the image level and feature comparison at the feature level.
[0056] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A printed image alignment detection method based on template comparison, characterized in that: The following steps are involved: Step 101: down-sampling the image to be detected and the template image respectively to obtain a plurality of comparison groups with successively increasing resolutions, wherein the comparison groups include images down-sampled from the image to be detected and templates down-sampled from the template image; Step 102: Divide the image and template of the comparison group into a plurality of small blocks respectively; Step 103: Match the first small block of the template with the second small block of the image to obtain a third small block with the best match; Step 104: Align the center points of the first small block with the center points of the third small block; Step 105: Obtain affine transformation parameters from the first small block to the third small block; Step 106: performing an affine transformation on the first point of the first small block according to the affine transformation parameters, obtaining a transformation point from the first point to the third small block, and calculating an error between the transformation point and a corresponding point of the third small block; Step 107: Obtain the number of first point alignments whose errors are less than a first threshold; Step 108: Determine whether the alignment quantity is greater than a second threshold; If the alignment number is greater than the second threshold, execute step 109: take the next comparison group with higher resolution, execute steps 102 to 108, and increase the number of small blocks; until the resolution of the comparison group is the highest, the image to be detected is aligned.
2. The printed image alignment detection method according to claim 1, characterized in that: If the alignment number is greater than or equal to the second threshold, step 110 is performed: the image to be detected is not aligned.
3. The printed image alignment detection method according to claim 2, characterized in that: Step 110 specifically includes: The size of the small block and / or the affine transformation parameters are adjusted, and steps 102-108 are performed until the number of times that the alignment quantity is less than or equal to the second threshold exceeds a third threshold continuously, and it is determined that the image to be detected is not aligned.
4. The printed image alignment detection method according to claim 2, characterized in that: If the images to be detected are not aligned, a comparison group with a higher resolution is no longer used for detection.
5. The printed image alignment detection method according to claim 1, characterized in that: The comparison groups include a first comparison group, a second comparison group, a third comparison group, a fourth comparison group and a fifth comparison group with resolutions increasing in sequence.
6. The printed image alignment detection method according to claim 1, characterized in that: The number of small blocks in the high-resolution contrast group is greater than that in the low-resolution contrast group.
7. The printed image alignment detection method according to claim 1, characterized in that: The affine transformation parameters from the template to the image are calculated by randomly extracting a certain number of points multiple times.
8. The printed image alignment detection method according to claim 1, characterized in that: The Euclidean distance from the transformed point to the corresponding point in the third small block is taken as the error.
9. The printed image alignment detection method according to claim 1, characterized in that: The first threshold value range is 0.01-0.1cm; The second threshold value ranges from 80% to 90%.
10. A system, characterized in that: Used to implement the printed image alignment detection method according to any one of claims 1 to 9, characterized in that it includes a downsampling module, a blocking module, a matching module, an error calculation module and a detection module; The downsampling module is used to downsample the image to be detected and the template image respectively to obtain a plurality of comparison groups with successively increasing resolutions; The block division module is used to divide the image and template of the comparison group into a plurality of small blocks respectively. The higher the resolution of the image of the comparison group, the more small blocks there are; The matching module is used to match the first small block of the template with the second small block of the image to obtain the third small block with the best match; and to correspond the center points of the first small block and the third small block; The error calculation module is used to extract the affine transformation parameters from the first small block to the third small block; according to the affine transformation parameters, perform affine transformation on the first point of the first small block to obtain the transformation point from the first point to the third small block, calculate the error between the transformation point and the corresponding point of the third small block; obtain the number of alignments of the first point whose error is less than a first threshold; The detection module is used to, if the alignment number is greater than a second threshold, take the next comparison group with a higher resolution, call the blocking module, and increase the number of small blocks; until the resolution of the current comparison group is the highest, the image to be detected is aligned; if the alignment number is less than or equal to the second threshold, adjust the size of the small block and / or the affine transformation parameters, and call the blocking module until the number of times the alignment number is less than or equal to the second threshold continuously exceeds a third threshold, then the image to be detected is not aligned.
Citation Information
Patent Citations
Image alignment method and device, storage medium and electronic equipment
CN111028276A
Ontology alignment method and device, equipment and storage medium
CN114691877A
Printing detection method for realizing accurate image matching
CN115100158A
Image alignment method and device, electronic equipment and storage medium
CN118096608A
Printing defect detection method based on machine vision and improved template matching
CN118096722A