High-quality art two-dimensional code generation method and system based on intelligent area positioning

By using intelligent region positioning and multi-dimensional image feature analysis, artistic QR codes are generated, solving the problems of low generation efficiency and unstable fusion quality in existing technologies, and realizing high-quality and low-cost artistic QR code generation.

CN121503519APending Publication Date: 2026-02-10JIANGSU IND INTERNET DEV RES CENT

Patent Information

Application Number
CN202511622506.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing technologies fail to effectively analyze the differences in local image features when generating artistic QR codes, resulting in blurry, recognition failure, or style imbalance in the generated results. Furthermore, they waste significant computing resources, making it difficult to meet the commercial demands for batch and high-quality generation.

Method used

Intelligent region localization is performed on the source image using image analysis methods. Candidate regions are extracted using preset analysis window size and sliding step size. Multidimensional image feature values ​​are calculated and a region suitability score is generated. Unsuitable regions are eliminated, and generative fusion is performed only on the target region to generate an artistic QR code fragment that combines artistic texture features with a recognizable QR code structure.

Benefits of technology

It improves the generation quality and recognition stability of artistic QR codes, reduces computing resources and time costs, expands the scope of applicable materials, and provides greater flexibility and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121503519A_ABST
    Figure CN121503519A_ABST
Patent Text Reader

Abstract

The invention discloses a high-quality AIGC art two-dimensional code generation method and system based on intelligent area positioning. The method comprises the following steps: scanning a source image uploaded by a user, and dividing the source image into a plurality of candidate areas; for each candidate area, calculating a multi-dimensional image characteristic value, generating an area suitability score, eliminating an unsuitable area through a smoothness threshold elimination rule, and determining the candidate area with the highest area suitability score as a target area; extracting a target area image segment from the source image, and inputting the image segment and to-be-coded two-dimensional code data into a generative image fusion process to generate an artistic two-dimensional code segment; and backfilling the artistic two-dimensional code segment to a corresponding position of the source image to obtain a complete artistic two-dimensional code image. According to the method, the optimal fusion area can be automatically identified and positioned before generation, the generation success rate and the scanning identification rate of the AIGC art two-dimensional code are remarkably improved, the calculation cost is reduced, and the unification of the visual effect and the functionality is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of two-dimensional code generation, in particular to a high-quality artistic two-dimensional code generation method and system based on intelligent region positioning. BACKGROUND

[0002] With the wide application of two-dimensional codes in the fields of advertisement dissemination, brand packaging and artistic design, the traditional artistic two-dimensional code generation method has gradually developed from simple image superposition and color replacement to image style transfer and beautification using a deep learning model. In the prior art, the color of a two-dimensional code image is usually adjusted, the texture is replaced or the shape is deformed in a fixed template to improve the visual effect of the two-dimensional code. However, most of these methods are based on global processing of the entire image, and cannot analyze the local feature differences of the image in detail, nor can they combine generative artificial intelligence technology to deeply integrate the two-dimensional code structure and the artistic image.

[0003] The prior art has the problems of low generation efficiency, large calculation overhead and unstable fusion quality. Since the local complexity and smoothness of the source image are not effectively evaluated, when the input image contains a large smooth area or lacks key texture, the generation result is prone to have a blurred two-dimensional code structure, recognition failure or style imbalance. In addition, some methods rely on multiple generations and manual screening, resulting in waste of computing resources and difficulty in meeting the commercial demand for batch and high-quality generation.

[0004] Therefore, it is necessary to provide a method capable of intelligently analyzing and positioning the source image before generation to improve the generation quality and recognition stability of the artistic two-dimensional code. SUMMARY

[0005] The application provides a high-quality artistic two-dimensional code generation method and system based on intelligent region positioning to improve the generation quality and recognition stability of the artistic two-dimensional code.

[0006] The application provides a high-quality artistic two-dimensional code generation method based on intelligent region positioning, comprising: An image analysis method is used to scan a source image uploaded by a user, the source image is locally divided based on a preset analysis window size and a sliding step, and a plurality of candidate regions are extracted; For each candidate region, a plurality of image feature values including information entropy, edge density and smoothness are calculated, a region suitability score is generated according to the plurality of image feature values, and a region unsuitable for the region suitability score is removed according to an exclusion rule when the smoothness exceeds a preset threshold, and a candidate region with the highest region suitability score is determined as a target region; Based on the target region, a corresponding regional image segment is extracted from the source image, the regional image segment and the two-dimensional code data to be encoded are jointly input into an AIGC generation process, and an artistic two-dimensional code segment with artistic texture characteristics and two-dimensional code readable structure is generated by using a generative image fusion method. The artistic two-dimensional code segment is backfilled to the corresponding position of the source image to generate a complete artistic two-dimensional code image.

[0007] The beneficial effects of the present application include: (1) The present application can accurately identify the best fusion region with rich texture and complete details before generation by performing multi-dimensional local feature analysis on the source image, comprehensively calculating information entropy, edge density and smoothness, and setting a smoothness threshold exclusion mechanism. This method effectively avoids the problems of two-dimensional code structure distortion and scanning failure caused by insufficient image region texture, so that the generated artistic two-dimensional code has high visual quality and high readability. (2) The present application completes intelligent positioning of the target region before AIGC generation, and only generates a single optimal region, avoiding the "brute force and error" process of repeated generation and post-selection of multiple regions in the prior art. This pre-analysis mechanism reduces unnecessary model call times, greatly reduces the cost of computing power and time, and makes the generation process more efficient and economical. (3) Through the intelligent positioning mechanism, the present application can automatically identify the local region that can be fused in a complex or heterogeneous source image, so that an image containing a part of low-quality region can still be fully utilized. This "local optimization" method avoids the situation where the entire image is discarded, significantly expands the scope of suitable materials, and provides higher flexibility and scalability for artistic creation and commercial design. BRIEF DESCRIPTION OF DRAWINGS

[0008] Figure 1 is a flowchart of a high-quality artistic two-dimensional code generation method based on intelligent region positioning provided by the first embodiment of the present application.

[0009] Figure 2 is a schematic diagram of a high-quality artistic two-dimensional code generation system based on intelligent region positioning provided by the second embodiment of the present application. DETAILED DESCRIPTION

[0010] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application. However, the present application can be practiced in many different ways beyond the specific embodiments described herein, and it is understood that one of ordinary skill in the art can make and use the present application without departing from the scope of the present application. Therefore, the present application is not limited by the specific implementations disclosed below.

[0011] The first embodiment of the present application provides a high-quality artistic two-dimensional code generation method based on intelligent region positioning. Please refer to Figure 1 , which is a schematic diagram of the first embodiment of the present application. The following will be described in combination withFigure 1 The first embodiment of the present application provides a high-quality artistic two-dimensional code generation method based on intelligent area positioning.

[0012] Step S101: Scan the source image uploaded by the user using an image analysis method, divide the source image locally based on a preset analysis window size and sliding step, and extract a plurality of candidate regions.

[0013] The purpose of step S101 is to accurately extract several local regions from the source image uploaded by the user before generating the artistic two-dimensional code, and form a candidate region set for subsequent analysis and fusion, to ensure that the subsequent image fusion process has a clear spatial basis and operability. Those skilled in the art should understand that the source image refers to the image file provided by the user for processing, which can be a brand packaging design, an advertisement picture, an illustration work or a photography picture, usually a two-dimensional digital image stored in JPEG, PNG or BMP format. The source image can be a color image or a grayscale image, but its pixel data must exist in a matrix form, and each pixel point contains brightness or RGB color information. In order to ensure that the artistic two-dimensional code image generated finally has sufficient resolution and texture details, the width or height of the source image should be no less than 1000 pixels, preferably in the range of 1500 to 3000 pixels.

[0014] In this step, the source image is first scanned. Scanning refers to traversing and extracting the source image according to a preset step parameter to form a plurality of local regions with consistent size. In this embodiment, the preset analysis window size is used to define the size of the region extracted at a time, i.e. the width and height of the sub-region selected on the source image. The analysis window size can be determined according to the target size of the two-dimensional code, the overall resolution of the image and the expected fusion accuracy, for example, it can be set to 512 pixels x 512 pixels, 256 pixels x 256 pixels or other integer values. The larger the window size, the wider the coverage of the candidate region, but the higher the demand for computing resources; the smaller the window size, the more local details can be found, but the screening process requires more traversal times. According to the specific application scenario, the appropriate window size can be selected through experience or parameter tuning.

[0015] The sliding step refers to the pixel distance that the analysis window moves at each time when it slides over the source image, which is used to control the degree of overlap between adjacent extraction regions. For example, when the window size is 512x512 pixels and the sliding step is set to 128 pixels, it means that the analysis window moves 128 pixels in the horizontal direction or the vertical direction at each time, so that about 75% of the overlap coverage is formed between adjacent extraction regions. This overlap helps to avoid missing potential high-quality texture features located at the boundaries of the regions. If the sliding step is equal to the window size, there is no overlap between adjacent regions; if the sliding step is smaller than the window size, the adjacent regions are partially overlapped; if the sliding step is greater than the window size, there will be scanning gaps, which can cause part of the image to be unanalyzed, so the preferred step should be less than half of the window size.

[0016] In a specific implementation, the top-left pixel of the source image is set as the coordinate origin (x=0, y=0), and the analysis window is placed from this point. The analysis window is moved in the horizontal direction, and when the right boundary of the window is about to exceed the image boundary, the scanning of the current row is stopped; then the sliding step is moved downward in the vertical direction, and the scanning is restarted from the leftmost side until the lower boundary of the window reaches or approaches the lower edge of the image. For each window position, the corresponding image data is intercepted to form a candidate region. The candidate region can be represented as a structure containing position and pixel information, which includes: candidate region number, top-left coordinates (x, y), window width w, window height h, and pixel matrix in the window. Each candidate region corresponds to a specific position in the source image, and the image content can be accurately extracted or backfilled from the source image according to these coordinate information in the future.

[0017] In a preferred embodiment, in order to ensure the comparability of different source images in feature analysis, the source image should be pre-processed before scanning. The basic pre-processing can include size normalization, color space unification and noise suppression. Size normalization refers to adjusting the long side of the image to a predetermined range, such as 1200 to 2000 pixels, without changing the aspect ratio of the image, so that the actual physical proportion of the analysis window on different images is consistent. Color space unification refers to converting all images to the three-channel RGB color model to avoid deviations in brightness calculation or contrast analysis of images of different formats. Noise suppression can use conventional image processing methods such as median filtering, bilateral filtering or Gaussian blur, for example, by using a 3x3 or 5x5 sliding filter window to remove isolated noise points, so as to prevent noise points from being misjudged as effective textures in subsequent feature calculation.

[0018] The number of candidate regions depends on the size of the source image, the size of the analysis window, and the sliding step size. For example, assuming the source image resolution is 2048 pixels × 2048 pixels, the analysis window size is 512 pixels × 512 pixels, and the sliding step size is 128 pixels, then approximately [(2048−512) / 128]+1≈13 sampling locations can be formed in both the horizontal and vertical directions, generating a total of approximately 169 candidate regions. This calculation formula can be used to derive the number of candidate regions under any parameters, allowing for optimization based on computational resources and time requirements.

[0019] The candidate region set obtained through the above method forms the input basis for subsequent region suitability analysis. Since the extraction method, size, and location of each candidate region are strictly set according to uniform parameters, the entire scanning process is highly repeatable and verifiable. This step not only ensures the comprehensiveness and accuracy of image analysis but also provides a unified scale benchmark for subsequent region feature calculations, ensuring the comparability and objectivity of subsequent scoring results.

[0020] Furthermore, the image analysis method scans the user-uploaded source image, and based on a preset analysis window size and sliding step size, locally segments the source image to extract multiple candidate regions, including: The source image uploaded by the user is preprocessed by converting the color space of the source image into a uniform brightness-saturation-hue space and performing histogram equalization on the brightness channel to correct brightness deviations under different shooting devices or lighting conditions, thereby obtaining a standardized image. The standardized image is scanned according to a preset analysis window size. The sliding step size of the scan is dynamically adjusted according to the brightness change of pixels within the window. When the brightness change within the window is greater than a first threshold, a smaller sliding step size is used to improve the resolution of the local area. When the brightness change within the window is less than a second threshold, a larger sliding step size is used to reduce the overlapping area. Both the first threshold and the second threshold are preset fixed values. For each image region within an analysis window, the brightness gradient change and texture direction change are calculated, and the two are combined to form region feature description data. The region feature description data includes statistical values ​​of pixel brightness change, statistical values ​​of texture direction change, and their position index information within the window. Based on the regional feature description data, the similarity of adjacent regions is compared. When the difference between the statistical value of brightness change and the statistical value of texture direction change of adjacent regions is less than the preset similarity threshold, the adjacent regions are merged into the same candidate region, resulting in multiple candidate regions that are consistent in brightness distribution and texture features. The boundary coordinates and the center position of each candidate region are recorded as output.

[0021] In this embodiment, the process of scanning the source image uploaded by the user using image analysis methods is one of the basic steps of the entire art QR code generation method. The purpose of this process is to extract multiple candidate regions that can represent different texture features and brightness variation features from the original image uploaded by the user, so as to provide reliable data input for subsequent image feature analysis and AIGC fusion generation.

[0022] After a user uploads an image, the system first preprocesses the source image. Since user-provided images may come from different devices (such as smartphones, digital cameras, or scanning devices), there will be differences in parameters such as brightness, color, and white balance between these devices during image acquisition. Therefore, a unified color space conversion is necessary. The system converts the input image from the RGB (red, green, blue) three-channel color space to a brightness-saturation-hue space, abbreviated as HSI or HSL space. This conversion separates color information from brightness information, making subsequent brightness analysis more robust. The brightness channel represents the lightness and darkness of the image, while the saturation and hue channels reflect the purity and variety of colors.

[0023] After conversion, histogram equalization is performed on the luminance channel to improve the overall image contrast and eliminate the effects of uneven lighting. Histogram equalization is a commonly used image enhancement method. Its principle is to remap pixels in an image that were originally concentrated within a certain brightness range, making their brightness distribution more uniform. Specifically, the process involves calculating the luminance histogram of all pixels in the image, then calculating the cumulative distribution function of the luminance based on this histogram, and finally using the cumulative distribution function to redistribute the luminance values ​​of the original image, making the contrast between light and dark areas more pronounced. Through this preprocessing, the system can effectively improve the dynamic range of image luminance information, thus providing standardized input for subsequent analysis. The image after this processing is called a standardized image, which can reduce errors caused by differences in equipment and exposure during subsequent scanning and feature calculation.

[0024] After the standardized image is generated, the system scans the image according to a preset analysis window size. An analysis window is a fixed-size rectangular area defined within the image for extracting local feature data. The size of the analysis window is typically determined by the ratio of the image resolution to the target QR code size. For example, when the source image is 2048 pixels × 2048 pixels, a window size of 256 pixels × 256 pixels can be selected, allowing each window to cover 1 / 64 of the image area, thus balancing computational efficiency and detail resolution. During scanning, the window moves row by row and column by column across the image with a certain sliding step, achieving a complete traversal of the entire image.

[0025] The sliding step size is not a fixed value, but is dynamically adjusted based on the brightness variation of pixels within the window. The brightness variation range refers to the difference between the maximum and minimum brightness values ​​of pixels within the window. For example, if the brightness range of pixels in a window is between 100 and 160, the brightness variation range is 60. During scanning, the system calculates the brightness variation range of the window in real time. When it exceeds a preset first threshold, it indicates that the area has significant brightness fluctuations and rich details. In this case, the sliding step size is set to a smaller value (e.g., 16 pixels) to increase the scanning density of the area and improve the accuracy of local feature capture. When the brightness variation range is less than a preset second threshold, it indicates that the area is relatively smooth with less detail. In this case, the sliding step size is set to a larger value (e.g., 64 pixels) to reduce repeated sampling and improve scanning efficiency. Both the first and second thresholds are constant values ​​set during system initialization. For example, the first threshold can be set to 40, and the second threshold to 15. Such numerical settings can achieve good brightness variation response in most natural images. Through this dynamic step size mechanism, computational resources can be concentrated on information-rich areas while maintaining overall scan coverage, reducing redundant analysis in monotonous areas.

[0026] During the scanning process, for each local area covered by a window, the system needs to calculate the brightness gradient change and texture direction change of that area. The brightness gradient change reflects the intensity of local brightness variations in the image. It is calculated by comparing the brightness differences between adjacent pixels and taking their average rate of change. For example, the absolute values ​​of the differences in brightness values ​​between adjacent pixels can be calculated along both the horizontal and vertical directions, and the average can be taken as the brightness gradient change of that window. A large value indicates the presence of significant light and dark boundaries or contours within the area; a small value indicates a relatively smooth area. The texture direction change reflects the directional characteristics of the local structure. It is calculated by analyzing the main direction of pixel grayscale changes within the window, for example, by calculating the directional distribution of local gradient vectors and statistically analyzing the variance of pixel gradient intensity in each direction. If the texture direction in a certain area is concentrated in a single direction, the structure is relatively regular; if the direction distribution is more dispersed, the texture of the area is complex.

[0027] The brightness gradient change and texture direction change together form the regional feature description data of the window. This regional feature description data includes statistical values ​​of the window's pixel brightness change, statistical values ​​of texture direction change, and the window's position coordinates in the image. Taking a 256×256 pixel window as an example, the system can record the window's average brightness gradient change value as 40, texture direction dispersion as 0.65, and record the top-left corner coordinates of the window as (512, 768). This information collectively constitutes the window's regional feature description data, used for subsequent similarity judgment and region merging.

[0028] After completing feature calculations for all windows, the system compares the similarity of regional feature descriptions of adjacent windows. Adjacent windows are those that overlap spatially or have edges touching. The principle of similarity comparison is: when the difference in brightness variation statistics between two windows does not exceed a preset brightness similarity threshold, and the difference in texture direction variation statistics does not exceed a preset texture similarity threshold, then these two regions are considered to belong to the same type and can be merged into a larger candidate region. For example, if the average brightness gradient variation values ​​of two adjacent windows are 38 and 42 respectively, with a difference of 4, which is less than the brightness similarity threshold of 10, and their texture direction variation statistics are 0.63 and 0.66 respectively, with a difference of 0.03, which is less than the texture similarity threshold of 0.05, then the system will merge these two windows into a unified candidate region.

[0029] By merging adjacent regions multiple times, the entire image can be divided into several candidate regions that are internally consistent in terms of brightness distribution and texture features. Each candidate region has clear boundary coordinates (determined by the position of the outermost pixel) and a region center position (obtained by the average of the region's pixel coordinates). The system records this information as input for subsequent feature analysis and region suitability scoring. After the above processing, the entire source image is divided into a limited number of candidate regions with relatively stable features, laying the foundation for subsequent analysis based on information entropy, edge density, and smoothness.

[0030] In summary, this step achieves intelligent segmentation of the source image through a series of precise operations such as standardized image preprocessing, dynamic step-size sliding scanning, local feature extraction, and similar region merging. This enables the extracted candidate regions to truly reflect the local differences and structural features of the image.

[0031] Step S102: For each candidate region, calculate multi-dimensional image feature values ​​including information entropy, edge density, and smoothness. Generate a region suitability score based on the multi-dimensional image feature values. According to the exclusion rule when the smoothness exceeds a preset threshold, remove unsuitable regions and determine the candidate region with the highest region suitability score as the target region.

[0032] The purpose of step S102 is to perform an objective, quantitative, and reproducible analysis on each candidate region after the candidate region extraction, thereby selecting a unique target region from among many candidate regions. A candidate region refers to a local area image extracted from the source image according to fixed coordinate rules based on the analysis window size and sliding step size in step S101. Each candidate region has specific location coordinates, a fixed pixel width, and a pixel height. This step evaluates the quality of each candidate region by calculating its multi-dimensional image feature values, and determines the target region for subsequent QR code fusion generation based on the evaluation results. To ensure the evaluation is effective, this step uses three types of feature values—information entropy, edge density, and smoothness—to characterize the texture complexity, structural contour richness, and whether there are overly smooth or detail-lacking areas in the candidate region, respectively. Those skilled in the art should understand that these three feature values ​​address three fundamental issues: "whether there is enough content," "whether there are enough boundary lines," and "whether it is too monotonous."

[0033] Information entropy measures the richness of detail and texture complexity within a candidate region. It is calculated by summing the negatives of the products of the probabilities of each gray level appearing in the candidate region and their logarithms, representing the uncertainty of the gray-level distribution in that region. Information entropy can be calculated based on the gray-level distribution of pixels. Specifically, the candidate region should first be converted into a grayscale image. Grayscale images can be obtained using conventional weighted channel synthesis methods. For example, for the red, green, and blue channels in a color image, a weighted summation can be used to obtain the brightness values ​​of a single channel, ensuring that each pixel corresponds to a grayscale value between 0 and 255. Then, the frequency of each possible grayscale value within the candidate region is counted; for example, how many pixels have a grayscale value of 0, how many have a grayscale value of 1, and so on. Finally, the frequency of each grayscale value is divided by the total number of pixels in the candidate region to obtain the proportion of that grayscale value in that region. Information entropy means that if a region has only a very small number of gray values ​​occupying the majority of pixels, such as a background that is almost entirely of the same brightness, then the information entropy will be very low. If a region contains details of various brightness levels, such as shadows, highlights, and texture wrinkles, then the information entropy will be relatively high. Those skilled in the art can understand information entropy as "the complexity of the visual content of a region." In practical applications, an empirical lower limit threshold can be given. For example, if the information entropy of a candidate region is lower than this lower limit threshold, it is considered that the region lacks texture support that can be used for subsequent QR code fusion, which is not conducive to embedding the structural units of the QR code while maintaining the artistic style. Therefore, this region will be considered of lower quality.

[0034] Edge density measures the proportion of contour lines, texture boundaries, and shape boundaries in a candidate region, reflecting whether the region contains sufficient structural features. Edge density can be calculated using classic edge detection algorithms to obtain a binarized edge image. A binarized edge image means dividing pixels in the candidate region into "edge pixels" and "non-edge pixels." Edge pixels typically correspond to locations where brightness changes abruptly or textures clearly demarcate, such as object outlines, leaf vein textures, or the direction of fabric wrinkles. These edge pixels can be obtained using conventional Canny edge detection methods, Sobel operators, or other mature edge detection operators with similar capabilities. After obtaining the edge pixels, the number of pixels identified as edge pixels within the candidate region can be counted, and then the total number of pixels within the candidate region can be counted. Edge density is the ratio of the former to the latter. In other words, edge density can be understood as "how many pixels in the candidate region belong to significant structural contours or detail boundaries." Higher edge density indicates that the region contains more natural structures that can align with or coordinate with the boundaries of QR code units, such as fleshy fibers, brushed metal textures, or the edges of splashed droplets. These details help to naturally "hide" the logical units of the QR code within existing textures during generative fusion, making the QR code look more natural while still maintaining a clear block structure during machine recognition. Conversely, if the edge density of a region is extremely low—for example, if the entire region is almost a uniform background or a large area of ​​blurred plane—then even if the region has an attractive color, it is not suitable for supporting a QR code structure.

[0035] Smoothness is used to identify areas that appear "clean" to the naked eye but are highly prone to problems during the technical generation process. These areas often lack subtle textures and brightness variations, such as a single sky background, a uniformly lit solid-color product surface, or large areas of skin on a human face after post-processing smoothing. Smoothness can be calculated using the concept of local standard deviation. Specifically, the candidate region can be further divided into several smaller sub-grids. For example, in a candidate region of 512 pixels × 512 pixels, it can be divided into a 16 × 16 grid, with each sub-grid covering a small contiguous area of ​​pixels. For each sub-grid, the dispersion of brightness values ​​for all pixels within that sub-grid is calculated. This dispersion is calculated by first determining the average brightness value of all pixels in the sub-grid, and then examining the deviation of the brightness values ​​of individual pixels within the same sub-grid from this average brightness value. If the brightness values ​​of most pixels are very close to the average brightness value, it indicates that there is almost no visible texture variation within this sub-grid, and this sub-grid can be marked as a smooth sub-grid. Conversely, if the brightness fluctuations within a sub-mesh are significant, it indicates the presence of obvious texture details or lighting structures, and thus the sub-mesh is not considered a smooth sub-mesh. After completing the above marking, the number of candidate regions marked as smooth sub-meshes can be counted, and then divided by the total number of sub-meshes in the candidate region to obtain the so-called smooth region percentage. The higher the smooth region percentage, the more the candidate region is composed of large areas of monotonous regions. This step requires setting an upper limit threshold for the smooth region percentage for each candidate region, for example, twenty percent. When the smooth region percentage of a candidate region exceeds this threshold, the candidate region will be directly eliminated and will not be included in the subsequent comprehensive scoring. This direct elimination process is a veto rule; that is, if a candidate region is judged to be too smooth, it is not allowed to be a target region regardless of its performance on other indicators.

[0036] After obtaining the three feature values—information entropy, edge density, and smoothness—they need to be used to score the suitability of candidate regions. The suitability score can be understood as a comprehensive quality score, reflecting whether the candidate region is suitable for embedding a QR code structure in subsequent generation steps. The calculation process for the suitability score can be implemented as follows: First, confirm whether the candidate region passes the veto rule, that is, confirm whether the smooth area ratio of the candidate region is less than a preset upper limit, and confirm that the candidate region does not contain sensitive content that needs to be avoided from being covered. Sensitive content can include clearly identifiable face regions, clear brand logos, product elements that need to be displayed completely, and text descriptions. Face regions can be identified using conventional face detection algorithms, brand logos can be detected using template matching or specific icon recognition methods, and text descriptions can be detected using optical character recognition methods. Once the above sensitive content is detected, the candidate region is also directly eliminated, because overlaying or redrawing QR codes on these areas often leads to brand compliance or visual damage issues. Only after passing the veto rule does the next step of scoring proceed.

[0037] For candidate regions that have passed the veto rule, a comprehensive score needs to be given based on the region's image detail carrying capacity, structural boundary clarity, and visual variation level. In practice, the scoring can be based on the following principles: regions with higher information entropy have an advantage in score because higher information entropy means richer texture, making it easier for generative methods to preserve natural texture when embedding QR code structures within these regions; regions with reasonable edge density also have an advantage because a suitable number of boundary lines can provide "attachment points" for the logical blocks of the QR code, ensuring that the module boundaries of the QR code align with the line directions of the original texture; regions with a lower proportion of smooth areas will also receive higher scores because low smoothness usually means the absence of large areas of monotonous, detail-less planes, which are often difficult to maintain both artistic effect and machine readability after generation.

[0038] For example, in a practical application scenario, a candidate region extracted from the source image is 512 pixels × 512 pixels. First, the system converts this region into a grayscale image and counts the frequency of each grayscale value. Assuming the grayscale values ​​vary between 0 and 255, the statistics show that the grayscale values ​​in this region are relatively evenly distributed, with a certain number of pixels from the darkest to the brightest, exhibiting significant brightness variations and not concentrated at a single grayscale level. This distribution indicates that the region has large pixel differences and rich details; therefore, the system assigns a higher score to the information entropy metric, which is generally considered superior to regions with a simple texture.

[0039] Next, the system uses conventional edge detection algorithms (such as the Canny operator) to identify the contour lines in the region. After detection, the program counts the number of edge pixels. For example, out of a total of 262,144 pixels, approximately 26,000 pixels are detected as edge pixels, indicating that about one-tenth of the pixels belong to clear texture or shape boundaries. This proportion represents a moderate amount of detail within the region, avoiding both excessively complex noise and overly smooth surfaces. The system therefore assigns a high score to the edge density metric.

[0040] The system then calculates the smoothness of the candidate region. To do this, the region is divided into a 16×16 grid array, with each grid containing 32×32 pixels. The program calculates the average brightness of each grid and compares the difference between each pixel and the average brightness. If the brightness of most pixels in a grid is very close to the average brightness (e.g., the difference is within 5), the grid is marked as a smooth grid. Assuming that the calculation finds only 30 out of 256 grids are marked as smooth grids, representing approximately 12% of the total grids, and since this proportion is below the system's preset upper limit of 20%, the region is considered to have good texture continuity and balanced detail levels, thus receiving a positive evaluation in the smoothness metric.

[0041] After evaluating the three indicators, the system normalizes the results of information entropy, edge density, and smoothness, and then performs a comprehensive score according to the set weights. Assuming that information entropy and edge density have slightly higher weights, and smoothness is used as an auxiliary correction term, the candidate region will receive a near-perfect comprehensive score due to its excellent performance across all three indicators. Conversely, another candidate region with a single grayscale distribution, sparse edge lines, and a smooth grid ratio as high as 40% at the same size will be automatically downgraded or directly excluded. Ultimately, the candidate region with the highest comprehensive score is determined as the target region. Through this method of item-by-item quantification, proportional comparison, and comprehensive weighting, an automated and repeatable region selection process can be achieved without relying on manual judgment.

[0042] In practice, a final score can be calculated for each candidate region, and all candidate regions can be ranked from highest to lowest based on their final scores. The candidate region with the highest score is determined as the target region. The target region is the image segment used in subsequent steps to carry out QR code generation and fusion. In an optional scenario, if the final scores of all candidate regions are lower than the preset minimum acceptable score, it can be determined that the overall quality of the source image is insufficient and cannot reliably generate a readable artistic QR code image. In this case, the processing can be terminated directly, and the user can be prompted to provide a new source image.

[0043] Through the above steps, each candidate region will undergo a consistent, repeatable, and quantifiable screening process, rather than relying on subjective human judgment.

[0044] Furthermore, for each candidate region, multi-dimensional image feature values, including information entropy, edge density, and smoothness, are calculated. A region suitability score is generated based on these multi-dimensional image feature values. Unsuitable regions are eliminated according to an exclusion rule when smoothness exceeds a preset threshold. The candidate region with the highest region suitability score is then determined as the target region. This process includes: For each candidate region's image data, a texture orientation-aware analysis is performed. By uniformly arranging multiple local sampling points within the region, the brightness difference and grayscale change direction of adjacent sampling points are calculated to obtain the main texture orientation data. The main texture orientation is then compared with the pixel distribution direction to determine whether the region has a texture orientation that can be embedded with a QR code structure. After obtaining the main direction data of the texture, the information entropy value, edge density value and smoothness value of the region are calculated. The information entropy is used to reflect the complexity of the brightness distribution, the edge density is used to reflect the concentration of the local gradient, and the smoothness is used to reflect the brightness continuity of the region. After normalizing the three values, the direction correction factor is generated using the brightness gradient distribution characteristics. The direction correction factor is used to enhance the score of the region that is consistent with the arrangement direction of the QR code module. The information entropy feature value, edge density feature value, and smoothness feature value are weighted and calculated with the direction correction factor to generate a comprehensive score for regional suitability. During the scoring process, if the edge density distribution of the specified region is not uniformly concentrated, that is, the edge density increases abruptly in one direction while it is sparse in other directions, its comprehensive score is automatically reduced to avoid local recognition interference in the subsequently generated image. Based on the exclusion rule when the smoothness exceeds the preset threshold, regions with smoothness feature values ​​exceeding the set upper limit are automatically removed; among the remaining regions, the candidate region with the highest comprehensive regional suitability score is selected as the target region, and the center coordinates, boundary contour, and direction correction parameters of the target region are output.

[0045] In this embodiment, calculating multi-dimensional image feature values, including information entropy, edge density, and smoothness, for each candidate region is the core step in the entire intelligent region localization process. Its purpose is to comprehensively evaluate the compatibility between artistic texture features and QR code structure readability of each candidate region through quantitative feature indicators, so as to select the most suitable embedding position in the subsequent AIGC generation process.

[0046] In its implementation, the system first performs texture direction-aware analysis on the image data of each candidate region. Texture direction refers to the dominant directional feature of local grayscale or brightness changes in an image, reflecting the arrangement pattern of textures within the region. To obtain texture direction information, the system arranges multiple local sampling points within the candidate region at regular intervals, for example, one sampling point every 8 pixels. For each sampling point, the system reads the brightness values ​​within a certain range (e.g., a 5×5 pixel neighborhood) and calculates the brightness difference and direction of change between adjacent sampling points. The brightness difference represents the magnitude of the brightness change, while the direction of change can be determined by comparing the brightness differences in the horizontal and vertical directions. The system statistically analyzes the grayscale change directions of all sampling points to obtain the main texture direction data for the entire region. The main texture direction can be understood as the direction of the most significant local brightness change; for example, in images with stripes or edges, the main texture direction is consistent with the stripe arrangement direction.

[0047] After obtaining the main direction data of the texture, the system further calculates the information entropy, edge density, and smoothness of the region. Information entropy reflects the complexity of the brightness distribution in the region; a higher value indicates a more uniform brightness distribution and richer details. Specifically, the system counts the frequency of each gray level in the candidate region and then calculates the information entropy value based on the probability of the gray level distribution. For example, if the gray values ​​in a region are concentrated in a few brightness ranges, such as most pixels having a brightness between 180 and 200, the information entropy value is low; if the region contains various brightness variations and the gray level distribution is uniform, the information entropy value is high.

[0048] Edge density describes the concentration of gray-level gradients within a local region, reflecting the presence of obvious boundaries or structural changes within the region. Its calculation can be implemented using gradient operators (such as Sobel or Prewitt). The system calculates the brightness gradient intensity of each pixel within the region and counts the proportion of pixels with intensity higher than a threshold. Higher edge density indicates that the region contains more edge features, such as contour lines and texture boundaries; while low edge density means the region is flat and lacks structural features.

[0049] Smoothness measures the continuity of brightness changes within a region, essentially reflecting its monotony. The system calculates the smoothness index by the variance of the brightness values ​​of adjacent pixels within the region; a smaller variance indicates a smoother region. If a region has an excessively high smoothness value, it indicates significant brightness jumps or irregular reflections. Such regions are often unsuitable for embedding QR code structures because excessive brightness contrast can disrupt the morphological consistency of the QR code module.

[0050] After the three feature values ​​are calculated, the system normalizes them to maintain a consistent value range (e.g., linearly mapping all feature values ​​to between 0 and 1) to avoid weight imbalances caused by differences in units of measurement between different features. Then, the system generates an orientation correction factor based on the brightness gradient distribution characteristics. The orientation correction factor is an adjustment parameter used to balance the image texture orientation and the QR code module arrangement orientation. QR code modules are typically arranged horizontally and vertically, so the system compares the angle difference between the main texture direction and the QR code direction of the candidate region. When the main texture direction and the QR code direction are consistent, the orientation correction factor is set to a higher value; when the angle is large, the orientation correction factor is set to a lower value. For example, when the angle is less than 15 degrees, the system sets the orientation correction factor to 1; when the angle is between 45 and 90 degrees, the correction factor is reduced to 0.5, thereby lowering the priority of that region in the overall score.

[0051] In the specific calculation process, the system first obtains the texture main direction angle value θ1 (in degrees) of the candidate region, which is 0 degrees in the horizontal direction and increases counterclockwise. Then, the system determines a reference angle θ2 based on the orientation of the QR code modules. This reference angle can be 0 degrees or 90 degrees, corresponding to the horizontal and vertical arrangement of the QR codes, respectively. The system calculates the angle difference Δθ between the two, defined as the absolute value of the difference between the two angles and limited to the range of 0 to 90 degrees. To obtain the specific value of the orientation correction factor, a linearly decreasing method can be used: when Δθ is less than or equal to 15 degrees, the orientation correction factor is 1; when Δθ is between 15 degrees and 90 degrees, the orientation correction factor gradually decreases proportionally to 0.5; when Δθ equals 90 degrees, the orientation correction factor is 0.5.

[0052] For example, when the main direction of the texture in a certain area is 10 degrees and the direction of the QR code module is horizontal (0 degrees), Δθ is 10 degrees and the corresponding direction correction factor is 1; when the main direction of the texture is 45 degrees, Δθ is 45 degrees and the corresponding direction correction factor is about 0.75; when the main direction of the texture is 90 degrees, Δθ is 90 degrees and the corresponding direction correction factor is 0.5.

[0053] The system then weights the information entropy feature value, edge density feature value, and smoothness feature value with the orientation correction factor to generate a comprehensive regional suitability score. The weighting calculation process can be implemented using fixed weight parameters, for example, an information entropy weight of 0.4, an edge density weight of 0.3, a smoothness weight of 0.2, and an orientation correction factor weight of 0.1. These weight values ​​are determined through extensive statistical experiments to ensure the visual balance and machine recognition of the artistic QR code. When a region performs well in terms of information entropy and edge density, and its texture orientation is highly consistent with the QR code's arrangement direction, the region's comprehensive score will significantly improve, indicating that the region is more suitable for embedding the QR code.

[0054] During the scoring process, the system also detects the uniformity of edge density distribution. When it finds that the edge density of a certain region is concentrated in one direction while being sparse in other directions, indicating that the region has obvious directional structures, such as strong reflective lines or shadow edges, the system will automatically correct the overall score of that region by reducing its weight. For example, if it detects that the gradient intensity in the horizontal direction is significantly higher than that in the vertical direction in a certain region, the system will reduce the overall score of that region by 30% to prevent local visual interference or QR code module distortion in subsequent AIGC generation.

[0055] After all candidate regions have been calculated, the system eliminates unsuitable regions based on an exclusion rule that considers smoothness exceeding a preset threshold. The preset threshold can be set to 0.8 depending on the specific application scenario. When the smoothness value exceeds this threshold, it indicates that the brightness variation within the region is too drastic, which is detrimental to the readability and fusion effect of the QR code. Therefore, this region is directly marked as unqualified and removed from the candidate list. For the remaining candidate regions, the system sorts them from highest to lowest based on their overall suitability score, selecting the one with the highest score as the final target region and outputting its center coordinates, boundary contour, and orientation correction parameters. This output data will serve as input for the next step of image fragment extraction and AIGC generation, providing directional consistency and a structural foundation for subsequent artistic QR code generation.

[0056] Through the above methods, the present invention not only achieves intelligent screening of candidate regions, but also achieves a dynamic balance between aesthetics and readability by matching the texture direction with the QR code structure direction, thereby ensuring that the QR code has both visual appeal and stable and reliable decoding performance in scanning and recognition after fusion.

[0057] Step S103: Based on the target region, extract the corresponding region image fragment from the source image, input the region image fragment and the QR code data to be encoded into the AIGC generation process, and use the generative image fusion method to generate an artistic QR code fragment that combines artistic texture features and a recognizable QR code structure.

[0058] Step S103 is the core process of generating the artistic QR code in this invention. Its task is to fuse the data information of the QR code with the image content of the target area determined in the previous stage, thereby generating a local artistic QR code fragment that contains both a complete QR code structure and artistic texture features. In order to ensure that the generated QR code has both visual appeal and can be reliably recognized by scanning devices, this step achieves a balance between structural preservation and style fusion through generative artificial intelligence image fusion technology (AIGC generation process).

[0059] In performing this step, the corresponding region image segment needs to be precisely extracted from the source image based on the target region location information determined in step S102. The size of this region image segment should match the total size of the QR code encoding module so that subsequent structural alignment can be performed at the pixel level. For example, when the QR code is a basic version of a standard 21×21 module, each module can correspond to several pixel units in the target region. Therefore, the extracted image segment should satisfy the integer ratio between the number of QR code modules and the region pixels in terms of pixel size. To ensure that the QR code is not visually damaged after fusion, each QR code module can be mapped to a small block region composed of multiple pixels, thereby preserving the detailed variations of the image in the local texture.

[0060] Subsequently, the extracted image fragments and the QR code data to be encoded are simultaneously input into the AIGC (Artificial Intelligence Generated Content) generation process. AIGC refers to a process based on deep learning models, using feature extraction and generative fusion algorithms to perform high-level semantic matching and visual reconstruction of the original QR code structural information and the target region image features. The generative model can be implemented based on diffusion models, generative adversarial networks (GANs), or image-to-image style transfer networks, but its essence is to learn the mapping relationship between image features and QR code modules, enabling the output image to retain the logical structure of the QR code while possessing an artistic appearance. Specifically, the AIGC model first extracts feature representations of the target region image fragments, including color distribution, texture direction, local gradients, and spatial frequency information; then, the QR code's structure matrix (i.e., the binary matrix representing the distribution of the QR code's black and white modules) is used as a structural constraint input; the generative model, through a multi-layer fusion mechanism, jointly encodes these two types of information in the latent space, generating a fusion result that visually continues the texture of the original image but logically embeds the QR code's encoded structure.

[0061] To ensure that the QR code can still be accurately read by recognition devices, the generation model needs to incorporate a structure preservation mechanism during training or inference. This mechanism can be implemented using mask constraints, where during fusion generation, the positions corresponding to black modules of the QR code maintain a high contrast intensity, while the positions of white modules maintain a lower brightness or transparency range. For example, at each pixel of the generated image, the model can dynamically adjust the brightness weight of the output pixel according to the structure matrix of the QR code to satisfy the logical contrast relationship of the QR code modules. Simultaneously, to avoid the QR code being overly abrupt, the model uses gradient transitions or texture interpolation at module boundaries, allowing the pixel brightness in the edge regions to smoothly connect with the texture direction of the original image within a locally continuous range of variation, thus achieving a balance between visual fusion and structural readability.

[0062] In this embodiment, the AIGC generation process can be implemented based on various publicly available or commercially available generative artificial intelligence image models. For example, the Taiyi-Diffusion-XL model proposed by a domestic research team can be used, which has good Chinese semantic understanding and text-to-image generation capabilities, and is suitable for generating image content with specific textures or styles based on Chinese prompts; the Hunyuan-DiT model developed by Tencent can also be used, which is based on a diffusion-type Transformer structure and can generate high-fidelity images under multi-resolution conditions, suitable for achieving natural texture fusion while maintaining the clarity of the QR code structure; the Seedream 4.0 model launched by ByteDance can also be selected, which supports multi-image fusion and high-resolution output, and can ensure the level of detail and overall consistency of the generated results while performing artistic processing. Those skilled in the art can choose a suitable implementation method from the above or other similar AIGC models according to specific application requirements and computing environment, without making substantial changes to the technical solution of this invention.

[0063] In practice, AIGC generation can be achieved through the following workflow: First, a feature encoder is used to extract texture feature vectors from the target region image fragments. These feature vectors reflect the local style features of the image, such as dominant hue, texture orientation, and noise frequency. Then, the structure matrix of the QR code is converted into a structure guide map, which represents the spatial relationship of the QR code's logical units. Next, the feature vectors and the structure guide map are input into a generative network. The generative network fuses the information from both through multiple convolutional modules and a self-attention module, gradually reconstructing the fused artistic QR code fragment within the pixel space. The final output is a locally fused image that matches the original image in color and texture orientation but visually contains a scannable QR code pattern.

[0064] To ensure the quality of the generated results, an evaluation step can be introduced to verify the results in two ways. The first method verifies whether the generated fragment can be correctly decoded by a standard QR code recognition algorithm. This step can use common QR code recognition libraries, such as those based on Zxing or OpenCV. If the recognition rate is lower than a set threshold, the generation parameters need to be adjusted, such as increasing the brightness and contrast of the QR code module or reducing the local texture blending range. The second method evaluates the image fusion quality through perceptual similarity. Perceptual similarity can be used to determine visual consistency by comparing the generated result with the original region image fragment in terms of color distribution, gradient direction distribution, and other indicators, thus ensuring that the fused QR code has a natural and harmonious overall style.

[0065] For example, in a typical generation instance, the target area is a light-colored background image with a water ripple texture, and the QR code data corresponds to a standard-sized black and white module matrix. When processing, the AIGC generation model first analyzes the directionality and frequency distribution of the water ripple texture, identifying the main direction of the texture as thin stripes sloping from the upper left to the lower right. During the QR code module overlay stage, the model adjusts the texture intensity of the black modules to a slightly darker blue-gray, while simultaneously overlaying tiny brightness fluctuations along the water ripple direction. This makes the boundaries of the QR code modules not perfectly straight, but rather exhibit slight undulations consistent with the background texture direction, thus creating a visually natural transition. After this fusion generation, the QR code is visually visible as a pattern with a water ripple texture, but the scanning device can still accurately recognize the QR code information.

[0066] Through the above process, step S103 realizes the generation of the fused art QR code fragment from the image fragment. This generation is not just a simple overlay or transparent blending, but a deep fusion process based on generative image understanding and texture reconstruction, so that the output image has both artistic expression and maintains the integrity of the QR code's encoding logic.

[0067] Furthermore, based on the target region, the corresponding region image fragment is extracted from the source image, and the region image fragment and the QR code data to be encoded are input together into the AIGC generation process. An artistic QR code fragment with both artistic texture features and a readable QR code structure is generated using a generative image fusion method, including: Pixel-level extraction is performed on the determined target region, and the boundary contour of the target region is resampled with sub-pixel precision to obtain a region image fragment that covers the entire region. The position index information of each pixel in the region image fragment in the source image is recorded. Brightness and color analysis are performed on the image fragments of the region to extract the main color tone, brightness distribution parameters and color contrast information of the image fragments of the region, and to generate regional visual style data. The region visual style data and the QR code data to be encoded are processed to perform feature correspondence processing to establish a mapping relationship between the QR code module and the texture unit in the region image segment. The mapping relationship is generated based on the logical distribution information of the QR code module, so that each QR code module corresponds to a texture unit in the region image segment. Based on the mapping relationship, each texture unit is locally redrawn, and the brightness and contrast of the texture unit are adjusted according to the logical state of the QR code module, so that the QR code logical structure is embedded into the texture structure of the regional image fragment. At the same time, the color change range is limited according to the regional visual style data, and the edge continuity between the texture units is maintained. The redrawn texture units are combined according to their original spatial order to generate a complete artistic QR code fragment. The boundary coordinates, center position, and grayscale contrast parameters of the artistic QR code fragment are then output for subsequent image backfilling steps.

[0068] In this embodiment, extracting the corresponding region image fragment from the source image based on the target region and inputting it together with the QR code data to be encoded into the generative image fusion process is a key step in achieving a balance between artistry and legibility. This step involves not only precise image extraction and pixel mapping, but also adaptive fusion operations in color and brightness spaces, enabling the QR code encoding structure to be naturally embedded into the texture details of the image, thus forming an artistic QR code fragment that possesses both artistic features and meets machine recognition standards.

[0069] Once the target region is identified, the system first performs pixel-level extraction. Pixel-level extraction refers to reading pixel information belonging to the target region point by point from the source image, using pixels as the smallest unit of analysis. Since the boundary of the target region is often not strictly aligned with the pixel grid, sub-pixel resampling is required. Sub-pixel resampling is an image interpolation method used to obtain pixel values ​​at non-integer coordinates. Its principle is based on the brightness and color values ​​of adjacent pixels, calculating the pixel information of the target point through linear or bilinear interpolation. For example, when the boundary of the target region passes between two pixels, the system calculates the brightness value of the middle position based on the brightness ratio of the pixels on both sides, ensuring that the extracted region image fragment has continuous, jagged edges and fully preserves the transition characteristics of the original texture. Simultaneously, during the extraction process, the system records the position index information of each pixel in the source image, storing it in the form of the pixel's horizontal and vertical coordinates in the original image coordinate system, to ensure that the subsequently generated QR code fragment can accurately correspond to the original image during backfilling.

[0070] After pixel extraction, the system performs brightness and color analysis on the extracted image fragments. The purpose of this analysis is to establish a parameter set describing the visual characteristics of the region, forming regional visual style data. Specifically, the system first converts the image fragments to a unified color space, such as the CIE Lab space, where the L component represents brightness, and the a and b components represent the color differences between red and green and blue and yellow, respectively. After conversion, the system calculates the average brightness, brightness variance, and principal component orientation of the color channels within the region to determine the dominant hue and color contrast. For example, when the red component is significantly higher than other color channels in a region, the system identifies the dominant hue as a warm tone and records the corresponding color distribution ratio. Color contrast is calculated by statistically analyzing the differences in brightness extremes, i.e., calculating the difference between the maximum and minimum brightness values; a larger difference indicates a more pronounced change in brightness within the region. These parameters collectively constitute regional visual style data, used to limit the range of color variations in the generated content during subsequent fusion processes, preventing the generated result from deviating from the style of the original image.

[0071] After obtaining the regional visual style data, the system performs feature mapping processing on it and the QR code data to be encoded. The QR code consists of multiple logical modules, each representing one bit of information, typically displayed in black and white. To achieve a natural fusion of the image and QR code, the system establishes a one-to-one mapping between texture units and QR code modules within the regional image segment. A texture unit is the smallest independently modifiable texture block divided within a regional image segment, and its size can be adaptively determined according to the size of the QR code module. For example, when the width of a QR code module is 12 pixels, the corresponding texture unit can be set to a 12×12 pixel image block. Based on the logical distribution information of the QR code modules, i.e., the black and white encoding sequence, the system assigns each module to a texture unit and records the correspondence table. For modules with a logical "black" QR code, the system marks their corresponding texture unit as a "high-density unit," and its brightness will be reduced accordingly during subsequent brightness adjustments; for modules with a logical "white" QR code, they are marked as "low-density units," and their brightness is maintained or slightly increased during fusion to create visual hierarchy.

[0072] After the mapping relationship is established, the system performs local redrawing on each texture unit based on this mapping. The core of local redrawing lies in embedding the logical state information of the QR code without destroying the original texture structure. In specific implementation, the system reads the brightness histogram of the texture unit and adjusts the distribution of the histogram according to the logical state of the QR code module. For example, for the black logic module, the system shifts the brightness peak of the histogram down by 5% to 10% to make the area darker overall; for the white logic module, the brightness peak is shifted up by the same amount to make it slightly brighter. At the same time, to avoid abrupt edge transitions, the system introduces an edge protection mechanism at the boundaries between texture units, using Gaussian blur smoothing within the boundary range to make the brightness transition natural and without discontinuities. In addition, during the local redrawing process, the system also constrains the color change range according to the dominant color of the regional visual style data to ensure that the overall color tone of the region remains consistent with the surrounding area after the QR code logic is embedded.

[0073] After redrawing all texture units, the system recombines them according to their original spatial order. The original spatial order refers to arranging the texture units row by row and column by column based on their coordinate positions within the image fragment, restoring a continuous image. During the recombination process, the system detects brightness differences and boundary continuity between adjacent texture units. When the brightness difference exceeds a set threshold (e.g., 10%), the boundary areas undergo further smoothing correction to avoid blocky visual effects in the generated result. Finally, the system obtains a complete artistic QR code fragment and outputs its boundary coordinates, center position, and grayscale contrast parameters. The boundary coordinates guide the location of the backfill position, the center position is used for subsequent image registration, and the grayscale contrast parameters are used to check the readability of the QR code, ensuring that the QR code still meets decoding requirements after artistic processing.

[0074] Through the above process, the present invention achieves full-process pixel-level fusion from image region extraction to QR code logical embedding, ensuring that the generated artistic QR code retains machine-recognizable features at the structural level, while being highly coordinated with the texture of the original image at the visual level.

[0075] Furthermore, the step of performing feature mapping processing on the regional visual style data and the QR code data to be encoded, and establishing a mapping relationship between the QR code module and the texture units in the regional image segment, includes: Based on the dominant color tone, brightness distribution parameters and texture direction information in the regional visual style data, visual feature matching data is generated for each QR code module; the matching similarity between each QR code module and multiple texture units in the regional image segment is calculated according to the visual feature matching data. In the texture unit set corresponding to each QR code module, the texture unit with the highest similarity is selected to establish a corresponding mapping relationship, and the brightness weight and direction deviation parameters between the QR code module and the texture unit are recorded. Based on the brightness weight and direction deviation parameters, the logic state of the QR code module and the brightness and contrast of the texture unit are adjusted accordingly, so that the logic structure of the QR code module is consistent with the visual style data of the region after embedding. The mapping relationship between the QR code module and the texture unit is stored in the form of a bidirectional index table. Each QR code module corresponds to a unique texture unit identifier. The texture unit identifier is used to recover the logical state of the original QR code module from the generated artistic QR code fragment. Obtain artistic QR code fragment data containing complete mapping relationships and brightness weight parameters, which will be used to generate artistic QR code fragments that combine artistic texture features and a recognizable QR code structure.

[0076] In the embodiments of the present invention, for the step of performing feature correspondence processing on regional visual style data and QR code data to be encoded in order to establish the mapping relationship between QR code module and texture unit in regional image segment, in order to ensure that the logical structure of QR code and visual features of artistic image can be compatible and integrated, bidirectional feature matching, weight calculation and consistency adjustment of image and encoded information are required.

[0077] First, it's necessary to clarify the composition of "regional visual style data." Regional visual style data refers to the set of parameters extracted from image fragments of a target region, describing its visual characteristics and representing the region's primary color, brightness, and texture features. In practical implementation, the system first performs color space analysis on the extracted regional image fragments, converting the color image into three components: brightness, saturation, and hue. The dominant color tone can be obtained by statistically analyzing the hue distribution of each pixel. For example, within a 256×256 pixel region, the hue values ​​of all pixels are counted. If the number of pixels in a certain hue range (e.g., the red range from 0° to 30°) exceeds 40% of the total number of pixels, then the dominant color tone of the region can be determined to be red. Simultaneously, the brightness distribution parameter represents the overall brightness and local contrast intensity by calculating the average and variance of pixel values ​​in the brightness channel. For example, when the average brightness is 180 and the variance is small (e.g., less than 400), it indicates that the region is generally bright with gradual brightness changes. Texture orientation information is obtained by calculating the distribution of image grayscale gradient directions. The main texture orientation can be estimated by using the directional angle of brightness change within a 3×3 pixel neighborhood, and the mode of the angle value is taken as the main texture orientation of that region. For example, if the gradient direction of most pixels is concentrated between 85° and 95°, the main texture orientation can be considered to be horizontal.

[0078] After obtaining the regional visual style data, visual feature matching data is generated for each QR code module. In this invention, a QR code module refers to a logical cell within the QR code, corresponding to the smallest information block in black-and-white or grayscale encoding. To achieve the correspondence between artistic texture and encoding logic, a set of feature parameters for matching needs to be constructed for each QR code module. The generation of visual feature matching data relies on three core elements of the regional visual style data: dominant hue, brightness distribution parameters, and texture direction information. Specifically, the system maps the logical state (0 or 1) of the QR code module to brightness information. When the logical state is "1", it tends to select texture units with lower brightness to form a contrasting dark area; when the logical state is "0", it tends to select texture units with higher brightness to maintain a readable bright background. Simultaneously, the system compares the relative position of the module with the main direction of the regional texture. For example, in the horizontal module arrangement direction of the QR code, it prioritizes matching units consistent with the texture direction to avoid visual distortion or damage to module boundaries. The generated visual feature matching data can then be defined as a triple {L, C, D}, where L is the target brightness value, C is the dominant hue encoding value, and D is the texture direction angle.

[0079] After generating matching data for all QR code modules, the system proceeds to the matching similarity calculation stage. The purpose of similarity calculation is to find the texture unit in the set of texture units of the region image segment that is closest to its target visual features for each QR code module. The definition of similarity should quantify the degree of difference between two sets of feature parameters, and a distance-based calculation method can be used.

[0080] When performing similarity calculations, the system quantifies the differences in three features—brightness, dominant hue, and texture direction—step by step, and converts these differences according to a uniform ratio, allowing data of different dimensions to be compared under the same evaluation framework. Specifically, the system first compares the difference between the target brightness of the QR code module and the actual brightness of the candidate texture unit. The difference is divided by the maximum allowed brightness variation range (e.g., a pixel brightness range of 0 to 255), resulting in a brightness matching coefficient between 0 and 1. When the brightness difference is small, the coefficient is close to 1; when the difference is large, the coefficient is close to 0. Next, the system calculates the dominant hue difference, comparing the target hue value of the QR code module with the dominant hue of the texture unit to obtain the deviation in hue angle. This deviation is then divided by the maximum possible hue angle range (e.g., 180 degrees) to obtain the dominant hue matching coefficient. The closer the hues are, the higher the coefficient. Subsequently, the system calculates the difference in texture direction and compares the arrangement direction of the QR code module with the main texture direction of the texture unit. If the two directions are consistent or differ only slightly (e.g., within 10 degrees), the direction matching coefficient is taken as close to 1. If the direction difference is large (e.g., more than 45 degrees), the coefficient is reduced to below 0.5.

[0081] After obtaining these three matching coefficients, the system multiplies them by preset weighting coefficients. For example, brightness features are usually more important than hue, so the brightness matching result accounts for about half of the overall similarity weight, while the dominant hue and orientation matching results each account for about a quarter. The three weighted results are then summed to obtain the final comprehensive matching value. The closer this comprehensive value is to 1, the more similar the target visual features of the QR code module are to the texture unit. For example, if the brightness of the QR code module is very close to the texture brightness, with a difference of less than 5, and the dominant hue difference is about 10 degrees, while the texture orientation difference is only 5 degrees, then the brightness matching coefficient is approximately 0.95, the hue matching coefficient is approximately 0.94, and the orientation matching coefficient is approximately 0.97. The weighted comprehensive matching value is approximately 0.95, and the system determines this as a high match. In another scenario, if the brightness difference reaches 40 degrees, the hue difference is 50 degrees, and the orientation difference is 30 degrees, then the coefficients are 0.6, 0.7, and 0.65 respectively. The weighted overall matching value is approximately 0.64. The system considers this texture unit to have a significant visual difference from the QR code module and therefore unsuitable for use. The system repeats the above calculation process in the candidate texture unit set corresponding to each QR code module, ultimately selecting the texture unit with the highest overall matching value as the best matching object for that module. The corresponding matching coefficients, weight parameters, and deviations are recorded and stored for use in subsequent brightness and orientation adjustment steps.

[0082] After matching is complete, the system needs to further calculate the brightness weight and orientation deviation parameters to ensure that the QR code logic and artistic texture remain consistent during the fusion process. The brightness weight describes the mapping ratio between the logical brightness of the QR code module and the texture brightness, while the orientation deviation parameter characterizes the angle between the main direction of the texture and the arrangement direction of the QR code module. The brightness weight can be obtained as the ratio of the brightness difference between the two. For example, when the QR code module requires a brightness value of 150 while the matching texture unit brightness is 120, the brightness weight is 150 / 120, or 1.25, indicating that the brightness needs to be increased by 25% in subsequent redrawing to achieve visual balance. The orientation deviation parameter is recorded as the angle value. If the module arrangement direction is horizontal (0°) and the texture direction is 20°, the deviation is 20°. During redrawing, this parameter will be used to correct the module boundary direction to maintain the overall texture continuity.

[0083] After the brightness weights and orientation deviation parameters are calculated, the system adjusts the display features corresponding to the logical states of the QR code module based on these parameters, ensuring that the visual performance of the QR code module is consistent with the regional visual style data. This process includes fine-tuning the brightness and contrast of the matching texture units. Brightness adjustment is scaled proportionally according to the weights, while contrast adjustment is set based on the regional brightness variance, ensuring that the module's brightness variations harmonize with the surrounding environment. For example, when the module is located in a bright background area and its logical state is "1", the system will appropriately increase the brightness difference of the module to enhance readability; when the module is in a dark background and its logical state is "0", the system will reduce the brightness contrast to avoid creating abrupt blocky visual breaks.

[0084] To ensure the reversibility of the entire mapping relationship and the possibility of subsequent editing, the system stores the mapping relationship between QR code modules and texture units in the form of a bidirectional index table. A bidirectional index table means that each QR code module corresponds to a unique texture unit identifier, and each texture unit can also be used to locate the corresponding QR code module's logical state through this identifier. The table can be stored in key-value pair format; for example, module number M001 corresponds to texture unit T105, and T105 points back to M001. In this way, when subsequent adjustments or decoding of the QR code are needed, the original logical matrix can be looked up from the artistic QR code image, achieving reversible recovery.

[0085] Finally, the system outputs artistic QR code fragment data containing complete mapping relationships and brightness weight parameters, which will be used to subsequently generate artistic QR code fragments that combine artistic texture features with a readable QR code structure. The output data file includes regional visual style parameters, a module matching relationship table, brightness and contrast correction values, and boundary direction adjustment records.

[0086] Through the above steps, high-precision mapping and fusion of QR code logic modules and image texture units can be achieved, so that the generated artistic QR code is naturally coordinated with the image style in appearance, while maintaining the logical integrity of the standard QR code in structure.

[0087] Step S104: Fill the corresponding position of the art QR code fragment into the source image to generate a complete art QR code image.

[0088] Step S104 is the output stage of the final generation of the art QR code in this embodiment. Its main task is to accurately fill the corresponding position of the art QR code fragment generated in the previous stage into the original source image, so as to maintain a natural continuity with the original image visually and form a complete and recognizable art QR code image in terms of structure.

[0089] Before executing step S104, the system has generated an artistic QR code fragment of the same size as the target area in step S103. This fragment contains a local image fused by AIGC, and its internal pixels inherit the texture style of the original image while embedding a QR code module structure that can be recognized by a scanning device. To ensure that this fragment can be perfectly stitched with the original image, it is necessary to first obtain the coordinate information of the target area recorded when extracting candidate areas in step S101. This coordinate information includes the pixel position (x0, y0) of the upper left corner of the target area, the area width w, and the height h. These four parameters uniquely determine the spatial range of the area in the source image. Those skilled in the art should understand that the source image is usually stored in the form of a two-dimensional pixel matrix, where each pixel consists of three-channel color values ​​(such as the red, green, and blue components in RGB mode). The coordinates (x0, y0) represent the index position of the upper left corner pixel in the entire image matrix, and the width w and height h represent the number of pixels contained in the area in the horizontal and vertical directions, respectively.

[0090] Once the QR code fragment is generated, the system compares its pixel matrix with the corresponding pixel matrix of the source image to ensure they are identical in size and resolution. If size differences are found, such as slight deviations in the number of boundary pixels due to interpolation algorithms during AIGC, bilinear interpolation or edge cropping can be used for resizing. Bilinear interpolation is a commonly used image scaling method that calculates new pixel values ​​by weighting the color values ​​of four known pixels adjacent to the target pixel, thus maintaining smooth boundaries after scaling. If the generated fragment is slightly larger than the target area, cropping can preserve pixels in the central region, ensuring that the boundary position accurately corresponds to the original image area after backfilling.

[0091] After size matching, the pixel data of the art QR code fragment is replaced pixel by pixel in the corresponding position of the source image matrix. Specifically, in the source image, starting from coordinates (x0, y0), w pixels are continuously replaced horizontally, and h rows are continuously replaced vertically, forming an embedded block with the same size as the local area of ​​the original image. Each replacement operation is performed according to the pixel index, that is, the pixel at position x0+i, y0+j in the source image is replaced by the pixel value at position i, j in the art QR code fragment. In the actual implementation, matrix operations can be used to achieve the overall replacement to reduce the amount of computation.

[0092] To avoid visual abruptness caused by boundary stitching, this step introduces boundary blending processing during the backfilling process. Boundary blending refers to smoothing the brightness and color transition of pixels at the stitching point between the artistic QR code fragment and the surrounding pixels of the source image, so that the transition area does not produce obvious color breaks. This can be achieved using weighted blending or gradient transition algorithms. For example, a blending band of 2 to 4 pixels wide is reserved outside the edge of the target area. Within this blending band, the color weight of the artistic QR code fragment is gradually reduced, while the weight of the original image pixels is increased, causing the pixel color in the edge area to gradually transition to the background color of the original image, thus creating a natural blending effect. Those skilled in the art will understand that this operation is similar to feathering in post-processing photography, allowing the newly embedded content to blend naturally with the original background.

[0093] After visual fusion is completed, the recognizability of the generated complete artistic QR code image needs to be verified. The recognizability of a QR code depends on contrast, module sharpness, and spatial consistency. Therefore, the system can automatically detect it using a QR code recognition algorithm after backfilling. The detection process includes four steps: grayscale conversion, binarization, module localization, and decoding. Grayscale conversion converts the color image into brightness information to identify black and white contrast areas; binarization uses thresholding to convert the image into a logical graphic containing only black and white pixels; module localization detects the QR code's locator pattern (usually located in the three corners of the QR code). If the locator cannot be correctly recognized, it indicates that the structural offset during fusion is too large, requiring regeneration or adjustment of backfilling parameters; decoding verifies whether the data content contained in the QR code, such as URLs, text, or encrypted information, can be correctly parsed. If the detection result indicates that the QR code cannot be recognized normally, the system will automatically adjust the fusion intensity parameters, such as increasing the brightness difference in the QR code module areas or locally sharpening the edges, and then re-execute the generation and backfilling process until it passes the recognition verification.

[0094] To illustrate the effect, consider this example. Assume the source image is a background image with a light-colored fabric texture, and the target area is located in the center of the image, measuring 512 pixels × 512 pixels. The AIGC-generated artistic QR code fragment continues the light gray tone of the fabric texture in color, but creates subtle shadow contrast in the corresponding area of ​​the QR code module. When this fragment is backfilled into the original image, the system inserts it into the center position based on the coordinates of the target area and sets a 4-pixel wide blending band at the edges, aligning the direction of the fabric texture with the edge of the QR code through a weighted average. After backfilling, the image appears to the naked eye as a complete fabric texture image, but when scanned by a barcode scanner, the QR code information it contains can be accurately identified.

[0095] In some embodiments, this step can also be extended to include compression and export functions. Since the generated artistic QR codes are typically used for advertising design, packaging printing, or digital media displays, a balance between file size and display clarity needs to be struck. An appropriate compression format, such as high-quality JPEG compression or lossless PNG compression, can be selected before output to maintain the integrity of the pixel matrix. Furthermore, to ensure consistent display across devices, a color profile (such as the sRGB standard) can be embedded during output to guarantee that the QR code and background colors are consistent across different display devices, preventing display differences from affecting scanning and recognition.

[0096] In summary, step S104, through multi-stage processing including pixel-level coordinate positioning, boundary fusion, recognition verification, and output optimization, ensures that the generated artistic QR code fragments can be accurately and naturally embedded into the original image, forming a complete high-quality artistic QR code image.

[0097] Furthermore, the step of filling the corresponding position of the art QR code fragment into the source image to generate a complete art QR code image includes: Spatial alignment is performed between the corresponding positions of the art QR code fragment and the source image. Based on the pixel position index information recorded in the extraction step, the art QR code fragment is geometrically corrected. During the correction process, the pixel displacement vector is calculated based on the perspective offset of the embedded region, and the pixel coordinates of the art QR code fragment are adjusted at the sub-pixel level so that the art QR code fragment corresponds precisely to the original pixel grid of the source image in space. After spatial alignment is completed, image data around the embedded region in the source image is extracted to obtain the brightness distribution parameters, main color tone, local texture direction and edge gradient information of the neighborhood of the embedded region, and to generate embedded environment feature data. The embedded environment feature data serves as the input basis for subsequent color adjustment and brightness transition. Based on the embedded environmental feature data, brightness transition processing is performed on the boundary region of the art QR code fragment. Within the boundary range, the difference between the pixel brightness of the art QR code fragment and the brightness of the neighborhood of the source image is calculated. The brightness value and contrast of the boundary pixels are weighted and adjusted according to the ratio of the brightness difference to make the brightness gradient of the boundary region continuous with that of the source image. At the same time, the color components of the boundary pixels are corrected according to the dominant color of the neighborhood to make the color transition of the boundary region smooth and consistent. After the brightness transition is completed, local texture consistency reconstruction is performed on the embedded region. Texture direction reference data is generated based on the local texture direction information in the embedded environment feature data. The texture direction reference data is then used to correct the orientation consistency of the pixels in the embedded region, so that the art QR code fragment and the source image remain continuous in texture direction. Global brightness balancing and global contrast unification are performed on the image after brightness transition and texture consistency reconstruction. By statistically analyzing the overall brightness histogram of the source image, the brightness deviation between the embedded region and the source image is calculated, and the pixel brightness of the embedded region is proportionally corrected according to the deviation, so that the backfilled region is consistent with the source image in terms of overall brightness and color level. The generated complete artistic QR code image is output, and the boundary coordinates, brightness correction parameters and color adjustment coefficients of the embedded region are recorded for subsequent QR code recognition verification and editing operations.

[0098] In this embodiment, filling the corresponding position of the art QR code fragment into the source image to generate the complete art QR code image is the last step in the entire generation process and a key step that determines the final visual consistency and machine recognition accuracy.

[0099] Once the generated artistic QR code fragment is complete, the system first spatially aligns the fragment with the corresponding embedded region in the source image. Spatial alignment refers to the process of ensuring a precise match between the QR code fragment and the pixel grid of the source image in a two-dimensional plane. Since images may undergo slight rotation, scaling, or perspective distortion when displayed on different devices or after editing, geometric correction is necessary to eliminate errors. During correction, the system calls upon the pixel position index information recorded in the extraction step, mapping the original coordinates of each pixel to the target coordinates of the backfill area. To achieve high-precision matching, sub-pixel-level position adjustment is used, that is, calculating new pixel values ​​at non-integer pixel positions using bilinear interpolation. The basic principle of bilinear interpolation is: when the coordinates of the target pixel are between four adjacent pixels, the brightness values ​​of the four pixels are weighted and averaged according to distance. For example, when the target pixel is located at coordinates (100.3, 200.7), the system takes the brightness values ​​of the adjacent pixels (100,200), (101,200), (100,201), and (101,201), calculates a weighted average based on their distances from the target point, and thus obtains an accurate interpolated brightness value. In this way, the artistic QR code fragment can be precisely superimposed on the pixel grid of the source image.

[0100] After spatial alignment, the system extracts image data from the source image surrounding the embedding region, analyzes the brightness distribution, dominant hue, local texture direction, and edge gradient information of the neighborhood, and generates embedding environment feature data. Embedding environment feature data is a set of parameters describing the visual characteristics around the embedding region, used to guide subsequent brightness and color adjustments. Specifically, the brightness distribution parameter reflects the average brightness value and standard deviation of neighboring pixels. The dominant hue is determined by analyzing the mean and proportion of color channels; for example, if the red channel intensity accounts for more than 50%, the dominant hue of the region is defined as a warm color. The local texture direction can be obtained through a gradient direction histogram, and the edge gradient information represents the rate of change of pixel brightness in different directions. The system combines these data into embedding environment feature data to calculate the visual differences between the QR code fragment and the surrounding image.

[0101] Subsequently, the system performs brightness transition processing on the boundary regions of the art QR code fragments based on embedded environmental feature data. Within the boundary range, the system calculates the difference between the pixel brightness of the QR code fragment and the brightness of the neighboring pixels in the source image. Assuming the fragment pixel brightness is L1 and the neighboring brightness is L2, the brightness difference is |L1−L2|. The system adjusts the boundary pixel brightness value proportionally according to this difference. For example, when the brightness difference is 20 (with a brightness range of 0 to 255), the system can correct by 50% of the difference, that is, adjust the brightness value by 10 units, so that the boundary brightness is closer to the average value of the neighborhood. At the same time, contrast adjustment is achieved by calculating the ratio of the maximum and minimum brightness difference within the region to make the brightness change smooth. In addition, the system also corrects the color components of the boundary pixels according to the dominant color tone of the neighborhood. For example, when the neighborhood area is bluish, the brightness of the blue channel in the boundary pixels is increased proportionally, thereby achieving a natural transition of color.

[0102] After completing the brightness and color transition, the system performs local texture consistency reconstruction on the embedded region. Texture consistency refers to maintaining the continuity of the direction and density of image surface details. To achieve this, the system generates texture direction reference data based on the local texture direction in the embedded environment feature data. Specifically, the system calculates the gradient direction distribution of neighboring pixels, determines the main texture direction (e.g., horizontal, vertical, or diagonal), and then adjusts the pixel arrangement order within the embedded region according to this direction to ensure that the texture line extension direction is consistent with the neighborhood. If the neighboring texture is arranged horizontally, but the QR code fragment contains vertical texture, the system will adjust it to be more horizontal through local rotation or interpolation to avoid visual breaks.

[0103] After local texture consistency processing, the system performs global brightness balancing and contrast unification on the backfilled image. Global brightness balancing aims to ensure consistent brightness distribution across the entire image. The system first calculates the brightness histogram of the source image to obtain the overall brightness distribution curve and then calculates the brightness histogram of the embedded region. If the embedded region is found to be too bright or too dark overall, the system corrects the pixel brightness of that region according to the deviation ratio. For example, if the average brightness of the embedded region is 8% higher than the overall image, the system scales the brightness of all pixels in that region by 0.92 to match the overall brightness. Global contrast unification is achieved through linear stretching or compression of the grayscale range, ensuring that the brightness levels of the embedded region are consistent with the source image.

[0104] After all the above operations are completed, the system outputs the generated complete artistic QR code image, while recording the boundary coordinates of the embedded area, brightness correction parameters, and color adjustment coefficients. This recorded data can be used for subsequent QR code recognition verification and editing operations, such as checking the machine readability of the QR code or automatically adjusting the display effect under different lighting conditions.

[0105] In the above embodiments, a method for generating high-quality artistic QR codes based on intelligent region positioning is provided. Correspondingly, this application also provides a system for generating high-quality artistic QR codes based on intelligent region positioning. Since this embodiment, i.e., the second embodiment, is basically similar to the method embodiment, it is described simply; relevant details can be found in the description of the method embodiment. The method embodiments described below are merely illustrative.

[0106] The second embodiment of this application provides a high-quality artistic QR code generation system based on intelligent region positioning, including: The scanning unit 201 is used to scan the source image uploaded by the user using image analysis methods, and to perform local segmentation of the source image based on a preset analysis window size and sliding step size, and extract multiple candidate regions. The calculation unit 202 is used to calculate multi-dimensional image feature values, including information entropy, edge density and smoothness, for each candidate region, generate a region suitability score based on the multi-dimensional image feature values, and eliminate unsuitable regions according to the exclusion rule when the smoothness exceeds a preset threshold, and determine the candidate region with the highest region suitability score as the target region. Extraction unit 203 is used to extract corresponding region image segments from the source image based on the target region, input the region image segments and the QR code data to be encoded into the AIGC generation process, and generate an artistic QR code segment with both artistic texture features and a recognizable QR code structure using a generative image fusion method. The backfill unit 204 is used to backfill the art QR code fragment to the corresponding position of the source image to generate a complete art QR code image.

[0107] A third embodiment of this application provides an electronic device, the electronic device comprising: processor; The memory is used to store a program, which, when read and executed by the processor, executes a high-quality artistic QR code generation method based on intelligent region positioning provided in the first embodiment of this application.

[0108] The fourth embodiment of this application provides a computer-readable storage medium storing a computer program thereon. When the program is executed by a processor, it executes a high-quality artistic QR code generation method based on intelligent region positioning provided in the first embodiment of this application.

[0109] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.

Claims

1. A method for generating high-quality artistic QR codes based on intelligent region positioning, characterized in that, include: The source image uploaded by the user is scanned using image analysis methods. Based on the preset analysis window size and sliding step size, the source image is locally divided and multiple candidate regions are extracted. For each candidate region, multi-dimensional image feature values, including information entropy, edge density, and smoothness, are calculated. A region suitability score is generated based on the multi-dimensional image feature values. Unsuitable regions are eliminated according to the exclusion rule when the smoothness exceeds a preset threshold. The candidate region with the highest region suitability score is determined as the target region. Based on the target region, the corresponding region image fragment is extracted from the source image. The region image fragment and the QR code data to be encoded are input into the AIGC generation process. An artistic QR code fragment with both artistic texture features and a recognizable QR code structure is generated using a generative image fusion method. The art QR code fragment is then filled back into the corresponding position of the source image to generate a complete art QR code image.

2. The method for generating high-quality artistic QR codes based on intelligent region positioning according to claim 1, characterized in that, The method involves scanning the user-uploaded source image using image analysis. Based on a preset analysis window size and sliding step size, the source image is locally segmented, and multiple candidate regions are extracted, including: The source image uploaded by the user is preprocessed by converting the color space of the source image into a uniform brightness-saturation-hue space and performing histogram equalization on the brightness channel to correct brightness deviations under different shooting devices or lighting conditions, thereby obtaining a standardized image. The standardized image is scanned according to a preset analysis window size. The sliding step size of the scan is dynamically adjusted according to the brightness change of pixels within the window. When the brightness change within the window is greater than a first threshold, a smaller sliding step size is used to improve the resolution of the local area. When the brightness change within the window is less than a second threshold, a larger sliding step size is used to reduce the overlapping area. Both the first threshold and the second threshold are preset fixed values. For each image region within an analysis window, the brightness gradient change and texture direction change are calculated, and the two are combined to form region feature description data. The region feature description data includes statistical values ​​of pixel brightness change, statistical values ​​of texture direction change, and their position index information within the window. Based on the regional feature description data, the similarity of adjacent regions is compared. When the difference between the statistical value of brightness change and the statistical value of texture direction change of adjacent regions is less than the preset similarity threshold, the adjacent regions are merged into the same candidate region, resulting in multiple candidate regions that are consistent in brightness distribution and texture features. The boundary coordinates and the center position of each candidate region are recorded as output.

3. The method for generating high-quality artistic QR codes based on intelligent region positioning according to claim 1, characterized in that, For each candidate region, multi-dimensional image feature values, including information entropy, edge density, and smoothness, are calculated. A region suitability score is generated based on these multi-dimensional image feature values. Unsuitable regions are eliminated according to an exclusion rule that prevents smoothness from exceeding a preset threshold. The candidate region with the highest region suitability score is then determined as the target region. This process includes: For each candidate region's image data, a texture orientation-aware analysis is performed. By uniformly arranging multiple local sampling points within the region, the brightness difference and grayscale change direction of adjacent sampling points are calculated to obtain the main texture orientation data. The main texture orientation is then compared with the pixel distribution direction to determine whether the region has a texture orientation that can be embedded with a QR code structure. After obtaining the main direction data of the texture, the information entropy value, edge density value and smoothness value of the region are calculated. The information entropy is used to reflect the complexity of the brightness distribution, the edge density is used to reflect the concentration of the local gradient, and the smoothness is used to reflect the brightness continuity of the region. After normalizing the three values, the direction correction factor is generated using the brightness gradient distribution characteristics. The direction correction factor is used to enhance the score of the region that is consistent with the arrangement direction of the QR code module. The information entropy feature value, edge density feature value, and smoothness feature value are weighted and calculated with the direction correction factor to generate a comprehensive score for regional suitability. During the scoring process, if the edge density distribution of the specified region is not uniformly concentrated, that is, the edge density increases abruptly in one direction while it is sparse in other directions, its comprehensive score is automatically reduced to avoid local recognition interference in the subsequently generated image. Based on the exclusion rule when the smoothness exceeds the preset threshold, regions with smoothness feature values ​​exceeding the set upper limit are automatically removed; among the remaining regions, the candidate region with the highest comprehensive regional suitability score is selected as the target region, and the center coordinates, boundary contour, and direction correction parameters of the target region are output.

4. The method for generating high-quality artistic QR codes based on intelligent region positioning according to claim 1, characterized in that, Based on the target region, the corresponding region image fragment is extracted from the source image. This region image fragment, along with the QR code data to be encoded, is input into the AIGC generation process. A generative image fusion method is used to generate an artistic QR code fragment that combines artistic texture features with a readable QR code structure. This includes: Pixel-level extraction is performed on the determined target region, and the boundary contour of the target region is resampled with sub-pixel precision to obtain a region image fragment that covers the entire region. The position index information of each pixel in the region image fragment in the source image is recorded. Brightness and color analysis are performed on the image fragments of the region to extract the main color tone, brightness distribution parameters and color contrast information of the image fragments of the region, and to generate regional visual style data. The region visual style data and the QR code data to be encoded are processed to perform feature correspondence processing to establish a mapping relationship between the QR code module and the texture unit in the region image segment. The mapping relationship is generated based on the logical distribution information of the QR code module, so that each QR code module corresponds to a texture unit in the region image segment. Based on the mapping relationship, each texture unit is locally redrawn, and the brightness and contrast of the texture unit are adjusted according to the logical state of the QR code module, so that the QR code logical structure is embedded into the texture structure of the regional image fragment. At the same time, the color change range is limited according to the regional visual style data, and the edge continuity between the texture units is maintained. The redrawn texture units are combined according to their original spatial order to generate a complete artistic QR code fragment. The boundary coordinates, center position, and grayscale contrast parameters of the artistic QR code fragment are then output for subsequent image backfilling steps.

5. The method for generating high-quality artistic QR codes based on intelligent region positioning according to claim 4, characterized in that, The step of performing feature mapping processing on the regional visual style data and the QR code data to be encoded, and establishing a mapping relationship between the QR code module and the texture units in the regional image segment, includes: Based on the dominant color tone, brightness distribution parameters and texture direction information in the regional visual style data, visual feature matching data is generated for each QR code module; the matching similarity between each QR code module and multiple texture units in the regional image segment is calculated according to the visual feature matching data. In the texture unit set corresponding to each QR code module, the texture unit with the highest similarity is selected to establish a corresponding mapping relationship, and the brightness weight and direction deviation parameters between the QR code module and the texture unit are recorded. Based on the brightness weight and direction deviation parameters, the logic state of the QR code module and the brightness and contrast of the texture unit are adjusted accordingly, so that the logic structure of the QR code module is consistent with the visual style data of the region after embedding. The mapping relationship between the QR code module and the texture unit is stored in the form of a bidirectional index table. Each QR code module corresponds to a unique texture unit identifier. The texture unit identifier is used to recover the logical state of the original QR code module from the generated artistic QR code fragment. Obtain artistic QR code fragment data containing complete mapping relationships and brightness weight parameters, which will be used to generate artistic QR code fragments that combine artistic texture features and a recognizable QR code structure.

6. The method for generating high-quality artistic QR codes based on intelligent region positioning according to claim 1, characterized in that, The step of filling the corresponding position of the art QR code fragment into the source image to generate a complete art QR code image includes: Spatial alignment is performed between the corresponding positions of the art QR code fragment and the source image. Based on the pixel position index information recorded in the extraction step, the art QR code fragment is geometrically corrected. During the correction process, the pixel displacement vector is calculated based on the perspective offset of the embedded region, and the pixel coordinates of the art QR code fragment are adjusted at the sub-pixel level so that the art QR code fragment corresponds precisely to the original pixel grid of the source image in space. After spatial alignment is completed, image data around the embedded region in the source image is extracted to obtain the brightness distribution parameters, main color tone, local texture direction and edge gradient information of the neighborhood of the embedded region, and to generate embedded environment feature data. The embedded environment feature data serves as the input basis for subsequent color adjustment and brightness transition. Based on the embedded environmental feature data, brightness transition processing is performed on the boundary region of the art QR code fragment. Within the boundary range, the difference between the pixel brightness of the art QR code fragment and the brightness of the neighborhood of the source image is calculated. The brightness value and contrast of the boundary pixels are weighted and adjusted according to the ratio of the brightness difference to make the brightness gradient of the boundary region continuous with that of the source image. At the same time, the color components of the boundary pixels are corrected according to the dominant color of the neighborhood to make the color transition of the boundary region smooth and consistent. After the brightness transition is completed, local texture consistency reconstruction is performed on the embedded region. Texture direction reference data is generated based on the local texture direction information in the embedded environment feature data. The texture direction reference data is then used to correct the orientation consistency of the pixels in the embedded region, so that the art QR code fragment and the source image remain continuous in texture direction. Global brightness balancing and global contrast unification are performed on the image after brightness transition and texture consistency reconstruction. By statistically analyzing the overall brightness histogram of the source image, the brightness deviation between the embedded region and the source image is calculated, and the pixel brightness of the embedded region is proportionally corrected according to the deviation, so that the backfilled region is consistent with the source image in terms of overall brightness and color level. The generated complete artistic QR code image is output, and the boundary coordinates, brightness correction parameters and color adjustment coefficients of the embedded region are recorded for subsequent QR code recognition verification and editing operations.

7. A high-quality artistic QR code generation system based on intelligent regional positioning, characterized in that, include: The scanning unit is used to scan the source image uploaded by the user using image analysis methods. Based on the preset analysis window size and sliding step size, the source image is locally divided and multiple candidate regions are extracted. The calculation unit is used to calculate multi-dimensional image feature values, including information entropy, edge density and smoothness, for each candidate region, generate a region suitability score based on the multi-dimensional image feature values, and eliminate unsuitable regions according to the exclusion rule when the smoothness exceeds a preset threshold, and determine the candidate region with the highest region suitability score as the target region. The extraction unit is used to extract the corresponding region image fragment from the source image based on the target region, input the region image fragment and the QR code data to be encoded into the AIGC generation process, and generate an artistic QR code fragment with both artistic texture features and a recognizable QR code structure using a generative image fusion method. The backfill unit is used to backfill the art QR code fragment to the corresponding position of the source image to generate a complete art QR code image.

Citation Information

Patent Citations

  • Scannable image generation method fusing digital coding

    CN108229234A

  • RDH method based on superpixel sorting and edge type adaptive prediction

    CN114971995A

  • Method and device for generating artistic code image, equipment and medium

    CN117115293A

  • Method and device for generating artistic two-dimensional code, equipment and medium

    CN117454917A

  • Method, apparatus and device for generating artistic code image, and medium

    WO2025066918A1

Cited By

  • DPM metal two-dimensional code decoding method based on light source direction sensitivity difference

    CN122197922A

  • A DPM Metal QR Code Decoding Method Based on Light Source Direction Sensitivity Differences

    CN122197922B