Two-dimensional code anti-counterfeiting image processing method and system for anti-counterfeiting verification

By acquiring multiple frames of QR code images and performing color block segmentation and grayscale matrix construction, the problem of the imbalance between robustness and accuracy in QR code anti-counterfeiting verification is solved, achieving a more efficient anti-counterfeiting verification effect.

CN120997537BActive Publication Date: 2026-02-13GUANGZHOU HONGYI ANTI-COUNTERFEITING PROD CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511506569.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2026-02-13
Estimated Expiration
2045-10-21

AI Technical Summary

Technical Problem

In existing QR code anti-counterfeiting verification, image quality is unstable due to factors such as ambient lighting, shooting angle, and camera resolution, resulting in insufficient robustness or low accuracy, making it difficult to balance robustness and accuracy.

Method used

Multiple frames of QR code images are captured by mobile terminals, grayscale processing and distortion correction are performed, color blocks are divided to obtain anti-counterfeiting pixels, an anti-counterfeiting grayscale matrix is ​​established, and enhanced anti-counterfeiting binary and grayscale matrices are constructed by combining edge gradients and grayscale distribution to determine the authenticity of the QR code.

Benefits of technology

This improves the robustness and accuracy of QR code anti-counterfeiting verification, enhances the authentication success rate in real-world scenarios, and ensures the accuracy and stability of anti-counterfeiting verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120997537B_ABST
    Figure CN120997537B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of image processing, and particularly relates to a two-dimensional code anti-counterfeiting image processing method and system for anti-counterfeiting verification, which comprises the following steps: dividing each standard image into a plurality of color blocks, obtaining anti-counterfeiting pixel points in the unit of color blocks, establishing an anti-counterfeiting gray matrix of an arbitrary standard image in combination with the gray degree of the anti-counterfeiting pixel points; obtaining the definition of an arbitrary to-be-tested image in combination with the edge gradient and the gray degree distribution type of the to-be-tested image; establishing an enhanced anti-counterfeiting binary matrix of the to-be-tested two-dimensional code; establishing an enhanced anti-counterfeiting gray matrix of the to-be-tested two-dimensional code based on the enhanced anti-counterfeiting binary matrix and in combination with the gray degree relationship of the pixel points of all to-be-tested images; and judging the authenticity of the to-be-tested two-dimensional code based on the enhanced anti-counterfeiting gray matrix. The application enhances the processing effect and anti-counterfeiting effect of the two-dimensional code anti-counterfeiting image in the anti-counterfeiting verification.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing. More particularly, the present application relates to a two-dimensional code anti-counterfeiting image processing method and system for anti-counterfeiting verification. BACKGROUND

[0002] Two-dimensional codes are a coding method for recording data information on a two-dimensional plane using black and white patterns. Two-dimensional codes are used and promoted due to their low cost and the ability to form various intelligent applications in combination with smart phones. One common direction of two-dimensional codes is product anti-counterfeiting traceability, which associates product information with two-dimensional codes, so that users can obtain product information and identify the authenticity of products by scanning two-dimensional codes when purchasing products. However, due to the replicability of two-dimensional codes, two-dimensional codes often need to be encrypted and image-processed to ensure the uniqueness of two-dimensional codes, in order to meet the use scenarios of anti-counterfeiting.

[0003] In order to ensure the uniqueness of two-dimensional codes, the micro-physical texture of the paper on which the two-dimensional code is located is often used as an anti-counterfeiting feature to enrich the verification content of the two-dimensional code. In related technologies, for example, a Chinese patent document with the authorization announcement number CN103279731B discloses a two-dimensional code anti-counterfeiting method and an anti-counterfeiting verification method thereof, which discloses using random image details that are difficult to copy when printing a two-dimensional code as an anti-counterfeiting feature part, so that the two-dimensional code has high anti-counterfeiting ability.

[0004] However, in the process of user scanning the two-dimensional code for verification, there is a problem of unstable image quality. The environment light, shooting angle, camera definition, etc. of the user scanning the two-dimensional code will all affect the recognition of the random image details, so when the extraction accuracy of the random image details is high, the robustness is insufficient, which may cause the anti-counterfeiting verification to fail, and if the extraction accuracy of the random image details is low, it will also cause the accuracy requirement of the anti-counterfeiting verification to be not met. SUMMARY

[0005] To solve the technical problem of balancing the robustness and accuracy of two-dimensional code anti-counterfeiting image processing, the present application provides solutions in the following aspects.

[0006] In a first aspect, the present application provides a two-dimensional code anti-counterfeiting image processing method for anti-counterfeiting verification, comprising:

[0007] The multiple images of the to-be-tested two-dimensional code are collected by a mobile terminal, and the grayscale processing and distortion correction result of the images are recorded as to-be-tested images; a standard image and a standard image set of the to-be-tested two-dimensional code are obtained; each standard image is divided into a plurality of color blocks, and anti-fake pixel points are obtained in the unit of the color blocks, and an anti-fake grayscale matrix of an arbitrary standard image is established in combination with the gray scale of the anti-fake pixel points; the anti-fake pixel points are extracted based on the uniformity of the grayscale distribution in the color blocks; the arbitrary standard image is recorded as a target image; the sharpness of an arbitrary to-be-tested image is obtained in combination with the edge gradient and the grayscale distribution type of the to-be-tested image; an enhanced anti-fake binary matrix of the to-be-tested two-dimensional code is established based on the sharpness of the to-be-tested image and the occurrence of the anti-fake pixel points in the to-be-tested image with different sharpness; an enhanced anti-fake grayscale matrix of the to-be-tested two-dimensional code is established based on the enhanced anti-fake binary matrix and the grayscale relationship of the pixel points of all the to-be-tested images; and the authenticity of the to-be-tested two-dimensional code is judged based on the grayscale similarity degree of the non-identical elements of the enhanced anti-fake grayscale matrix of the to-be-tested two-dimensional code and the anti-fake grayscale matrix of the corresponding standard image.

[0008] The present application can effectively inhibit the negative effects of hand shaking, motion blur and light transient by collecting multiple images and calculating the feature stability of each anti-fake pixel point, and can extract the most reliable physical features from unstable data streams, thereby greatly improving the authentication success rate in a real scene. The present application uses the anti-fake pixel points with stable geometric and physical properties of the two-dimensional code as a local light reference to achieve accurate light correction of the anti-fake pixel points. This self-referencing mechanism does not require additional hardware and is more accurate than global correction, thereby ensuring the authenticity of the material fingerprint features.

[0009] Preferably, the dividing each standard image into a plurality of color blocks comprises:

[0010] Edge detection is performed on the target image to obtain a plurality of edges of the target image; a sliding window is established, and the initial size of the sliding window is The sliding window is slid in an S-shaped manner in the target image with 1 pixel point as a step from the top-left corner to the bottom-right corner, and any pixel point of the target image is recorded as , and the window containing is recorded as ; the sliding window is set, and the color block size is determined based on the edge distribution in the window.

[0011] The color block size of the target image is set as the final sliding window size, the monochromatic window of all the pixel points of the target image is obtained, the union set is taken, and the color block set of the target image is obtained.

[0012] The present application divides the to-be-tested image, fully applies the characteristics of the two-dimensional code in the unit of the color block, and makes the acquisition of the anti-fake pixel points more detailed and accurate. ​

[0013] Preferably, the determining the color block size comprises:

[0014] For any window, if the window does not contain the pixel point of any edge of the target image, the window is recorded as a monochrome window of ; if the window contains the edge pixel point of the target image and is adjacent to the edge pixel point of the target image contained in the adjacent window, the window is recorded as a mixed color window of ; if all pixel points of the target image exist in the monochrome window, the sliding window is increased by 1 pixel point as a step; when is increased to , all pixel points of the target image exist in the monochrome window, and is increased to , all pixel points of the target image do not contain the monochrome window, and the corresponding sliding window size is recorded as the color block size of the target image.

[0015] Preferably, the obtaining the anti-counterfeiting pixel point in the color block unit comprises:

[0016] Any color block in the target image is recorded as a target color block, and the pixel points belonging to each gray scale of the target color block are obtained; according to the gray scale distribution uniformity of the pixel points in the target color block, the arbitrary gray scale stability of the target color block is calculated; the anti-counterfeiting stability of any pixel point of the target color block is obtained in combination with the gray scale stability of the pixel points and the gray scale of the adjacent pixel points; based on the gray scale stability, the stable pixel points of the target color block are screened out, the stable pixel points of the target color block are clustered based on the anti-counterfeiting stability, and a plurality of anti-counterfeiting pixel point clusters of the target color block are obtained; an anti-counterfeiting gray scale matrix of the target image is established, the gray scale of all anti-counterfeiting pixel points is counted into the elements in the corresponding position of the anti-counterfeiting gray scale matrix, and the values of the remaining elements are recorded as , which is a preset value of a non-gray scale value range.

[0017] Based on the screening of the anti-counterfeiting pixel points according to the gray scale distribution, the texture characteristics of the two-dimensional code on different printing material backgrounds can be greatly reflected, so that the anti-counterfeiting pixel points have the effect of anti-counterfeiting verification.

[0018] Preferably, the calculating the arbitrary gray scale stability of the target color block comprises:

[0019] The target color block is equally divided into a plurality of sub-color blocks, and the number of pixel points with a gray scale q in all sub-color blocks of the target color block is obtained;

[0020] The gray scale stability of the target color block with the gray scale q satisfies the expression:

[0021] ;

[0022] In the formula, represents the gray stability of the target color block with the gray q; represents the number of pixel points of the target color block with the gray q; represents the number of pixel points of the target color block; represents the number of sub-color blocks of the color block; represents the number of pixel points of the target color block with the gray q belonging to the a-th and b-th sub-color blocks; represents the absolute value function; represents the natural exponential function.

[0023] Preferably, the anti-fake stability of any pixel point of the target color block satisfies the expression:

[0024]

[0025] In the formula, represents the anti-fake stability of the i-th pixel point of the target color block; represents the gray stability corresponding to the gray of the i-th pixel point of the target color block; represents the number of neighborhood pixel points of the pixel point; represents the gray stability corresponding to the gray of the r-th neighborhood pixel point of the i-th pixel point of the target color block; represents the natural exponential function.

[0026] The anti-fake stability of the pixel point improves the robustness of the two-dimensional code anti-fake verification, and avoids the influence of factors such as illumination and definition on the judgment of the authenticity of the commodity.

[0027] Preferably, the definition of any to-be-measured image comprises:

[0028] Based on an edge detection algorithm, a plurality of edges of any to-be-measured image are acquired, a plurality of pixel points are acquired on any edge of the to-be-measured image at equal pixel point distances, which are recorded as edge feature pixel points of the to-be-measured image, and a gradient vector of the edge feature pixel point is acquired.

[0029] The definition of any to-be-measured image satisfies the expression: In the formula, represents the definition of the k-th to-be-measured image; represents the number of edge feature pixel points of the k-th to-be-measured image; represents the gradient vector of the t-th edge feature pixel point of the k-th to-be-measured image; represents the gray type of the pixel point of the k-th to-be-measured image; represents the absolute value function; represents the normalization function;​​ is a minimum value.

[0030] The clarity of the acquired image is such that even in the case of low clarity, there are enough anti-counterfeiting pixel points for anti-counterfeiting verification, thereby ensuring the detection accuracy of the anti-counterfeiting two-dimensional code.

[0031] Preferably, the establishment of the enhanced anti-counterfeiting binary matrix of the to-be-detected two-dimensional code comprises:

[0032] The anti-counterfeiting grayscale matrix of all the to-be-detected images is acquired, and an anti-counterfeiting frequency matrix of the to-be-detected two-dimensional code is constructed, wherein the value of any element of the anti-counterfeiting frequency matrix is equal to the frequency of the corresponding coordinate belonging to the anti-counterfeiting pixel point in all the to-be-detected images, the value of the element of the position with a frequency less than the second threshold in the anti-counterfeiting frequency matrix is changed to 0, and the values of the elements of all the positions other than the position with the frequency less than the second threshold are changed to 1. The obtained matrix is recorded as the enhanced anti-counterfeiting grayscale matrix of the to-be-detected two-dimensional code.

[0033] Preferably, the establishment of the enhanced anti-counterfeiting grayscale matrix of the to-be-detected two-dimensional code comprises:

[0034] Based on the grayscale mean value range, the color block set of each to-be-detected image is divided into two types of color blocks; the vth color block of any to-be-detected image is recorded as , the grayscale mean value of all the stable pixel points of is recorded as , and the background grayscale of is recorded as When the difference between the background grayscale of and the mean value of the background grayscales of all the same type color blocks is less than or equal to the third threshold, the is recorded as a stable color block; all the stable color blocks in the vth color block of each to-be-detected image are screened, and the stable color blocks in the vth region of the to-be-detected two-dimensional code are collectively recorded as the stable color blocks in the vth region of the to-be-detected two-dimensional code; the grayscale values of the anti-counterfeiting pixel points at the same coordinates of all the stable color blocks in the vth region of the to-be-detected two-dimensional code are averaged, thereby obtaining the preliminary enhanced anti-counterfeiting grayscale matrix of the to-be-detected two-dimensional code; and the preliminary enhanced anti-counterfeiting grayscale matrix is multiplied by the enhanced anti-counterfeiting binary matrix bit by bit, thereby obtaining the enhanced anti-counterfeiting grayscale matrix of the to-be-detected two-dimensional code.

[0035] In a second aspect, the present application provides a two-dimensional code anti-counterfeiting image processing system for anti-counterfeiting verification, comprising a processor and a memory, wherein the memory stores computer program instructions, and the computer program instructions are executed by the processor to implement the above-mentioned two-dimensional code anti-counterfeiting image processing method for anti-counterfeiting verification.

[0036] By using the above technical solution, the two-dimensional code anti-counterfeiting image processing method for anti-counterfeiting verification is generated into a computer program and stored in the memory to be loaded and executed by the processor, thereby manufacturing a terminal device according to the memory and the processor, and facilitating use.

[0037] The present application has the advantages of:

[0038] (1) The present application can directly and accurately locate the texture-rich area of the two-dimensional code background by dividing the standard image into color blocks and analyzing the uniformity of the gray scale distribution in the color blocks to extract anti-counterfeit pixels.

[0039] (2) The present application compares the gray scale relationship and anti-counterfeit stability of the pixels in the two-dimensional code to be tested and the standard image, which can improve the robustness and accuracy of the two-dimensional code anti-counterfeit verification compared to the single gray scale value comparison.

[0040] (3) The present application ensures the accuracy requirement of anti-counterfeit verification and improves the processing effect of the two-dimensional code anti-counterfeit image used for anti-counterfeit verification under the condition of high extraction accuracy of two-dimensional code image details. BRIEF DESCRIPTION OF DRAWINGS

[0041] Figure 1 is a flowchart schematically showing the two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification in the present application;

[0042] Figure 2 is a window schematic diagram schematically showing the DETAILED DESCRIPTION

[0043] The present application embodiment discloses a two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification, referring to Figure 1 , comprising steps S1-S4:

[0044] S1: Collecting multiple images of the two-dimensional code to be tested by a mobile terminal, and recording the gray scale processing and distortion correction results of the images as the two-dimensional code to be tested; obtaining the standard image of the two-dimensional code to be tested and the standard image set.

[0045] It should be noted that the scenario of verifying the two-dimensional code is often to confirm the authenticity of the goods during the purchase process or to verify the authenticity of the goods during the confirmation of the receipt process, so the terminal for shooting the two-dimensional code is often a mobile terminal, and the user will move the hand to make the camera of the mobile terminal can shoot the two-dimensional code clearly, and in this process, the angle and light are changed, therefore, in order to improve the accuracy of the two-dimensional code scanning and anti-counterfeit verification, the present application collects the two-dimensional code images multiple times during the camera movement, and combines multiple two-dimensional code images for anti-counterfeit verification, thereby avoiding verification failure caused by external factors such as angle and light. At the same time, in order to make the verification of the two-dimensional code have a source, it is also necessary to obtain all unverified two-dimensional codes of the goods stored in the verification center.

[0046] ​Specifically, when the user clicks the two-dimensional code scanning module of the mobile terminal, the camera starts to run to collect images of the two-dimensional code at a preset frequency to obtain a preset number of images of the two-dimensional code to be detected. It should be noted that the preset frequency and the preset number are set by the implementer according to the actual implementation situation, for example, the preset frequency can be set to 0.1 seconds per image, and the preset number can be set to 10 images.

[0047] All images of the two-dimensional code to be detected are subjected to grayscale processing, and then the boundaries of the two-dimensional code to be detected of all images are obtained through Hough line detection, pixel points of the boundaries and regions within the boundaries are extracted, and distortion correction is performed through affine transformation to obtain a plurality of test images of the two-dimensional code to be detected. It should be noted that the grayscale processing, Hough line detection and affine transformation are all prior art and will not be described here.

[0048] All test images are identified and decoded through a two-dimensional code decoder, and jump to a verification link of the two-dimensional code to be detected to obtain a standard image of the two-dimensional code of the product contained in the verification link, and obtain a standard image set of all two-dimensional codes of the same product. It should be noted that identification and decoding through the two-dimensional code decoder are prior art and therefore will not be described in detail.

[0049] At this point, a plurality of test images and corresponding standard images and standard image sets are obtained.

[0050] S2: Each standard image is divided into a plurality of color blocks, and anti-counterfeit pixel points are obtained in units of color blocks, and an anti-counterfeit grayscale matrix of any standard image is established in combination with the grayscale of the anti-counterfeit pixel points.

[0051] It should be noted that the two-dimensional code is composed of a plurality of black and white squares, and these black and white squares represent 1 and 0 values. Due to the influence of paper on the presentation of the two-dimensional code, the two-dimensional code image in real-time shooting is often not a binary image, and the microstructure of the paper is mixed in it, so that the grayscale in the black and white squares is not uniform, which constitutes the unique mark of each two-dimensional code. Therefore, the standard image is first divided, all black and white squares are taken as a color block, and the pixel points with unique grayscale in the color block are taken as the anti-counterfeit features of the color block for subsequent anti-counterfeit verification.

[0052] Specifically, each standard image is divided into a plurality of color blocks, anti-counterfeit pixel points are obtained in units of color blocks, and an anti-counterfeit grayscale matrix of any standard image is established in combination with the grayscale of the anti-counterfeit pixel points, including:

[0053] Any standard image is denoted as a target image, and edge detection is performed on the target image to obtain a plurality of edges of the target image. It should be noted that the edge detection is prior art and can be obtained through a canny operator or a sobel operator.

[0054] A sliding window is established, and the initial size of the sliding window is The sliding window is slid in the target image from the top-left corner to the bottom-right corner in an "S" shape with a step size of 1 pixel point, and any pixel point of the target image is denoted as The window containing is denoted as The window containing Figure 2 is denoted as The window containing , , , The four windows containing are respectively denoted as

[0055] It should be noted that if any window of has an edge connected to the edge of a neighboring window, it means that the window is not a single color block, and thus if has a window that does not contain an edge connected to the edge of a neighboring window, it means that P belongs to a color block, and if all pixel points belong to a color block respectively, it means that the sliding window can still be increased, and thus the sliding window is increased to contain a complete color block.

[0056] For any window of , if the window does not contain any edge pixel point of the target image, the window is denoted as a single-color window of If the window contains an edge pixel point of the target image and is adjacent to the edge pixel point of the target image contained in a neighboring window, the window is denoted as a mixed-color window of If all pixel points of the target image have single-color windows, the sliding window is increased by 1 pixel point; when is increased to , all pixel points of the target image have single-color windows, and is increased to , all pixel points of the target image do not have single-color windows, and the corresponding sliding window size is recorded as the color block size of the target image.

[0057] The color block size of the target image is set as the final sliding window size, the single-color windows of all pixel points of the target image are obtained, the union set is taken, and the color block set of the target image is obtained.

[0058] It should be noted that in each color block, due to factors such as paper texture, the gray scale distribution is uneven, and thus the uneven gray scale in the color block is extracted, that is, the anti-fake pixel points in the color block are obtained.

[0059] Any color block in the target image is recorded as a target color block, and pixel points belonging to each gray scale of the target color block are obtained.

[0060] It should be noted that the more pixel points of the target color block belonging to any gray scale and the more uniform the distribution, the more stable the pixel points of the gray scale in the target color block. Thus, according to the uniformity of the gray scale distribution of the pixel points in the color block, the stability of the color block of any gray scale is calculated.

[0061] The target color block is equally divided into a plurality of sub-color blocks, and the number of pixel points with a gray scale q in all sub-color blocks of the target color block is obtained. It should be noted that the number of equal divisions of the target color block is set by the implementer according to the actual implementation, for example, if the size of the color block is , the size of the sub-color block can be set to .

[0062] The gray scale stability of the target color block with a gray scale q satisfies the expression:

[0063] ;

[0064] In the expression, represents the gray scale stability of the target color block with a gray scale q; represents the number of pixel points of the target color block with a gray scale q; represents the number of pixel points of the target color block; represents the number of sub-color blocks of the color block; , represents the number of pixel points belonging to the a-th and b-th sub-color blocks among the pixel points of the target color block with a gray scale q; represents the absolute value function; represents the natural exponential function.

[0065] In the expression, represents the proportion of the pixel points of the target color block with a gray scale q, and the larger the value, the more common the gray scale q in the target color block, and thus the higher the gray scale stability of the gray scale q; represents the cumulative difference of the number of pixel points with a gray scale q in all different sub-color blocks of the target color block, and the value represents the uniformity of the distribution of the pixel points with a gray scale q in the target color block. The larger the value, the more uneven the distribution of the pixel points with a gray scale q in the target color block, and the lower the gray scale stability of the target color block with a gray scale q. The is combined with , and the larger the value, the more pixel points with a gray scale q in the target color block and the more uniform the distribution, and thus the higher the gray scale stability of the target color block with a gray scale q.

[0066] It should be noted that the higher the gray stability of the pixel points, the weaker the feature performance of the color block, and therefore the lower the gray stability of the pixel points, the more capable they are as anti-counterfeit pixel points for representing the microstructure characteristics of the color block. On the other hand, if the anti-counterfeit pixel points do not gather, it is easy to cause the camera to be unable to be shot due to the instability of the camera definition, light, and direction, and therefore further, the gathering of the anti-counterfeit pixel points is considered and analyzed, the more the anti-counterfeit pixel points gather, the stronger the feature performance and the stronger the stability, and the more capable they are as anti-counterfeit pixel points. In combination with the gray stability of the gray of the pixel points and the neighborhood pixel points in the color block, the anti-counterfeit stability of the pixel points is obtained.

[0067] The anti-counterfeit stability of the arbitrary pixel point of the target color block satisfies the expression:

[0068] ;

[0069] In the formula, represents the anti-counterfeit stability of the i-th pixel point of the target color block; represents the gray stability corresponding to the gray of the i-th pixel point of the target color block; represents the number of neighborhood pixel points of the pixel point; represents the gray stability corresponding to the gray of the r-th neighborhood pixel point of the i-th pixel point of the target color block; represents the natural exponential function. It should be noted that the neighborhood pixel points are preset values, which can be set as the neighborhood, and the number of neighborhood pixel points is 24.

[0070] The pixel points of the N kinds of gray with the maximum gray stability are recorded as stable pixel points, the pixel points of the target color block are taken as growth seeds in the order of the anti-counterfeit stability from large to small, and region growing is sequentially performed, the growing condition is that there is a non-stable pixel point in the neighborhood pixel points of the growing region, the growing stop condition is that all the neighborhood pixel points of the growing region are stable pixel points, when the number of the regions completing the region growing is greater than a first threshold or the growing region of the growth seed exists overlap, the region growing is stopped, each growing region is recorded as an anti-counterfeit pixel point cluster, and a plurality of anti-counterfeit pixel point clusters of the target color block are obtained.

[0071] The anti-counterfeit pixel point clusters of all the color blocks of the target image are obtained, an anti-counterfeit gray matrix of the target image is established, the anti-counterfeit gray matrix is the same in size as the target image, the gray of all the anti-counterfeit pixel points is counted into the elements in the corresponding positions of the anti-counterfeit gray matrix, and the values of the remaining elements are recorded as . It should be noted that the is a preset value of a non-gray value range, which can be set as 256, or other characters can be used instead.

[0072] At this point, the anti-counterfeit gray matrix of any image to be measured is obtained.

[0073] S3: Obtain the sharpness of any test image in combination with the edge gradient and the gray scale distribution type of the test image; based on the sharpness of the test image and the occurrence of the anti-counterfeit pixel points in the test image of different sharpness, an enhanced anti-counterfeit binary matrix of the test two-dimensional code is established; based on the enhanced anti-counterfeit binary matrix, in combination with the gray scale relationship of the pixel points of all test images, an enhanced anti-counterfeit gray scale matrix of the test two-dimensional code is established.

[0074] It should be noted that the acquisition scene of the standard image is relatively idealized, while the test image is limited by the sharpness of the camera of the mobile terminal and external factors, which may cause some changes in the anti-counterfeit gray scale matrix, such as changes in the position and gray scale of the anti-counterfeit pixel points, so that the anti-counterfeit gray scale matrix of the test image cannot completely match the anti-counterfeit gray scale matrix of the corresponding standard image. However, by splicing the anti-counterfeit gray scale matrix of all test images of the test two-dimensional code, the corresponding standard image can be restored to the greatest extent. Therefore, the enhanced anti-counterfeit gray scale matrix of the test two-dimensional code is obtained in combination with the anti-counterfeit gray scale matrix of all test images.

[0075] It should be further noted that when the sharpness of the test image is relatively low, the obtained anti-counterfeit gray scale matrix may deviate, and there are fewer anti-counterfeit pixel points, but the position structure of the anti-counterfeit pixel points can still show the anti-counterfeit features of the two-dimensional code. When the color of the test image changes, the overall or local gray scale of the test image may deviate, but the gray scale relationship of the anti-counterfeit pixel points can still show the anti-counterfeit features of the two-dimensional code. Therefore, the enhanced anti-counterfeit gray scale matrix of the test two-dimensional code is established in combination with the position structure of the anti-counterfeit pixel points and the gray scale relationship of the anti-counterfeit gray scale matrix of all test images.

[0076] It should be noted that the higher the sharpness of the test image, the clearer the boundary of the test image and the more dispersed the gray scale distribution of the pixel points, so that the details can be presented.

[0077] Specifically, the sharpness of any test image is obtained in combination with the edge gradient and the gray scale distribution type of the test image, including:

[0078] The edge of any test image is detected to obtain a plurality of edges of the test image, a plurality of pixel points are obtained on any edge of the test image at equal pixel point distances, which are referred to as edge feature pixel points of the test image, and a gradient vector of the edge feature pixel points is obtained. It should be noted that the equal pixel point distance can be set according to actual implementation, for example, 4 pixel points of the edge are obtained at equal pixel point distances, and the number is too small to accurately reflect the sharpness, and the number is too large to increase irrelevant calculation. The edge detection is a prior art and can be obtained by a sobel operator or a canny operator.

[0079] The sharpness of any image under test satisfies the expression:

[0080] ;

[0081] In the formula, This represents the sharpness of the k-th image to be tested; This represents the number of edge feature pixels in the k-th image to be tested; This represents the gradient vector of the t-th edge feature pixel in the k-th image to be tested; This represents the grayscale class of the k-th pixel in the image to be tested; Represents the absolute value function; Represents the normalization function; To find the minimum value and avoid a denominator of 0, for example, .

[0082] In the formula, This represents the magnitude of the gradient vector of the t-th edge feature pixel in the k-th test image. This value reflects the degree of gray-level change in the neighborhood of the t-th edge feature pixel in the k-th test image. The larger the value, the higher the degree of gray-level change in the neighborhood of the t-th edge feature pixel in the k-th test image, the more details are preserved, and therefore the higher the clarity of the k-th test image. This represents the average sharpness of the neighborhood of all edge feature pixels in the k-th test image. A larger value indicates higher sharpness of the k-th test image. Based on this, the grayscale values ​​of the pixels in the k-th test image are... The larger the value, the richer the grayscale of the k-th test image, the fewer the blurred pixels in the k-th test image, and the higher the clarity of the k-th test image.

[0083] It should be noted that the lower the resolution of the image under test, the fewer anti-counterfeiting pixels can be extracted. However, if these anti-counterfeiting pixels are located in the corresponding positions of the high-resolution image under test, then these anti-counterfeiting pixels have a higher anti-counterfeiting capability and can still correctly prevent counterfeiting even with significant image loss. Therefore, the positions of anti-counterfeiting pixels in all images under test are statistically analyzed and filtered to obtain the enhanced anti-counterfeiting binary matrix of the QR code under test.

[0084] Preferably, the anti-counterfeiting grayscale matrix of all images to be tested is obtained, and the anti-counterfeiting frequency matrix of the QR code to be tested is constructed. The value of any element in the anti-counterfeiting frequency matrix is ​​equal to the frequency of the corresponding position belonging to the anti-counterfeiting pixel in all images to be tested. The values ​​of elements in the anti-counterfeiting frequency matrix whose frequency is less than the second threshold are changed to... Then all non- the value of the element is changed to 1, and the obtained matrix is recorded as an enhanced anti-fake binary matrix of the to-be-tested two-dimensional code. It should be noted that the second threshold value can be set according to actual implementation conditions, for example, in the case of 10 to-be-tested images, the second threshold value can be set to 5. The enhanced anti-fake binary matrix embodies the positions of anti-fake pixel points with strong anti-fake capability obtained from all to-be-tested images. The enhanced anti-fake gray matrix of the to-be-tested two-dimensional code is obtained by analyzing and quantifying the gray relationship of the pixel points of the enhanced anti-fake binary matrix. is a preset value of the non-gray value range, which can be 256, or other characters can be used instead.

[0085] It should be noted that, unlike the coordinates of the anti-fake pixel points, the gray values of the anti-fake pixel points at the corresponding positions of the enhanced anti-fake gray matrix cannot be obtained only by accumulation or the like, because the overall gray of different to-be-tested images is different, for example, the overall gray of a to-be-tested image with insufficient light is lower, while the overall gray of a to-be-tested image with strong light is higher, but the gray relationship between pixel points does not change. In the case of uniform light, the gray size relationship of two adjacent pixel points is stable, and therefore, further, the gray relationship of the pixel points of the enhanced anti-fake binary matrix is analyzed and quantified to obtain the enhanced anti-fake gray matrix.

[0086] Preferably, based on the enhanced anti-fake binary matrix, the enhanced anti-fake gray matrix of the to-be-tested two-dimensional code is established by combining the gray relationship of the pixel points of all to-be-tested images, including:

[0087] For the color block set of each to-be-tested image, the color block with a gray mean value greater than the gray mean value of the corresponding to-be-tested image is recorded as a first-type color block of the corresponding to-be-tested image, and the color block with a gray mean value less than the gray mean value of the corresponding to-be-tested image is recorded as a second-type color block of the corresponding to-be-tested image.

[0088] The vth color block of the kth to-be-tested image is recorded as , and the gray mean value of all stable pixel points of is recorded as , and the background gray of is obtained. If the difference between the background gray of and the mean value of the background grays of all the same color blocks is greater than a third threshold value, the color block is recorded as an unstable color block, If the difference between the background gray of and the mean value of the background grays of all the same color blocks is less than or equal to the third threshold value, the color block is recorded as a stable color block. It should be noted that, considering that the light position is unstable, the gray relationship of the color block may change when the color block position is the light position or a gray abrupt change region, and therefore, the color blocks are screened, and the stable color blocks are used for analysis of the gray relationship. The third threshold value is set by the implementer according to actual implementation conditions, for example, the third threshold value can be set to 8.

[0089] The vth color block of the to-be-tested image is recorded as the vth region of the to-be-tested two-dimensional code, the vth color block of all to-be-tested images is obtained, and stable color blocks are screened out, which are collectively referred to as stable color blocks of the vth region of the to-be-tested two-dimensional code. The average value of the gray values of the anti-counterfeit pixel points at the same coordinates of all stable color blocks of the vth region of the to-be-tested two-dimensional code is obtained to obtain a preliminary enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code. The preliminary enhanced anti-counterfeit gray matrix is multiplied by the enhanced anti-counterfeit binary matrix of the to-be-tested two-dimensional code bit by bit to obtain an enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code. It should be noted that the elements with a value of 1 in the enhanced anti-counterfeit binary matrix represent the positions of the pixel points that can enhance the anti-counterfeiting of the enhanced anti-counterfeit gray matrix. By filling in the gray values of the preliminary enhanced anti-counterfeit gray matrix, the pixel points that can enhance the anti-counterfeiting are more specific, and more accurate basis is provided for anti-counterfeiting verification.

[0090] At this point, the enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code is obtained.

[0091] S4: Based on the non-0 elements of the enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code and the anti-counterfeit gray matrix of the corresponding standard image, the authenticity of the to-be-tested two-dimensional code is judged.

[0092] It should be noted that the enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code is a matrix of pixel point coordinates and gray values obtained through screening and gray reorganization, which is not completely consistent with the anti-counterfeit gray matrix of the standard image of the corresponding product, but the key pixel points, that is, the pixel points that can enhance the anti-counterfeiting, can be well matched in the anti-counterfeit gray matrix of the standard image, that is, it can be explained that the to-be-tested two-dimensional code corresponds to the genuine product.

[0093] Specifically, the elements with values not equal to 0 in the enhanced anti-counterfeit gray matrix of the to-be-tested two-dimensional code and the anti-counterfeit gray matrix of the corresponding standard image are recorded as temporary anti-counterfeit elements of the to-be-tested two-dimensional code and the standard image, respectively.

[0094] It should be noted that the elements at the same positions in the temporary anti-counterfeit elements of the to-be-tested two-dimensional code and the standard image should have consistent gray relationship with the neighborhood, for example, the gray difference between the temporary anti-counterfeit elements at positions and is 10, so the closer the gray difference of the two temporary anti-counterfeit elements in the to-be-tested two-dimensional code is to 10, the more the two temporary anti-counterfeit elements conform to the genuine two-dimensional code. Therefore, the authenticity of the to-be-tested two-dimensional code is obtained by combining the gray difference of the same neighborhood relationship of the temporary anti-counterfeit elements of the to-be-tested two-dimensional code and the standard image.

[0095] The authenticity of the to-be-tested two-dimensional code satisfies the expression:

[0096] ​​ ;

[0097] In the formula, represents the authenticity of the to-be-tested two-dimensional code; represents the number of temporary anti-counterfeiting elements of the to-be-tested two-dimensional code; represents the gray scale difference value of the s-th and z-th temporary anti-counterfeiting elements of the to-be-tested two-dimensional code; represents the gray scale difference value of the s-th and z-th temporary anti-counterfeiting elements of the standard image; represents the two-by-two combination mode of the total temporary anti-counterfeiting elements; represents an absolute value function; represents a natural exponential function; is a minimum value, which is used to avoid a denominator of 0, and an exemplary .

[0098] In the formula, represents the difference of the gray scale difference value of the s-th and z-th temporary anti-counterfeiting elements in the to-be-tested two-dimensional code and the standard image; represents the total sum of the differences of the gray scale difference values of all different two-by-two combinations of the temporary anti-counterfeiting elements in the to-be-tested two-dimensional code and the standard image; represents the average of the total sum of the differences of the gray scale difference values of all different two-by-two combinations of the temporary anti-counterfeiting elements in the to-be-tested two-dimensional code and the standard image, which reflects the overall difference of the temporary anti-counterfeiting elements in the to-be-tested two-dimensional code and the standard image, and the greater the value, the less the gray scale relationship of the anti-counterfeiting pixel points of the to-be-tested two-dimensional code conforms to the standard image, thereby indicating that the authenticity of the to-be-tested two-dimensional code is lower.

[0099] At this point, the authenticity of the to-be-tested two-dimensional code is obtained.

[0100] A fourth threshold value is set, and if the authenticity of the to-be-tested two-dimensional code is greater than the fourth threshold value, it is considered that the product corresponding to the to-be-tested two-dimensional code is a genuine product. It should be noted that the fourth threshold value can be set by the authenticity obtained by detecting the two-dimensional code in a simulated real environment, for example, set to 0.7, and a larger setting will detect a real two-dimensional code as a counterfeit product, and a smaller setting will identify a counterfeit two-dimensional code as a genuine product.

[0101] At this point, the processing of the two-dimensional code anti-counterfeiting image and the anti-counterfeiting verification are completed.

[0102] The embodiment of the application also discloses a two-dimensional code anti-counterfeiting image processing system for anti-counterfeiting verification, comprising a processor and a memory, and the memory stores computer program instructions, which realize the two-dimensional code anti-counterfeiting image processing method for anti-counterfeiting verification according to the application when the computer program instructions are executed by the processor.

[0103] The system also comprises other components well known to those skilled in the art such as a communication bus and a communication interface, the arrangement and function of which are known in the art and will therefore not be described in more detail here.

[0104] While the present specification has shown and described a number of embodiments of the application, it is to be understood that those skilled in the art will be able to devise their own implementations that, while not explicitly shown or described herein, embody the principles of the application and, thus, are within the spirit and scope of the application. It is therefore intended that the application not be limited to the explicitly described embodiments but rather only by the claims that follow.

Claims

1. A two-dimensional code anti-counterfeiting image processing method for anti-counterfeiting verification, characterized in that, The method comprises the following steps: Collecting multiple images of the to-be-tested two-dimensional code by a mobile terminal, and recording the grayscale processing and distortion correction result of the images as to-be-tested images; obtaining a standard image and a standard image set of the to-be-tested two-dimensional code; Dividing each standard image into a plurality of color blocks, obtaining anti-counterfeit pixel points in the color block units, and establishing an anti-counterfeit grayscale matrix of an arbitrary standard image in combination with the grayscale of the anti-counterfeit pixel points; the anti-counterfeit pixel points are extracted based on the uniformity of the grayscale distribution in the color block; and recording an arbitrary standard image as a target image; The anti-counterfeit pixel points are obtained in units of color blocks, including: recording any color block in a target image as a target color block, obtaining pixel points belonging to each gray scale of the target color block; calculating the arbitrary gray scale stability of the target color block according to the gray scale distribution uniformity of the pixel points in the target color block; obtaining the anti-counterfeit stability of any pixel point in the target color block in combination with the gray scale stability of the gray scales to which the pixel points and the neighborhood pixel points in the target color block belong; screening out stable pixel points of the target color block based on the gray scale stability, clustering the stable pixel points of the target color block based on the anti-counterfeit stability, and obtaining several anti-counterfeit pixel point clusters of the target color block; the lower the gray scale stability of the pixel points, the more capable the pixel points are of being used as anti-counterfeit pixel points to represent the microstructure characteristics of the color block; the more the anti-counterfeit pixel points are gathered, the stronger the feature performance and the stronger the stability, and the more capable the anti-counterfeit pixel points are; an anti-counterfeit gray scale matrix of the target image is established, the gray scales of all the anti-counterfeit pixel points are counted into the elements in the corresponding positions of the anti-counterfeit gray scale matrix, and the values of the remaining elements are recorded as ; Obtaining the sharpness of an arbitrary to-be-tested image in combination with the edge gradient and the grayscale distribution type of the to-be-tested image; establishing an enhanced anti-counterfeit binary matrix of the to-be-tested two-dimensional code based on the sharpness of the to-be-tested image and the occurrence of the anti-counterfeit pixel points in the to-be-tested image of different sharpness; and establishing an enhanced anti-counterfeit grayscale matrix of the to-be-tested two-dimensional code based on the enhanced anti-counterfeit binary matrix and in combination with the grayscale relationship of the pixel points of all to-be-tested images; The method comprises the following steps: determining the authenticity of the to-be-tested two-dimensional code based on the similarity of the gray scale of the elements of the enhanced anti-counterfeiting gray scale matrix of the to-be-tested two-dimensional code and the anti-counterfeiting gray scale matrix corresponding to the standard image. The authenticity of the to-be-tested two-dimensional code is determined based on the similarity of the gray scale of the elements of the enhanced anti-counterfeiting gray scale matrix of the to-be-tested two-dimensional code and the anti-counterfeiting gray scale matrix corresponding to the standard image. The preset value of the non-gray value range.

2. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The method further comprises the following steps of dividing each standard image into a plurality of color blocks: Edge detection is performed on the target image to obtain a plurality of edges of the target image; a sliding window is established, and an initial size of the sliding window is The sliding window is slid in an S shape from the top-left corner to the bottom-right corner in the target image by 1 pixel point as a step, and any pixel point of the target image is recorded as The window containing is recorded as The sliding window is set, and the color block size is determined based on the edge distribution in the window. Setting the color block size of the target image as the final sliding window size, obtaining a single-color window of all pixel points of the target image, taking the union set, and obtaining a color block set of the target image.

3. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 2, characterized in that, The method further comprises the following steps of determining the color block size: For any window of , if the window does not contain the pixel point of any edge of the target image, the window is recorded as a monochrome window of ; if the window contains the pixel point of the edge of the target image and is adjacent to the pixel point of the edge of the target image contained in the adjacent window, the window is recorded as a mixed window of ; if all pixel points of the target image exist in the monochrome window, the sliding window is increased by 1 pixel point as a step; when is increased to , all pixel points of the target image exist in the monochrome window, and is increased to , all pixel points of the target image do not contain the monochrome window, and the corresponding sliding window size is recorded as the color block size of the target image.

4. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The method further comprises the following steps of calculating the arbitrary grayscale stability of the target color block: Equally dividing the target color block into a plurality of sub-color blocks, and obtaining the number of pixel points with a grayscale of q in all sub-color blocks of the target color block; The grayscale stability of the target color block with a grayscale of q satisfies the expression: ; In the formula, represents the gray stability of the target color block with the gray q; represents the number of pixels of the target color block with the gray q; represents the number of pixels of the target color block; represents the number of sub-color blocks of the color block; , represents the number of pixels of the target color block with the gray q belonging to the a-th and b-th sub-color blocks; represents the absolute value function; represents the natural exponential function.

5. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The anti-counterfeit stability of an arbitrary pixel point of the target color block satisfies the expression: ; In the formula, represents the anti-counterfeiting stability of the i-th pixel point of the target color block; represents the gray stability corresponding to the gray of the i-th pixel point of the target color block; represents the number of neighborhood pixel points of the pixel point; represents the gray stability corresponding to the gray of the r-th neighborhood pixel point of the i-th pixel point of the target color block; represents a natural exponential function.

6. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The method further comprises the following steps of obtaining the sharpness of an arbitrary to-be-tested image: Obtaining a plurality of edges of an arbitrary to-be-tested image based on an edge detection algorithm, obtaining a plurality of pixel points on an arbitrary edge of the to-be-tested image at an equal pixel point distance, recording the pixel points as edge feature pixel points of the to-be-tested image, and obtaining a gradient vector of the edge feature pixel points. The definition of the sharpness of the kth test image is: ; wherein, represents the sharpness of the kth test image; represents the number of edge feature pixel points of the kth test image; represents the gradient vector of the tth edge feature pixel point of the kth test image; represents the gray scale of the pixel point of the kth test image; represents the absolute value function; represents the normalization function; is the minimum value.

7. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The method further comprises the following steps of establishing the enhanced anti-counterfeit binary matrix of the to-be-tested two-dimensional code: Obtain the anti-counterfeiting gray matrix of all images to be tested, construct an anti-counterfeiting frequency matrix of the two-dimensional code to be tested, the value of any element of the anti-counterfeiting frequency matrix is equal to the frequency of the corresponding coordinate belonging to the anti-counterfeiting pixel point in all images to be tested, change the value of the element of the position whose frequency is less than the second threshold in the anti-counterfeiting frequency matrix to , and then change the value of all non elements to 1, and the obtained matrix is denoted as an enhanced anti-counterfeiting binary matrix of the two-dimensional code to be tested.

8. The two-dimensional code anti-counterfeit image processing method for anti-counterfeit verification according to claim 1, characterized in that, The method further comprises the following steps of establishing the enhanced anti-counterfeit grayscale matrix of the to-be-tested two-dimensional code: Based on the grayscale mean range, the set of color patches in each image to be tested is divided into two types of color patches; the v-th color patch of any image to be tested is denoted as... , obtain Similar color blocks in the neighborhood will The average grayscale value of all stable pixels is denoted as Background grayscale, when If the difference between the background grayscale and the average background grayscale of all similar color blocks is less than or equal to the third threshold, then... The stable color blocks are denoted as stable color blocks. The stable color blocks in the v-th color block of all the images to be tested are collectively referred to as the stable color blocks of the v-th region of the QR code to be tested. The average gray value of the anti-counterfeiting pixels with the same coordinates of all stable color blocks in the v-th region of the QR code to be tested is calculated to obtain the preliminary enhanced anti-counterfeiting gray matrix of the QR code to be tested. The matrix is ​​multiplied bit by bit with the enhanced anti-counterfeiting binary matrix to obtain the enhanced anti-counterfeiting gray matrix of the QR code to be tested.

9. A two-dimensional code anti-counterfeit image processing system for anti-counterfeit verification, characterized in that, The method comprises the following steps: A processor and a memory, the memory stores computer program instructions, when the computer program instructions are executed by the processor, the method for anti-counterfeit verification of the two-dimensional code anti-counterfeit image processing method according to any one of claims 1-8 is realized.

Citation Information

Patent Citations

  • Two-dimension code anti-counterfeit method and its anti-counterfeit verification method

    CN103279731B

  • Production method of anti-counterfeiting embossed metal picture

    CN117173142A

  • Double-layer anti-counterfeit label system and method based on artificial intelligence

    CN119992072A