A method for enhancing 3D codes based on image colors

By optimizing the 3D code generation method by obtaining the brightness value of the background image and the average brightness value of the neighborhood, the problem of poor fusion effect between the code points and the background image is solved, and a balance between visual effect optimization and reading performance of 3D codes is achieved.

CN114565518BActive Publication Date: 2025-10-28CN3WM XIAMEN NETWORK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111681820.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-10-28
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

In existing 3D code generation methods, the fusion effect between code dots and background images is awkward, and existing optimization methods are cumbersome, slow in recognition speed, or lose color information after fusion, resulting in poor visual effects.

Method used

By obtaining the maximum and minimum brightness values ​​of the background image, the target brightness value of each code point is determined and converted into a target color value to generate a 3D code. The color tone variation is optimized by combining the average brightness value of the neighborhood to ensure the 3D code reading performance.

Benefits of technology

While ensuring the performance of 3D barcode reading, the fusion effect between the barcode dots and the background image has been enhanced, the color information of the background image has been preserved, and the visual effect has been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114565518B_ABST
    Figure CN114565518B_ABST
Patent Text Reader

Abstract

This invention relates to a method for enhancing 3D codes based on image colors, comprising: acquiring a background image; selecting a code generation area on the background image; calculating the maximum and minimum brightness values ​​of pixels within the code generation area; determining the target brightness value of each code point based on the maximum and minimum brightness values; determining the target color value of each code point based on the target brightness value; and generating a code point matrix within the code generation area based on the target color value of each code point to obtain a 3D code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for enhancing 3D codes based on image colors, belonging to the field of 3D codes. Background Technology

[0002] A QR code is a symbol that represents information using black and white alternating patterns in both the horizontal and vertical directions of a plane. By fusing a QR code with a background image, a 3D code can be obtained (see patent CN106991462A, "3D Code Generation Method"). The background image can be a company logo, trademark, product logo, face, application scene, etc. Besides providing data information, 3D codes also provide visual information. However, the code dots and background image inevitably interfere with each other. Existing 3D code generation methods result in a rather abrupt fusion of code dots and background images, necessitating a method to optimize the visual effect of 3D codes while maintaining their readability.

[0003] In patent CN107563476B, "A Method for Beautifying and Anti-counterfeiting QR Codes," when merging the QR code with a background image, the initial RGB values ​​of the 0-values ​​of the QR code matrix with a black background are set to (200, 200, 200) to make the color grayish; the initial RGB values ​​of the 1-values ​​are set to (0, 0, 0) to prevent black dots from being identified as white dots because the background is black; the initial RGB values ​​of the 0-values ​​of the QR code matrix with a white background are set to (220, 220, 220) to make the color... A slightly whiter color scheme improves the overall visual effect. The initial RGB value of 1 is set to (50, 50, 50) to make the black dots appear grayish, achieving a softer look. After setting the initial values, the QR code matrix uses a binary search to extract values ​​between (200, 200, 200) and (220, 220, 220) for 0 values ​​and between (0, 0, 0) and (50, 50, 50) for 1 values, generating a QR code for reverse recognition. The optimal RGB value combination is selected based on recognition speed. However, the fusion effect between the background image and the QR code needs further improvement, and using a binary search to select the fastest QR code to ensure 3D barcode reading performance is cumbersome and time-consuming.

[0004] Patent CN108665434, "Image Synthesis Method and Apparatus," discloses the following steps: mapping a first color in a QR code image to a first color level range, and mapping a second color in the QR code image to a second color level range; obtaining the pixel value CVij of the first pixel point Cij located in the i-th row and j-th column of the background image; defining the pixel value QVij of the second pixel point Qij located in the i-th row and j-th column of the QR code image as 0 or 1 based on the first and second colors; mapping the pixel value CVij of the first pixel point Cij at the corresponding position in the background image to the first color level range or the second color level range, respectively, to obtain the third pixel point Eij of the pixel value EVij at the corresponding position, and generating a synthesized QR code image based on the third pixel point Eij. While this invention adjusts the background image color based on the QR code color to a certain extent to ensure the readability of the 3D code, the resulting 3D code loses color information, resulting in poor visual effects. Summary of the Invention

[0005] To overcome the problems existing in the prior art, this invention designs a method for beautifying 3D codes based on image colors.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] A method for enhancing 3D codes based on image colors includes the following steps:

[0008] Get the background image;

[0009] Select the code area on the background image;

[0010] Calculate the maximum and minimum brightness values ​​of the pixels within the generated code area;

[0011] Based on the maximum and minimum brightness values, determine the target brightness value for each code point;

[0012] Based on the target brightness value of each code point, determine the target color value of each code point respectively;

[0013] Based on the target color value of each code point, a code point matrix is ​​generated within the code generation area to obtain a three-dimensional code.

[0014] Furthermore, the brightness value of the pixel is calculated based on the RGB value of the pixel, expressed by the formula:

[0015] L i =0.299*R i +0.587*G i +0.114*B i

[0016] Where, L iRepresents the brightness value of a pixel; R i Represents the R component in the RGB value of a pixel; G i Represents the G component in the RGB value of a pixel; B i This represents the B component in the RGB value of a pixel.

[0017] Furthermore, determining the target brightness value of each code point based on the maximum and minimum brightness values ​​specifically involves:

[0018] Set the target brightness value of the first code point to the maximum brightness value, and set the target brightness value of the second code point to the minimum brightness value.

[0019] Furthermore, let the target color value of the first code point be the color value of the pixel corresponding to the maximum brightness value, and the target color value of the second code point be the color value of the pixel corresponding to the minimum brightness value.

[0020] Furthermore, it also includes: calculating the neighborhood average brightness value of the code point within its neighborhood range;

[0021] The target brightness value of each code point is determined based on the maximum brightness value, the minimum brightness value, and the average brightness value of the neighborhood.

[0022] Furthermore, the determination of the target brightness value for each code point based on the maximum brightness value, minimum brightness value, and neighborhood average brightness value is expressed by the following formula:

[0023]

[0024] Where, L target Indicates the target brightness value of a pixel; L c L represents the average brightness value of the neighborhood. min Indicates the minimum brightness value; L max This indicates the maximum brightness value.

[0025] Furthermore, the target color value specifically refers to the pixel target RGB value; the target color value of the code point is determined based on the target brightness value of the code point, expressed by the formula:

[0026] R target =L target G target =L target B target =L target

[0027] Where, L target Represents the target brightness value of a pixel; R target Represents the R component in the RGB value of a pixel target; G target Represents the G component in the RGB value of a pixel target; B target This represents the B component in the RGB value of a pixel target.

[0028] Compared with the prior art, the present invention has the following features and beneficial effects:

[0029] 1. This invention determines the target brightness value of each code point based on the maximum and minimum brightness values ​​of the code generation area in the background image, and then converts the target brightness value into the target color value of the code point. While ensuring the 3D code reading performance, it enhances the fusion effect of the code points relative to the background image and retains the color information of the background image, thereby optimizing the visual effect of the 3D code.

[0030] 2. In this invention, the average brightness value of the code point's neighborhood is mapped to a wider color space based on the difference between the average brightness value of the code point's neighborhood and the maximum or minimum brightness value to obtain the target brightness value. Then, the target brightness value is converted into the code point's color value. While ensuring the performance of 3D code reading, the color tone variation of the code point is increased, and the code point is better integrated into the background image, further optimizing the visual effect.

[0031] 3. In this invention, the target color value of the code point is set to the RGB value of the pixel corresponding to the maximum or minimum brightness value. Then the color value of the code point is consistent with the color value of a certain pixel in the background image. Under the premise of ensuring the performance of 3D code reading, a colored code point that is integrated into the background image is obtained, further optimizing the visual effect. Attached Figure Description

[0032] Figure 1 This is a flowchart of the invention;

[0033] Figure 2 This is a background image illustration;

[0034] Figure 3 This is a schematic diagram of the raw code area;

[0035] Figure 4 This is a schematic diagram of the 3D code generated in Example 4;

[0036] Figure 5 This is a schematic diagram of the 3D code generated in Example 5;

[0037] Figure 6 This is a schematic diagram of the 3D code generated in Example 6. Detailed Implementation

[0038] The present invention will now be described in more detail with reference to the embodiments.

[0039] like Figure 1 As shown, a method for enhancing 3D codes based on image colors includes the following steps:

[0040] Get the background image;

[0041] Select the code area on the background image;

[0042] Statistically calculate the maximum and minimum brightness values ​​of pixels within the generated code area (when the background image is a black and white image, the brightness value is represented as a grayscale value);

[0043] Based on the maximum and minimum brightness values, determine the target brightness value for each code point;

[0044] The target color value of the code point is determined based on the target brightness value of the code point (the color value can be in RGB color mode, HEX color mode or other color mode);

[0045] Based on the target color value of each code point, a code point matrix is ​​generated within the code generation area to obtain a three-dimensional code.

[0046] The beneficial effects of this embodiment are as follows: Based on the maximum and minimum brightness values ​​of the code generation area in the background image, the target brightness value of each code point is determined, and then the target brightness value is converted into the target color value of the code point. While ensuring the 3D code reading performance, the fusion effect of the code points relative to the background image is enhanced, and the color information of the background image is preserved, thereby optimizing the visual effect of the 3D code.

[0047] Example 2

[0048] Enter a background image;

[0049] Select the raw code area on the background image. The side length of the raw code area is 2 pixels.

[0050] Obtain the encoding information I, and generate a code point matrix based on the encoding information I. In the code point matrix, dark code points represent 1 and light code points represent 0. The width of the code point matrix is ​​W. Calculate the number of pixels on the side of each code point according to the following formula.

[0051] mul = PX2 / W

[0052] The formula for calculating the brightness value of each pixel within the code area is as follows:

[0053] L i =0.299*R i +0.587*G i +0.114*B i

[0054] Where, L i Represents the brightness value of a pixel; R i Represents the R component in the RGB value of a pixel; G i Represents the G component in the RGB value of a pixel; B i This represents the B component in the RGB value of a pixel.

[0055] The average brightness value of each code point within its neighborhood is calculated using the following formula:

[0056]

[0057] Where, L c This represents the average brightness value of the neighborhood of the code point; n represents the total number of pixels in the neighborhood of the code point.

[0058] Find the maximum brightness value L max Minimum brightness value L min ;

[0059] Calculate the target luminance value L for each code point. target The formula is as follows:

[0060]

[0061] The target brightness value, which is the target RGB value for this code point, is calculated using the following formula:

[0062] R target =L target G target =L target B target =L target

[0063] Based on the target RGB color value of each code point, a code point matrix is ​​superimposed on the generated code area to obtain a three-dimensional code.

[0064] Building upon Example 1, this example goes a step further by utilizing local binarization in the 3D barcode reading principle (i.e., calculating the average brightness of a specified area around a pixel P, and determining whether pixel P is a black or white pixel by whether its brightness is greater than this average brightness). The beneficial effects are as follows: Based on the difference between the average brightness value of the barcode's neighborhood and the maximum or minimum brightness value, the average brightness value of the barcode's neighborhood is mapped to a wider color space to obtain the target brightness value. Then, the target brightness value is converted into the barcode's color value. While ensuring the 3D barcode reading performance, this increases the color variation of the barcode, making the barcode blend more seamlessly into the background image and further optimizing the visual effect.

[0065] Example 3

[0066] The difference between this embodiment and embodiment two is that: after obtaining the maximum and minimum brightness values ​​within the generated code area, the RGB values ​​(RGB values) of the pixels corresponding to the maximum and minimum brightness values ​​are stored. Lmax RGB Lmin And set the target color value of the dark code point to RGB. Lmax The target color value of the light-colored code point is RGB. Lmin When the background image has distinct light and dark colors, the code point colors are the light and dark colors of the background image, and the code points are colorful and blend into the background image.

[0067] This embodiment is based on global binarization in the principle of 3D barcode recognition (i.e., setting a fixed threshold brightness for the entire image, where pixels with brightness greater than this threshold are considered white pixels and pixels with brightness less than this threshold are considered black pixels), achieving the following beneficial effects: if the target color value of the barcode point is set to the RGB value of the pixel corresponding to the maximum or minimum brightness value, then the color value of the barcode point is consistent with the color value of a certain pixel in the background image. Under the premise of ensuring the performance of 3D barcode recognition, colored barcode points that blend into the background image are obtained, further optimizing the visual effect.

[0068] Example 4

[0069] Input background image P1; background image P1 is as follows Figure 2 As shown, the side length is 800 pixels.

[0070] Select the raw code area P2 on the background image P1; the raw code area P2 is as follows: Figure 3 As shown, the side length of the generated code region P2 is 800 pixels. The matrix width is 33, therefore the side length in pixels, mul, is 27.

[0071] The maximum brightness value L within the raw code area P2 was obtained through calculation and searching. max =255, minimum brightness value L min =65. Calculate the target luminance value L for each code point according to the formula described in Example 2. target Target brightness value L target This refers to the target RGB value of the code point. A code point matrix is ​​superimposed on the generated code area according to the target RGB value to obtain the three-dimensional code, as shown below. Figure 4 As shown.

[0072] Example 5

[0073] The difference between this embodiment and embodiment four is that different code-generating regions P2 are selected, resulting in three-dimensional codes as follows: Figure 5 As shown.

[0074] Example 6

[0075] The difference between this embodiment and embodiment four is that the RGB values ​​of the code points are set to the RGB values ​​of the pixels corresponding to the maximum or minimum brightness values, resulting in a 3D code as follows: Figure 6 As shown.

[0076] Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

Claims

1. A method for enhancing 3D codes based on image colors, characterized in that, Includes the following steps: Get the background image; Select the code area on the background image; Calculate the maximum and minimum brightness values ​​of the pixels within the generated code area; Based on the maximum and minimum brightness values, determine the target brightness value for each code point; Based on the target brightness value of each code point, determine the target color value of each code point respectively; Based on the target color value of each code point, a code point matrix is ​​generated in the code generation area to obtain a three-dimensional code. It also includes: calculating the neighborhood average brightness value of the code point within its neighborhood range; The target brightness value for each code point is determined based on the maximum brightness value, minimum brightness value, and average brightness value of the neighborhood, expressed by the formula: Where, L target Indicates the target brightness value of a pixel; L c L represents the average brightness value of the neighborhood. min Indicates the minimum brightness value; L max This indicates the maximum brightness value.

2. The method for enhancing 3D codes based on image colors according to claim 1, characterized in that, The brightness value of the pixel is calculated based on the pixel's RGB values, expressed by the formula: L i =0.299*R i +0.587*G i +0.114*B i Where, L i Represents the brightness value of a pixel; R i Represents the R component in the RGB value of a pixel; G i Represents the G component in the RGB value of a pixel; B i This represents the B component in the RGB value of a pixel.

3. The method for enhancing 3D codes based on image color according to claim 1, characterized in that, The target color value is specifically the pixel target RGB value; the target color value of the code point is determined based on the target brightness value of the code point, expressed by the formula: R target =L target ;G target =L target ;B target =L target Where, L target Indicates the target brightness value of a pixel; R target Represents the R component in the RGB value of a pixel target; G target Represents the G component in the RGB value of a pixel target; B target This represents the B component in the RGB value of a pixel target.

Citation Information

Patent Citations

  • Three-dimensional code generating method

    CN106991462A

  • A method for beautifying and preventing counterfeiting of QR codes

    CN107563476B

  • Three-dimensional code optimization method, medium, computer equipment and device

    CN110009082A