A method and device for detecting micro-code reflection based on grayscale histogram discreteness
Through the micro-graphic code reflection detection method based on grayscale histogram, the image interference problem caused by ink reflection when smart devices take micro-graphic codes is solved, and the image reflection is accurately judged, which improves the stability and robustness of anti-counterfeiting identification.
Patent Information
- Application Number
- CN202211448313.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-18
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-11-18
AI Technical Summary
When taking micro-image codes in smart devices, the smooth ink reflection phenomenon will cause image details to interfere with, affecting the final result of micro-image anti-counterfeiting codes, which may lead to the authentic product being misjudged as a fake.
The micro-map code reflection detection method based on the discreteness of the gray histogram is adopted. The micro-map code sample picture is obtained by taking photos, and the micro-map anti-counterfeiting code area image is positioned and calculating the gray histograms into multiple areas. The gray histogram position characteristics are calculated in each area, and the image is judged whether there is reflection.
Effectively determine whether the image has reflection, reduce the phenomenon of authentic products being judged as fakes due to image reflection, and improve the stability and robustness of anti-counterfeiting identification.
Smart Images

Figure CN115908319B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to image processing technology, and in particular to a micro-code reflection detection method and device based on grayscale histogram discreteness. Background Art
[0002] With the popularization of smart devices, image anti-counterfeiting technology is becoming more and more popular. A new type of micro-image code has been designed. The micro-image code is a combination of QR code + micro-image anti-counterfeiting code, which has the functions of pre-sale anti-counterfeiting, product traceability, prevention of parallel trading and smart marketing. The micro-image anti-counterfeiting code is a dense dot matrix pattern designed, which is more conducive to the random diffusion of ink during printing. The micro-image anti-counterfeiting technology compares the diffusion effect of ink in subtle places by taking a clear and stable image with a mobile phone and comparing it with the server template image.
[0003] In actual application, due to the shooting angle of smartphones, the smooth ink will reflect light, which will interfere with the details of the image and affect the final result of micro-image anti-counterfeiting, which may cause the genuine product to become a fake, which is intolerable in the market. Based on this background, a grayscale histogram-based anti-counterfeiting code image reflection detection method is proposed. When the image is detected as a reflective image, the result is determined to be unreliable and the user is asked to take a photo again for verification. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a micro-code reflective detection method and device based on the discreteness of the grayscale histogram in view of the defects in the prior art.
[0005] The technical solution adopted by the present invention to solve the technical problem is: a micro-code reflective detection method based on the discreteness of the grayscale histogram, comprising the following steps:
[0006] Step 1) taking a photo to obtain a sample image of the micro-code; the micro-code includes a QR code area and an anti-counterfeiting area; the anti-counterfeiting area includes a micro-code anti-counterfeiting code, wherein the micro-code anti-counterfeiting code is a pattern composed of dense dot matrix;
[0007] Step 2) Locate and deduct the regional image of the micro-image anti-counterfeiting code, divide the regional image of the micro-image anti-counterfeiting code into N parts at the center point, where N is greater than or equal to 4; calculate the grayscale histogram of the regional image of the micro-image anti-counterfeiting code by region;
[0008] Step 3) Calculate the bimodal position features of the grayscale histogram of each region, and determine whether the image has reflection based on the bimodal features of the histogram;
[0009] 3.1) Calculate the positions of the two peaks of the grayscale histogram of region N, denoted as G ij ; G ij Indicates the position of the jth peak of the grayscale histogram of region i;
[0010] Find the maximum relative difference between the two peak positions:
[0011] Δx=Max(G 10 ,G 20 ,G 30 …,G N0 )-Min(G 10 ,G 20 ,G 30 …,G N0 )
[0012] Δy=Max(G 11 ,G 21 ,G 31 …,G N1 )-Min(G 11 ,G 21 ,G 31 …,G N1 )
[0013] According to the preset low brightness peak relative position difference threshold T x , high brightness peak relative position difference threshold T y ;
[0014] 3.2) When Δx>T x or Δy>T y When , it is judged that there is reflection in the image;
[0015] 3.3) When Δx≤T x And Δy≤T y When , in the four areas of the grayscale histogram, the grayscale concentration of the peak position interval is calculated with two peaks as the center points;
[0016] When P <P x , judge the image as luminous, where P x is the grayscale concentration value threshold; S1, S2,…, S N They are the interval pixels of the two peak positions in the four regions of the image, and the total number of pixels in the image is S.
[0017] According to the above scheme, in step 1), a micro code sample image is obtained by taking a photo with a mobile smart terminal.
[0018] According to the above scheme, in step 2), the details are as follows:
[0019] Step 2.1) locate and extract the target image area, and correct and normalize the extracted image;
[0020] Step 2.2) calculating the grayscale histogram distribution of the corrected target image by region;
[0021] Step 2.3) Smooth the histogram.
[0022] According to the above scheme, the regional image of the micro-image anti-counterfeiting code is located and deducted in step 2.1), as follows:
[0023] After smoothing and binarizing the anti-counterfeiting pattern in the microcode sample image, the contour is found, and the rectangle that conforms to the square in the contour is selected as the target contour. The contour is extracted, and the target image is extracted using image affine transformation.
[0024] According to the above scheme, in step 2.3), the histogram is smoothed using median filtering.
[0025] The beneficial effects produced by the present invention are:
[0026] When the method of the present invention is used, when the image is reflective as a whole or partially, the method is used to determine whether it is reflective, thereby providing accurate information for a subsequent anti-counterfeiting code verification method, reducing the phenomenon of authentic products being judged as counterfeits due to image reflection, improving the stability of anti-counterfeiting identification, and greatly improving the robustness of identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0028] Figure 1 is a method flow chart of an embodiment of the present invention;
[0029] Figure 2 2 is a schematic diagram for comparing feature extraction according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0031] like Figure 1 As shown, the present invention provides a micro-code reflective detection method based on the discreteness of the grayscale histogram, comprising the following steps:
[0032] Step 1: Take a photo with your mobile phone to obtain a sample image of the microcode;
[0033] Step 2: Locate and deduct the anti-counterfeiting area image of the micro-code, divide the anti-counterfeiting area into 4 parts at the center point, and calculate the grayscale histogram of the anti-counterfeiting code image by area;
[0034] Step 3: Calculate the bimodal position features of the grayscale histogram of each region, and determine whether the image is reflective based on the bimodal features of the histogram;
[0035] The micro-code anti-counterfeiting area is the target area. The micro-code is a combination of a QR code and a micro-code anti-counterfeiting code, and has the functions of pre-sale anti-counterfeiting, product traceability, prevention of counterfeiting and smart marketing. The micro-code anti-counterfeiting code is a specially designed dense dot matrix pattern, which is more conducive to the random diffusion of ink during printing. The anti-counterfeiting code image has a two-level grayscale distribution feature. In this embodiment, the micro-code anti-counterfeiting code is also designed with 3 white circles for positioning.
[0036] The micro-code anti-counterfeiting area is located and deducted by smoothing and filtering the anti-counterfeiting area image, binarizing it, finding the outline, screening the rectangles that conform to the square in the outline, and judging whether there are three white circles in the square outline. If there are three white circles, it is the target outline, extracting the outline, and using the image affine transformation to extract the target image and normalize the size.
[0037] Step 2.2: Divide the corrected anti-counterfeiting code area into regions and extract grayscale histogram features.
[0038] Step 2.3: Use median filtering to smooth the histogram.
[0039] like Figure 2 As shown, in step 3: using extreme values to find four grayscale histograms, after calculating the bimodal features of the histograms of each region, the bimodal features are comprehensively analyzed. The bimodal positions of the four regions of the normal image are not much different, and the image grayscale is concentrated in the bimodal position area. For the reflective image, the bimodal position shifts to high brightness, the grayscale distribution is not concentrated, and the high brightness peak has a large position difference. The specific implementation is as follows,
[0040] 1). Calculate the positions of the two peaks of the grayscale histogram of the 4 regions, respectively G 00 ,G 01 ,G 10 ,G 11 ,G 20 ,G 21 ,G 30 ,G 31 . Find the maximum relative difference between the two peak positions:
[0041] Δx=Max(G 00 ,G 10 ,G 20 ,G 30 )-Min(G 00 ,G 10 ,G 20 ,G 30 )
[0042] Δy=Max(G 01 ,G 11 ,G 21 ,G 31 )-Min(G 01 ,G 11,G 21 ,G 31 )
[0043] By analyzing the relative position differences of the two peaks in the four regions of normal image data and blurred data, the relative position difference threshold T of the low brightness peak is obtained. x , high brightness peak relative position difference threshold T y When Δx>T x or Δy>T y , the image is judged to be reflective.
[0044] 2) When Δx≤T x And Δy≤T y When , it indicates that the peak positions of the four regions are relatively concentrated. At this time, it is necessary to analyze the concentration of the image grayscale. In the grayscale histogram, take the two peaks as the center point, extract the number of pixels in the ±20 interval, calculate the sum of the pixels in the two regions, and record the pixel and statistical data of the peak position intervals of the four regions of the image as: S0, S1, S2, S3, and the total number of pixels in the image is S. Grayscale concentration calculation value: By analyzing the grayscale concentration calculation values of normal image data and reflection data, the grayscale concentration value threshold P is obtained. x , when P <P x , judge the image as luminous.
[0045] When the method of the present invention is used, when the image is reflective as a whole or partially, the method is used to determine whether it is reflective, thereby providing accurate information for a subsequent anti-counterfeiting code verification method, reducing the phenomenon of authentic products being judged as counterfeits due to image reflection, improving the stability of anti-counterfeiting identification, and greatly improving the robustness of identification.
[0046] According to the above method, the present invention also provides a micro-code reflective detection device based on the discreteness of the grayscale histogram, comprising:
[0047] A module is used to take a photo to obtain a sample image of a micro-code; the micro-code includes a QR code area and an anti-counterfeiting area; the anti-counterfeiting area includes a micro-code anti-counterfeiting code, wherein the micro-code anti-counterfeiting code is a pattern composed of dense dot matrix;
[0048] A grayscale histogram calculation module is used to locate and deduct the regional image of the micro-image anti-counterfeiting code, divide the regional image of the micro-image anti-counterfeiting code into N parts at the center point, where N is greater than or equal to 4; and then calculate the grayscale histogram of the regional image of the micro-image anti-counterfeiting code by region;
[0049] In the grayscale histogram calculation module, the grayscale histogram of the micro-image anti-counterfeiting code area image is calculated as follows:
[0050] 1) Locate and extract the target image area, and correct and normalize the extracted image;
[0051] 2) Calculate the grayscale histogram distribution of the corrected target image by region;
[0052] 3) Smoothing the histogram;
[0053] The judgment module is used to calculate the bimodal position characteristics of the grayscale histogram of each region, and judge whether there is reflection in the image according to the bimodal characteristics of the histogram; the judgment process is as follows:
[0054] 1) Calculate the positions of the two peaks of the grayscale histogram in region N, denoted as G ij ; G ij Indicates the position of the jth peak of the grayscale histogram of region i;
[0055] Find the maximum relative difference between the two peak positions:
[0056] Δx=Max(G 10 ,G 20 ,G 30 …,G N0 )-Min(G 10 ,G 20 ,G 30 …,G N0 )
[0057] Δy=Max(G 11 ,G 21 ,G 31 …,G N1 )-Min(G 11 ,G 21 ,G 31 …,G N1 )
[0058] According to the preset low brightness peak relative position difference threshold T x , high brightness peak relative position difference threshold T y ;
[0059] 3.2) When Δx>T x or Δy>T y When , it is judged that there is reflection in the image;
[0060] 3.3) When Δx≤T x And Δy≤T y When , in the four areas of the grayscale histogram, the grayscale concentration of the peak position interval is calculated with two peaks as the center points;
[0061] When P <P x , judge the image as luminous, where P x is the grayscale concentration value threshold; S1, S2,…, S NThey are the interval pixels of the two peak positions in the four regions of the image, and the total number of pixels in the image is S.
[0062] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A micro-code reflective detection method based on the discreteness of grayscale histogram, comprising the following steps: Step 1) taking a photo to obtain a sample image of the micro-code; the micro-code includes a QR code area and an anti-counterfeiting area; the anti-counterfeiting area includes a micro-code anti-counterfeiting code, wherein the micro-code anti-counterfeiting code is a pattern composed of dense dot matrix; Step 2) Locate and deduct the regional image of the micro-image anti-counterfeiting code, divide the regional image of the micro-image anti-counterfeiting code into N parts at the center point, where N is greater than or equal to 4; calculate the grayscale histogram of the regional image of the micro-image anti-counterfeiting code by region; Step 3) Calculate the bimodal position features of the grayscale histogram of each region, and determine whether the image has reflections based on the bimodal features of the histogram; the determination process is as follows: 3.1) Calculate the positions of the two peaks of the grayscale histogram of region N, denoted as G ij ; G ij Indicates the position of the jth peak of the grayscale histogram of region i; Find the maximum relative difference between the two peak positions: Δx=Max(G 10 ,G 20 ,G 30 …,G N0 )-Min(G 10 ,G 20 ,G 30 …,G N0 ) Δy=Max(G 11 ,G 21 ,G 31 …,G N1 )-Min(G 11 ,G 21 ,G 31 …,G N1 ) According to the preset low brightness peak relative position difference threshold T x , high brightness peak relative position difference threshold T y ; 3.2) When Δx>T x or Δy>T y When , it is determined that the image has reflection; 3.3) When Δx≤T x And Δy≤T y When , in the N areas of the grayscale histogram, the peak position interval is determined with two peaks as the center points, and the grayscale concentration P of the peak position interval is calculated; When P <P x , judge the image as luminous, where P x is the grayscale concentration value threshold; S1, S2, …S N They are the interval pixels between the two peak positions in the N region of the image, and the total number of pixels in the image is S.
2. The micro-code reflective detection method based on grayscale histogram discreteness according to claim 1 is characterized in that: In the step 1), a microcode sample image is obtained by taking a photo with a mobile smart terminal.
3. The micro-code reflective detection method based on grayscale histogram discreteness according to claim 1 is characterized in that: In the step 2), the details are as follows: Step 2.1) locate and extract the target image area, and correct and normalize the extracted image; Step 2.2) calculating the grayscale histogram distribution of the corrected target image by region; Step 2.3) Smooth the grayscale histogram.
4. The micro-code reflective detection method based on grayscale histogram discreteness according to claim 3 is characterized in that: The location and deduction of the regional image of the micro-image anti-counterfeiting code in step 2.1) are as follows: After smoothing and binarizing the anti-counterfeiting pattern in the microcode sample image, the contour is found, and the rectangle that conforms to the square in the contour is selected as the target contour. The contour is extracted, and the target image is extracted using image affine transformation.
5. The micro-code reflective detection method based on grayscale histogram discreteness according to claim 3 is characterized in that: In the step 2.3), the histogram is smoothed using median filtering.
6. A micro-code reflective detection device based on the discreteness of grayscale histogram, characterized in that: include: A module is used to take photos to obtain sample images of microcodes; The micro-code includes a QR code area and an anti-counterfeiting area; The anti-counterfeiting area includes a micro-image anti-counterfeiting code, wherein the micro-image anti-counterfeiting code is a pattern composed of dense dot matrix; A grayscale histogram calculation module is used to locate and deduct the regional image of the micro-image anti-counterfeiting code, divide the regional image of the micro-image anti-counterfeiting code into N parts at the center point, where N is greater than or equal to 4; and then calculate the grayscale histogram of the regional image of the micro-image anti-counterfeiting code by region; The judgment module is used to calculate the bimodal position characteristics of the grayscale histogram of each region, and judge whether there is reflection in the image according to the bimodal characteristics of the histogram; the judgment process is as follows: 1) Calculate the positions of the two peaks of the grayscale histogram in region N, denoted as G ij ; G ij Indicates the position of the jth peak of the grayscale histogram of region i; Find the maximum relative difference between the two peak positions: Δx=Max(G 10 ,G 20 ,G 30 …,G N0 )-Min(G 10 ,G 20 ,G 30 …,G N0 ) Δy=Max(G 11 ,G 21 ,G 31 …,G N1 )-Min(G 11 ,G 21 ,G 31 …,G N1 ) According to the preset low brightness peak relative position difference threshold T x , high brightness peak relative position difference threshold T y ; 3.2) When Δx>T x or Δy>T y When , it is determined that the image has reflection; 3.3) When Δx≤T x And Δy≤T y When , in the N areas of the grayscale histogram, the peak position interval is determined with two peaks as the center points, and the grayscale concentration P of the peak position interval is calculated; When P <P x , judge the image as luminous, where P x is the grayscale concentration value threshold; S1, S2, …S N They are the interval pixels between the two peak positions in the N region of the image, and the total number of pixels in the image is S.
7. The micro-code reflective detection device based on grayscale histogram discreteness according to claim 6 is characterized in that: In the step 1), a microcode sample image is obtained by taking a photo with a mobile smart terminal.
8. The micro-code reflective detection device based on grayscale histogram discreteness according to claim 6 is characterized in that: In the grayscale histogram calculation module, the grayscale histogram of the micro-image anti-counterfeiting code area image is calculated as follows: 1) Locate and extract the target image area, and correct and normalize the extracted image; 2) Calculate the grayscale histogram distribution of the corrected target image by region; 3) Smooth the histogram.
Citation Information
Patent Citations
A deep learning and shape detection combined two-dimensional code positioning method and system
CN109740395A
Bright spot detection method and device, equipment and storage medium
CN115345887A