Method for generating damaged two-dimensional code

By performing curves, straight scratches and wear treatments on the QR codes, combined with background image fusion and blurring, the problem of damaged QR codes in the existing technology is solved, and the generated QR codes are more visually more Natural and coordinated, adapted to a variety of application scenarios, enhancing its sense of reality and credibility.

CN119251066APending Publication Date: 2025-01-03WUXI IDATA TECHNOLOGY COMPANY LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411497711.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The existing QR code generation technology cannot effectively simulate the damaged characteristics that may occur in actual use of QR codes, resulting in the generated damaged QR code not being true enough and cannot meet the needs of training and evaluating QR code identification systems.

Method used

By performing curve scratches, straight scratches, wear generation and other treatments on the ideal QR code, combined with the background image for fusion and blurring, we generate damaged QR codes that are more in line with the actual usage, and using the Poisson ratio fusion algorithm Eliminate the boundary differences between QR codes and backgrounds to ensure that the generated QR codes are visually natural and coordinated.

Benefits of technology

The generated damaged QR code has enhanced visual reality and is rich in adaptability. It can effectively simulate a variety of damaged features, improve the expressiveness and readability of small-size damaged targets, avoid artificial visual effects, and enhance credibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119251066A_ABST
    Figure CN119251066A_ABST
Patent Text Reader

Abstract

The invention provides a damaged two-dimensional code generation method, and relates to the technical field of barcode generation. The method comprises the following steps: generating a two-dimensional code ideal graph; performing damage effect processing on the two-dimensional code ideal image to obtain a damaged two-dimensional code image; obtaining a background image; fusing the damaged two-dimensional code image with the background image to obtain a fused image; carrying out fuzzy processing on the fused image; and generating a damaged two-dimensional code image. According to the two-dimensional code generation method and system, various damaged features can be effectively simulated by combining an image processing technology, and meanwhile, the combination effect of the various damaged features is considered, so that the generated two-dimensional code has rich diversity and adaptability in different application scenes. In addition, fine-grained feature information is reserved as much as possible in the generation process, and the expressive force and readability of the small-size damaged target are improved. The boundary difference between the two-dimensional code and the background can be effectively eliminated, and it is ensured that the fused image is more natural and harmonious visually.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of barcode generation, and in particular to a method for generating a damaged two-dimensional code. Background Art

[0002] As an efficient information storage and transmission tool, QR codes (Quick Response Codes) have been widely used in areas such as product identification, payment systems, logistics tracking, and information sharing. QR code recognition algorithms are the core technology for quickly and accurately reading QR code information. These algorithms rely on scanning devices to quickly and accurately interpret image information. However, in practical applications, QR codes are prone to contamination, obstruction, and deformation, which can lead to recognition failures.

[0003] Existing QR code generation technology mainly focuses on generating QR codes in ideal conditions, but lacks effective simulation of the damaged features that may appear in actual use of QR codes. As a result, the generated damaged QR codes are not realistic enough and cannot meet the needs of training and evaluating QR code recognition systems. Summary of the Invention

[0004] The present invention provides a method for generating a damaged QR code, which is used to solve the problem in the prior art that the generated damaged QR code is not authentic enough and cannot meet the requirements of training and evaluating a QR code recognition system.

[0005] The present invention provides a method for generating a damaged two-dimensional code, comprising:

[0006] Generate an ideal QR code image;

[0007] Performing damage effect processing on the ideal QR code image to obtain a damaged QR code image;

[0008] Get the background image;

[0009] Fusing the damaged QR code image with the background image to obtain a fused image;

[0010] Performing blurring on the fused image;

[0011] Generates a damaged QR code image.

[0012] According to a method for generating a damaged two-dimensional code provided by the present invention, the damaged effect processing includes: generating curved scratches, generating straight scratches, and generating wear on an ideal two-dimensional code graph.

[0013] According to a method for generating a damaged two-dimensional code provided by the present invention, the method for generating curved scratches includes:

[0014] Randomly generate control points P0, P1, and P2, generate a curve using formula (1), and superimpose the curve on the ideal QR code image to form a curve scratch; formula (1) is:

[0015] B(t)=(1-t) 2 P0+2(1-t)tP1+t 2 P2 (1)

[0016] Where B(t) is the position of the point on the curve; t is a parameter with a value range of [0,1]. When t increases from 0 to 1, the point on the curve moves smoothly from P0 to P1 and P2 in sequence.

[0017] According to a method for generating a damaged two-dimensional code provided by the present invention, the method for generating a straight line scratch comprises:

[0018] Randomly generate a starting point and an ending point, connect the two points to form a straight line, and superimpose the straight line on the ideal QR code image to form a straight line scratch.

[0019] According to a method for generating a damaged two-dimensional code provided by the present invention, the method for generating a damaged two-dimensional code by wear and tear includes:

[0020] Randomly generate irregular polygonal areas, superimpose the polygonal areas on the ideal QR code image, and adjust the transparency of the polygonal areas to control the intensity of the wear effect; in this process, use formula (2):

[0021] I worn (x,y)=I fused (x,y)·(1-A(x,y))+I poly (x,y)·A(x,y) (2)

[0022] Among them, I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, I fused (x, y) is the pixel value of the image of the polygonal area superimposed on the ideal image of the QR code at the coordinate (x, y), I poly (x, y) is the pixel value at coordinate (x, y) of the polygonal area used to simulate the wear effect; A(x, y) is the weight mask, whose value is between [0, 1], which is used to control the influence of each pixel position in the fusion process;

[0023] After superimposing the wear effect, the image is faded by reducing the contrast C and brightness L of the image. In this process, formula (3) is used:

[0024]

[0025] Among them, I faded(x,y) is the pixel value of the faded image at coordinate (x,y), I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, C original is the contrast of the original image.

[0026] According to a method for generating a damaged two-dimensional code provided by the present invention, when fusing the damaged two-dimensional code image with the background image, formula (4) is used:

[0027]

[0028] Among them: I output (x,y) represents the pixel value of the fused output image at the coordinate (x,y); I source (x ′ ,y ′ ) indicates that the source damaged QR code image is at coordinate (x ′ ,y ′ )’s pixel value; is a normalization factor that ensures that the sum of all weights is 1; Ω represents the range of the neighborhood considered during the fusion process; (x ′ ,y ′ )∈Ω represents the pixels in the neighborhood area Ω, that is, several pixels around the current pixel (x, y); λ is a parameter that controls the weight decay rate.

[0029] According to a method for generating a damaged QR code provided by the present invention, after the damaged QR code image is fused with the background image, the brightness of the damaged QR code image is dynamically adjusted according to the lighting conditions of the background image. The adjustment formula (5) is:

[0030] I adjusted (x, y) = I output (x, y) + Δ L (5)

[0031] Among them, I adjusted (x, y) is the pixel value of the damaged QR code image at coordinate (x, y) after brightness adjustment, I output (x, y) is the pixel value of the damaged QR code image at coordinate (x, y) before brightness adjustment, and ΔL is the brightness value adjusted according to the lighting conditions of the background image.

[0032] According to a method for generating a damaged two-dimensional code provided by the present invention, blurring is performed on a fused image, comprising:

[0033] Generate random noise and superimpose it on the fused QR code image using formula (6):

[0034] I noisy (x,y)=Ifused (x,y)+N(x,y) (6)

[0035] Among them, I noisy (x,y) is the pixel value of the image at coordinate (x,y) after adding noise, I fused (x,y) is the pixel value of the fused image at the coordinate (x,y), and N(x,y) is the random noise value at the coordinate (x,y);

[0036] The image after adding noise is blurred, and the blur calculation formula (7) is:

[0037]

[0038] Among them: I blurred (x, y) is the pixel value of the blurred image at coordinate (x, y); I noisy (u,v) is the pixel value of the noisy image at coordinate (u,v); G(xu,yv) is a Gaussian weight function that calculates the weight based on the distance between the coordinate (x,y) and the coordinate (u,v) in the neighborhood.

[0039] σ is the blur degree parameter; K is the normalization constant that ensures that the total value of the weight sum is 1; Ω is the neighborhood range of the coordinate (x, y) during the blurring process.

[0040] According to a method for generating a damaged two-dimensional code provided by the present invention, before blurring the fused image, the method further includes performing cylindrical transformation on the fused image:

[0041] The fused image is transformed from the plane coordinate system to the cylindrical coordinate system using formula (8)

[0042] Line: x ′ =R·cos(θ),y ′ =R·sin(θ),z ′ =z(8)

[0043] Where: (x ′ ,y ′ ,z ′ ) is the transformed cylindrical coordinate; R is the radial distance on the XY plane; θ is the angle around the Z axis on the XY plane, in radians; z is the height coordinate of the image.

[0044] The method for generating a damaged QR code provided by the present invention, by combining image processing technology, can effectively simulate a variety of damaged features, such as scratches, stains and wear, thereby generating a damaged QR code that is more in line with actual usage and enhancing its visual realism. At the same time, the combined effect of a variety of damaged features is taken into account, so that the generated QR code has rich diversity and adaptability in different application scenarios. In addition, fine-grained feature information is retained as much as possible during the generation process to improve the expressiveness and readability of small-sized damaged targets. The Poisson's ratio fusion algorithm is used to effectively eliminate the boundary difference between the QR code and the background, ensuring that the fused image is more visually natural and coordinated. At the same time, through meticulous image processing, the blur and damage effects are ensured to be natural and realistic, avoiding the generation of artificial visual effects, making the generated damaged QR code more credible. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 1 is a flow chart of a method for generating a damaged QR code provided by the present invention;

[0047] Figure 2 This is one of the schematic diagrams of the damaged QR code generation process;

[0048] Figure 3 This is the second schematic diagram of the damaged QR code generation process;

[0049] Figure 4 This is a module block diagram of the system for generating a damaged QR code provided by the present invention. DETAILED DESCRIPTION

[0050] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0051] The following combination Figure 1-Figure 3 A method for generating a damaged QR code according to the present invention is described, comprising:

[0052] Generate an ideal QR code image;

[0053] Performing damage effect processing on the ideal QR code image to obtain a damaged QR code image;

[0054] Get the background image;

[0055] Fusing the damaged QR code image with the background image to obtain a fused image;

[0056] Performing blurring on the fused image;

[0057] Generates a damaged QR code image.

[0058] In the application, the steps for generating the ideal QR code image are as follows:

[0059] Regularized dot matrix generation algorithm: By creating a blank image object and redrawing the QR code image on it, the dot matrix effect is achieved. First, the original QR code image is converted into a grayscale image, and the spacing of the drawn dots is calculated based on the set dot size and density. Then, when traversing the image pixels, the set grayscale threshold is used to determine whether dots need to be drawn at a specific location. If the grayscale value of the pixel is lower than the threshold (that is, the darker area), a dot is drawn at the corresponding position. The final image is composed of these regularly arranged dots. By adjusting the dot size, density and threshold, the generated image can be flexibly controlled.

[0060] Perspective Transformation: After generating a QR code, you can apply affine and perspective transformations to simulate the visual effects of the QR code in real-world applications. This process adjusts the perspective of the QR code to ensure that it appears naturally at different viewing angles, enhancing its realism.

[0061] Among them, the affine transformation is realized by the following formula:

[0062]

[0063] Where (x, y) is the original QR code coordinate, (x′, y′) is the transformed coordinate, a, b, c, d are the elements of the affine transformation matrix, and tx, ty are the translation vectors.

[0064] The perspective transformation is implemented by the following formula:

[0065]

[0066] The damaged effect processing includes: generating curved scratches, generating straight scratches and generating wear on the ideal QR code image.

[0067] The method for generating curved scratches includes:

[0068] Randomly generate control points P0, P1, and P2, generate a curve using formula (1), and superimpose the curve on the ideal QR code image to form a curve scratch; formula (1) is:

[0069] B(t)=(1-t) 2 P0+2(1-t)tP1+t 2 P2 (1)

[0070] Where B(t) is the position of the point on the curve; t is a parameter with a value range of [0, 1] that controls the position of the curve points at different locations. As t increases from 0 to 1, the points on the curve move smoothly from P0 to P1 and P2, respectively. Random curved scratches based on Bezier curves are added to the image to simulate curved scratches that may appear in reality.

[0071] Among them, the method of generating straight line scratches includes:

[0072] Randomly generate a start and end point to define the direction and position of the line scratch. Connect the two points to form a straight line. Superimpose this line onto the ideal QR code image to form the line scratch. Ensure that the color and transparency of the scratch are consistent with the overall style of the image. Add random straight line scratches to the image to simulate common straight line damage.

[0073] Among them, the methods of wear generation include:

[0074] Randomly generate irregular polygonal areas, superimpose the polygonal areas on the ideal QR code image, and adjust the transparency of the polygonal areas to control the intensity of the wear effect; in this process, use formula (2):

[0075] I worn (x,y)=I fused (x,y)·(1-A(x,y))+I poly (x,y)·A(x,y) (2)

[0076] Among them, I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, I fused (x, y) is the pixel value of the image of the polygonal area superimposed on the ideal image of the QR code at the coordinate (x, y), I poly (x, y) is the pixel value of the polygonal area at coordinate (x, y) used to simulate the wear effect; A(x, y) is the weight mask (alpha mask), whose value is between [0, 1] and is used to control the influence of each pixel position in the fusion process.

[0077] Simulates localized wear effects such as scratches, abrasion, and more by randomly generating polygonal areas and overlaying them onto an image.

[0078] After superimposing the wear effect, the image is faded by reducing the contrast C and brightness L of the image. In this process, formula (3) is used:

[0079]

[0080] Among them, I faded (x,y) is the pixel value of the faded image at coordinate (x,y), I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, C original is the contrast of the original image. Contrast C and brightness L are constants, selected based on actual needs. After wear and tear overlay, the image's contrast and brightness are reduced to simulate image fading.

[0081] Furthermore, when fusing the damaged QR code image with the background image, formula (4) is used:

[0082] (4)

[0084] Among them: I output (x,y) represents the pixel value of the fused output image at the coordinate (x,y); I source (x ′ ,y ′ ) indicates that the source damaged QR code image is at coordinate (x ′ ,y ′ )’s pixel value; is a normalization factor that ensures that the sum of all weights is 1, ensuring that the intensity of the output pixel value does not exceed the expected range; Ω represents the neighborhood range considered in the fusion process; (x ′ ,y ′ )∈Ω represents the pixels in the neighborhood area Ω, that is, several pixels around the current pixel (x, y); λ is a parameter that controls the weight decay rate. A larger λ makes the weight decay faster with distance.

[0085] This step uses a Poisson's ratio fusion algorithm to seamlessly combine the QR code image with the background image, achieving a natural and harmonious visual effect. This algorithm effectively eliminates the boundary differences between the QR code and the background, making the fused image more visually natural and harmonious, thereby improving the user experience.

[0086] To further enhance the visual consistency between the QR code and the background, this application adjusts the lighting and color of the QR code using the following methods:

[0087] Furthermore, after the damaged QR code image is fused with the background image, the brightness of the damaged QR code image is dynamically adjusted according to the lighting conditions of the background image. The adjustment formula (5) is:

[0088] I adjusted (x,y)=I output (x,y)+ΔL (5)

[0089] Among them, I adjusted (x, y) is the pixel value of the damaged QR code image at coordinate (x, y) after brightness adjustment, I output (x,y) is the pixel value of the damaged QR code image at coordinate (x,y) before brightness adjustment, and ΔL is the brightness adjusted based on the background image's lighting conditions. This adjustment ensures the QR code remains visible against a variety of backgrounds.

[0090] Color correction: During the fusion process, a color space conversion method is used to convert the QR code's color space to match the background's color space. This process includes adjusting the hue, saturation, and brightness to ensure that the QR code's color is visually consistent with the background.

[0091] Fusion effect evaluation: After background fusion is completed, the fusion quality is evaluated by calculating the root mean square error (RMSE) of the fusion effect. The specific calculation formula (9) is:

[0092]

[0093] Among them, I target (i) is the pixel value of the target image, and N is the total number of pixels. By comparing the RMSE value of the output image with the target image, we can effectively evaluate the fusion effect and make necessary adjustments based on the results to ensure the high quality and naturalness of the final image.

[0094] Furthermore, the fused image is fuzzified, including:

[0095] Generate random noise and superimpose it on the fused QR code image using formula (6):

[0096] I noisy (x,y)=I fused (x,y)+N(x,y) (6)

[0097] Among them, I noisy (x,y) is the pixel value of the image at coordinate (x,y) after adding noise, I fused(x,y) is the pixel value of the fused image at the coordinate (x,y), and N(x,y) is the random noise value at the coordinate (x,y). Noise blur is introduced to simulate the blur effect that may occur in the actual use of the QR code.

[0098] The image after adding noise is blurred, and the blur calculation formula (7) is:

[0099]

[0100] Among them: I blurred (x, y) is the pixel value of the blurred image at coordinate (x, y); I noisy (u,v) is the pixel value of the noisy image at coordinate (u,v); G(xu,yv) is a Gaussian weight function that calculates the weight based on the distance between the coordinate (x,y) and the coordinate (u,v) in the neighborhood. σ is the blur parameter; K is a normalization constant that ensures the weights sum to 1; and Ω is the neighborhood of the coordinate (x, y) during the blurring process. A Gaussian blur algorithm is used to blur the image after adding noise, ensuring a natural and smooth blur effect.

[0101] Contrast and brightness adjustment: After noise blurring, adjust the contrast and brightness of the blurred image to further enhance the damage effect of the QR code. Specific operations include:

[0102] Contrast adjustment changes the contrast by adjusting the brightness histogram of the image, so that the QR code still has a certain degree of readability in a blurred state.

[0103] Brightness adjustment simulates the lighting changes that a QR code may experience in a real environment by increasing or decreasing the overall brightness of the image.

[0104] Final output: After noise blurring and subsequent adjustments, the generated image will simulate the actual damaged state of the QR code in a real environment, making it more visually realistic and credible.

[0105] Furthermore, before blurring the fused image, a cylindrical transformation is performed on the fused image:

[0106] The fused image is transformed from the plane coordinate system to the cylindrical coordinate system using formula (8)

[0107] Line: x ′ =R·cos(θ),y ′ =R·sin(θ),z ′ =z(8)

[0108] Where: (x ′ ,y ′,z ′ ) is the transformed cylindrical coordinate; R is the radial distance (polar diameter) on the XY plane; θ is the angle (polar angle) around the Z axis on the XY plane, in radians; z is the height coordinate of the image, which remains unchanged.

[0109] Cylindrical transformation is used to simulate the appearance of QR codes on different surfaces (such as curved or irregular surfaces) to enhance the application adaptability and realism of QR codes. The specific steps of this transformation method include:

[0110] Determine transformation parameters: Determine the parameters of the cylindrical transformation, including radius, angle, and height, based on the geometric characteristics of the target surface to adapt to the shape changes of the QR code on a specific surface.

[0111] Apply cylindrical coordinate transformation: Use the above formula (8).

[0112] Image resampling: After the cylindrical transformation is completed, image resampling is performed to ensure that the transformed QR code image maintains good quality. The resampling method can use bilinear interpolation or other adaptive interpolation algorithms to reduce image distortion.

[0113] Edge smoothing: After resampling, the edges of the QR code are smoothed to remove jagged edges caused by the transformation, improving the overall aesthetics and recognizability of the QR code.

[0114] Visual Enhancement: To further enhance the realism of the QR code, after completing the cylindrical transformation, the contrast and brightness can be adjusted to make the QR code appear more natural on the simulated surface. Additionally, consider overlaying localized wear or stain effects on the QR code to simulate the damaged state of the QR code in real applications.

[0115] It should be understood that the above-mentioned method for generating a damaged QR code is not absolute in the order of steps. The order of operations involved can be adjusted according to the actual application scenario of the QR code (i.e., different background images) to make the generated damaged QR code more realistic.

[0116] The damaged QR code generation system provided by the present invention is described below. The damaged QR code generation system described below and the damaged QR code generation method described above can refer to each other.

[0117] A system for generating damaged QR codes, such as Figure 4 Shown, including:

[0118] QR code ideal image generation module: used to generate the ideal QR code image; specifically, it includes: using a regularized dot matrix generation algorithm to generate the QR code image; performing perspective transformation to simulate the visual effect of the QR code in actual application;

[0119] Damage effect generation module: This module applies damage effects to the ideal QR code image to generate a damaged QR code image. This module includes: randomly generating polygonal areas to simulate local wear effects; adding random curved scratches and random straight scratches based on Bezier curves to the image to simulate various damage features that may appear in reality; blurring the generated damaged features to enhance the wear effect; and adjusting the brightness and contrast of the final QR code image to ensure the QR code has a certain degree of visual readability.

[0120] Background image acquisition module: used to randomly acquire a background image; the background image can be various object images in the actual application process of the QR code;

[0121] Fusion module: used to fuse the damaged QR code image with the background image to obtain a fused image;

[0122] Fuzzy processing module: used to perform fuzzy processing on the fused image;

[0123] Output module: used to generate and output damaged QR code images.

[0124] Furthermore, a cylindrical transformation module may be included between the fusion module and the blur processing module, for transforming the fused image from a plane coordinate system to a cylindrical coordinate system.

[0125] It should be noted that the working principle of the damaged QR code generation system of the present application is consistent with the damaged QR code generation method described above, and will not be elaborated on here.

[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for generating a damaged two-dimensional code, characterized in that: include: Generate an ideal QR code image; Performing damage effect processing on the ideal QR code image to obtain a damaged QR code image; Get the background image; The damaged two-dimensional code image is fused with the background image to obtain a fused image; Performing blur processing on the fused image; Generates a damaged QR code image.

2. The method for generating a damaged two-dimensional code according to claim 1, characterized in that: The damaged effect processing includes: generating curved scratches, generating straight scratches and generating wear on the ideal QR code image.

3. The method for generating a damaged two-dimensional code according to claim 2, characterized in that: The methods for generating curved scratches include: Randomly generate control points P0, P1, and P2, generate a curve using formula (1), and superimpose the curve on the ideal QR code image to form a curve scratch; formula (1) is: B(t)=(1-t) 2 P0+2(1-t)tP1+t 2 P2 (1) Where B(t) is the position of the point on the curve; t is a parameter with a value range of [0,1]. When t increases from 0 to 1, the point on the curve moves smoothly from P0 to P1 and P2 in turn.

4. The method for generating a damaged two-dimensional code according to claim 2, characterized in that: The methods for generating straight line scratches include: Randomly generate a starting point and an end point, connect the two points to form a straight line, and superimpose the straight line on the ideal QR code image to form a straight line scratch.

5. The method for generating a damaged two-dimensional code according to claim 2, characterized in that: Methods of wear generation include: An irregular polygonal area is randomly generated, and the polygonal area is superimposed on the ideal image of the two-dimensional code. The transparency of the polygonal area is adjusted to control the intensity of the wear effect. In this process, formula (2) is used: Yo worn (x,y)=I fused (x,y)·(1-A(x,y))+I poly (x,y)·A(x,y) (2) Among them, I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, I fused (x, y) is the pixel value of the image at coordinate (x, y) where the polygonal area is superimposed on the ideal image of the QR code. poly (x, y) is the pixel value of the polygonal area at the coordinate (x, y) used to simulate the wear effect; A(x, y) is the weight mask, whose value is between [0, 1], which is used to control the influence of each pixel position in the fusion process; After superimposing the wear effect, the image is faded by reducing the contrast C and brightness L of the image. In this process, formula (3) is used: Among them, I faded (x, y) is the pixel value of the faded image at coordinate (x, y), I worn (x, y) is the pixel value of the image at coordinate (x, y) after the wear effect is superimposed, C original is the contrast of the original image.

6. The method for generating a damaged two-dimensional code according to claim 1, characterized in that: When the damaged QR code image is fused with the background image, formula (4) is used: Where: I output (x, y) represents the pixel value of the fused output image at the coordinate (x, y); I source (x ′ ,y ′ ) indicates that the source damaged QR code image is at coordinate (x ′ ,y ′ )’s pixel value; is a normalization factor to ensure that the sum of all weights is 1; Ω represents the range of the neighborhood considered during the fusion process; (x ′ ,y ′ )∈Ω represents the pixels in the neighborhood area Ω, that is, several pixels around the current pixel (x, y); λ is the parameter that controls the weight decay rate.

7. The method for generating a damaged two-dimensional code according to claim 1, characterized in that: After the damaged QR code image is fused with the background image, the brightness of the damaged QR code image is dynamically adjusted according to the lighting conditions of the background image. The adjustment formula (5) is: I adjusted (x, y) = I output (x, y) + Δ L (5) Among them, I adjusted (x, y) is the pixel value of the damaged QR code image at coordinate (x, y) after adjusting the brightness. output (x, y) is the pixel value of the damaged QR code image at the coordinate (x, y) before brightness adjustment, and ΔL is the brightness value adjusted according to the lighting conditions of the background image.

8. The method for generating a damaged two-dimensional code according to claim 1, characterized in that: The fused image is fuzzy processed, including: Generate random noise and superimpose it on the fused QR code image using formula (6): I noisy (x,y)=I fused (x,y)+N(x,y) (6) Among them, I noisy (x, y) is the pixel value of the image at coordinate (x, y) after adding noise, I fused (x,y) is the pixel value of the fused image at the coordinate (x,y), and N(x,y) is the random noise value at the coordinate (x,y); The image after adding noise is blurred, and the blur calculation formula (7) is: Where: I blurred (x, y) is the pixel value of the blurred image at coordinate (x, y); noisy (u,v) is the pixel value of the noisy image at the coordinate (u,v); G(xu,yv) is a Gaussian weight function, which calculates the weight according to the distance between the coordinate (x,y) and the coordinate (u,v) in the neighborhood. σ is the blur degree parameter; K is the normalization constant to ensure that the total value of the weight sum is 1; Ω is the neighborhood range of the coordinate (x, y) during the blurring process.

9. The method for generating a damaged two-dimensional code according to claim 1, characterized in that: Before blurring the fused image, the fused image is also subjected to cylindrical transformation: The fused image is converted from the plane coordinate system to the cylindrical coordinate system using formula (8): ′ =R·cos(θ),y ′ =R·sin(θ),z ′ =z(8) Where: (x ′ ,y ′ ,z ′ ) is the transformed cylindrical coordinate; R is the radial distance on the XY plane; θ is the angle around the Z axis on the XY plane, in radians; z is the height coordinate of the image.