Two-dimensional code image quality enhancement method and system based on multi-task ordinal regression

By employing a multi-task ordinal regression method for preprocessing, feature extraction, and fusion of QR code images, combined with morphological post-processing, the problem of QR code image quality degradation in complex industrial environments is solved, improving the decoding robustness and quality restoration effect of the images. This approach is suitable for industrial automation and intelligent manufacturing.

CN121659970APending Publication Date: 2026-03-13SHANDONG UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-15
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

In complex industrial environments, the duty cycle distribution of QR code images is affected by factors such as uneven lighting, surface reflection, dirt, water stains, and camera defocusing, leading to a decline in image quality. Traditional methods struggle to achieve effective adaptive recovery of the QR code duty cycle, thus impacting decoding performance.

Method used

A multi-task ordinal regression method is adopted, which predicts the duty cycle level and pixel density level through image preprocessing, multi-scale feature extraction and fusion, and morphological post-processing. Combined with morphological post-processing, dilation and erosion operations are performed on the QR code image to improve image quality.

Benefits of technology

It significantly improves the quality restoration effect and decoding robustness of QR code images in complex industrial scenarios such as low resolution, low contrast, and high noise, and is suitable for industrial automation and intelligent manufacturing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121659970A_ABST
    Figure CN121659970A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image enhancement, in particular to a two-dimensional code image quality enhancement method and system based on multi-task ordinal regression. The method comprises the following steps: firstly, preprocessing a two-dimensional code image to obtain an updated image; performing multi-scale feature extraction and feature fusion on the updated image to obtain fusion features; predicting a duty ratio grade and a pixel density grade based on the fusion features; the duty ratio grade and the pixel density grade are normalized and then linearly combined, and the morphological post-processing kernel size is determined; and calculating the maximum number of iterations of morphological post-processing in combination with the offset degree of the duty ratio grade and the intermediate ideal grade, performing multiple expansion and corrosion operations on the updated image by using the morphological post-processing core based on the maximum number of iterations, and finally obtaining a quality-enhanced two-dimensional code image. The method effectively solves the problem of quality degradation of the two-dimensional code in practical application scenes of low resolution, high noise, low contrast and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image enhancement technology, specifically a method and system for enhancing QR code image quality based on multi-task ordinal regression. Background Technology

[0002] QR codes (such as Quick Response Codes) are a highly efficient and reliable image encoding technology widely used in mobile payments, IoT tags, smart manufacturing, and industrial product traceability. The core step in the QR code decoding process lies in the accurate sampling and positioning of the black and white modules. This crucial step largely depends on the accuracy and stability of the duty cycle (i.e., the ratio of the black pixel area to the total image area) of the QR code image.

[0003] However, real-world shooting environments are often extremely complex. Uneven lighting, surface reflections, dirt, water stains, out-of-focus or blurry camera shots, and unclear characters or ink overflow during the printing process can all significantly interfere with the duty cycle distribution of QR code images, leading to areas that are too dark or too bright. Furthermore, reliable estimation of the duty cycle is highly dependent on the scale of the QR code itself, i.e., pixels per module (PPM). In some industrial production line scenarios, QR codes are often used to identify small parts, and the black and white modules of the QR code are often only a few pixels in size, making the image quality requirements extremely stringent. Simultaneously, industrial environments often involve complex and drastic changes in operating conditions, and shooting equipment frequently faces challenges such as low resolution, low contrast, high noise, and even motion blur. Under these extreme shooting conditions, traditional global thresholding or geometric correction methods often struggle to achieve effective adaptive recovery of the QR code duty cycle, thus significantly reducing the decodeability of the QR code image and severely impacting downstream identification and traceability tasks. Summary of the Invention

[0004] The purpose of this invention is to provide a method and system for enhancing QR code image quality based on multi-task ordinal regression.

[0005] A QR code image quality enhancement method based on multi-task ordinal regression includes the following operations: S1. Obtain the QR code image. The QR code image is preprocessed to obtain the updated QR code image. S2. Perform multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. ; S3, will , , A unified scale is used to concatenate the features to obtain a fused feature vector. The fused feature vector is then passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. Finally, the multiple probability distributions are added together to obtain the predicted duty cycle level. , , After pooling and concatenation, a global feature vector is obtained. The global feature vector is then linearly mapped and activated to obtain regression prediction. The global feature vector is linearly transformed and then nonlinearly mapped to generate multiple probability distributions. These multiple probability distributions are accumulated and added to a preset minimum pixel density to obtain hierarchical prediction. The regression prediction and hierarchical prediction are then fused to obtain the predicted pixel density level. S4. The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The offset between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level. The maximum number of iterations for morphological post-processing is calculated based on the offset. S5. Based on the maximum number of iterations, perform multiple dilation and erosion operations on the updated QR code image using morphological post-processing to obtain a QR code image with enhanced quality.

[0006] The multi-scale feature extraction operation in S2 is as follows: convolution is performed on the updated QR code image to obtain the first-scale feature; the first-scale feature is expanded through channels, processed by depthwise separable convolution and activation function, and then compressed through channels. The above steps are repeated multiple times, and the second-scale feature is obtained through convolution operation; the second-scale feature is processed by convolution and pooling operation to obtain the third-scale feature.

[0007] The specific operation in S3 to obtain the predicted duty cycle level is: to combine multiple probability distributions The sum is used to obtain the predicted duty cycle level. The specific formula is as follows: , Among them, the authenticity level of the QR code image ,correspond There are two binary classification subtasks that determine whether the value is greater than or equal to a threshold k, where k is the threshold value corresponding to the binary classification subtask. .

[0008] The specific operation to obtain regression predictions in S3 is as follows: global feature vector. Regression predictions are obtained through linear mapping and activation functions. The specific formula is as follows: , in, , This is the weight matrix. This is the activation function.

[0009] The specific operation for obtaining hierarchical predictions in S3 is as follows: Multiple probability distributions... The summation is then added to the preset minimum pixel density to obtain the hierarchical prediction. The specific formula is as follows: , Set the range of pixel density values ​​as follows: , The minimum pixel density is given by the pixel density level boundary. ,correspond Does it exceed the level boundary? The binary classification subtask, where k is the threshold corresponding to the binary classification subtask, and takes a value of .

[0010] The specific operation for obtaining the predicted pixel density level in S3 is: fusion regression prediction. With hierarchical prediction The predicted pixel density level is obtained. The specific formula is as follows: , in This is a hyperparameter.

[0011] The specific operation for obtaining the kernel scale index in S4 is: the predicted duty cycle level. With pixel density level After normalization, the kernel scale index is obtained by linear combination. The specific formula is as follows: , in This is a hyperparameter.

[0012] The specific operation in S4 for determining the size of the morphological post-processing kernel is: kernel scale index. Perform mapping to determine the size of the morphological post-processing kernel. The specific formula is as follows: , in, These are hyperparameters used to limit the maximum morphological post-processing kernel radius. This indicates that the value within the parentheses is rounded up.

[0013] The operation in S4 to calculate the maximum number of iterations for morphological post-processing is as follows: Calculate the maximum number of iterations for morphological post-processing based on the offset. The specific formula is as follows: , in, This represents the degree of deviation between the current image duty cycle level and the ideal intermediate level. This indicates that the value within the parentheses is rounded down. This represents the upper limit of the number of iterations.

[0014] A QR code image quality enhancement system based on multi-task ordinal regression includes: Image preprocessing module: acquires the QR code image, and preprocesses the QR code image to obtain the updated QR code image; Multi-scale feature extraction and fusion module: Performs multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. ; Level prediction module: , , A unified scale is used to concatenate the features to obtain a fused feature vector. The fused feature vector is then passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. Finally, the multiple probability distributions are added together to obtain the predicted duty cycle level. , , After pooling and concatenation, a global feature vector is obtained. The global feature vector is then linearly mapped and activated to obtain regression prediction. The global feature vector is linearly transformed and then nonlinearly mapped to generate multiple probability distributions. These multiple probability distributions are accumulated and added to a preset minimum pixel density to obtain hierarchical prediction. The regression prediction and hierarchical prediction are then fused to obtain the predicted pixel density level. Morphological post-processing parameter determination module: The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The offset between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level. The maximum number of iterations of morphological post-processing is calculated based on the offset. Morphological post-processing module: Based on the maximum number of iterations, the updated QR code image is subjected to multiple dilation and erosion operations using a morphological post-processing kernel to obtain a QR code image with enhanced quality.

[0015] The beneficial effects of this invention are: This invention provides a QR code image quality enhancement method based on multi-task ordinal regression. First, the QR code image is preprocessed to obtain an updated image. Then, multi-scale feature extraction and feature fusion are performed on the updated image to obtain fused features. Based on the fused features, duty cycle level and pixel density level are predicted. The duty cycle level and pixel density level are linearly combined after normalization to determine the morphological post-processing kernel size. The maximum number of iterations for morphological post-processing is calculated by combining the offset between the duty cycle level and the intermediate ideal level. Based on the maximum number of iterations, the updated image is subjected to multiple dilation and erosion operations using the morphological post-processing kernel, ultimately obtaining the enhanced QR code image. This invention can significantly improve the quality restoration effect and decoding robustness of QR code images in complex industrial scenarios such as low resolution, low contrast, and high noise, and has broad application prospects and practical value in the fields of industrial automation and intelligent manufacturing. Attached Figure Description

[0016] Figure 1 This is a first set of QR code quality enhancement effect diagrams of the present invention; Figure 2 This is a diagram showing the quality enhancement effect of the second set of QR codes in this invention. Detailed Implementation

[0017] This embodiment provides a QR code image quality enhancement method based on multi-task ordinal regression, the specific operation of which is as follows: S1. Obtain the QR code image. The QR code image is preprocessed to obtain the updated QR code image.

[0018] Among all the QR code images to be processed, those with incomplete black-and-white modules and a large number of irregular noise points are grouped together, such as... Figure 1 As shown in the first row; QR code images with blurred black-and-white modules, insufficient contrast, and severe noise interference are grouped together, such as... Figure 2 As shown in the first row, each group of QR code images is preprocessed to obtain the updated QR code image.

[0019] In the image preprocessing stage, to eliminate the influence of external environmental factors on subsequent processing, the QR code image is first geometrically corrected, and then contrast-limited adaptive histogram equalization is used to improve the overall brightness and local contrast of the image. Next, adaptive bilateral filtering is used to remove high-frequency noise while maintaining the integrity of edge information. Finally, adaptive binarization is used to binarize the images in different states to obtain the updated QR code image.

[0020] S2. Perform multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. .

[0021] The multi-scale feature extraction operation is as follows: convolution is performed on the updated QR code image to obtain the first-scale feature; the first-scale feature is expanded through channels, processed by depthwise separable convolution and activation function, and then channel compression is performed. The above steps are repeated multiple times, and the second-scale feature is obtained through convolution operation; the second-scale feature is processed by convolution and pooling operation to obtain the third-scale feature.

[0022] Applying 1×1 convolutions to the first-scale features, second-scale features, and third-scale features respectively to unify the number of channels and suppress redundant information, yields the fused features. , , ; After upsampling, and Perform feature fusion to obtain ; After upsampling, and Perform feature fusion to obtain The specific formula is as follows: , , in, This indicates bilinear interpolation, which can preserve shallow spatial details while introducing deeper semantic information. To reduce the aliasing effect caused by upsampling, [the following is used:] ... , Apply a 3×3 convolution once to obtain the fused features. , The specific formula is as follows:

[0023] right After deep feature extraction and pooling, fused features are obtained. Deep feature extraction includes multi-head attention processing, residual connections, and normalization, with the specific operations as follows: First, Flattened into a sequence S of N tokens according to spatial dimensions, where B is the batch size, C is the number of channels, and H and W are the width and height, respectively, the specific formula is as follows: , in, Represents the i-th token. This indicates transpose, which is the operation of swapping rows and columns in a matrix.

[0024] Next, sequence S generates query matrix Q, key matrix K, and value matrix V through linear mapping: , , , in, , , It is a learnable weight matrix.

[0025] The query matrix Q, key matrix K, and value matrix V are each divided into h submatrices, corresponding to h attention heads. Each attention head independently calculates a weighted sum, and the weighted sum of the i-th attention head is... The specific formula is as follows: , in, For activation function, , , These are the i-th submatrices after partitioning the query matrix Q, key matrix K, and value matrix V, respectively. This is the scaling factor.

[0026] By concatenating the weighted sums of the h attention heads, we obtain a weighted sum sequence. The weighted sum sequence is passed through the output linear layer to obtain the multi-head attention output. : , , in, It is a learnable weight matrix.

[0027] For sequence T and multi-head attention output Perform residual connections and layer normalization to obtain the output sequence. : , in, This is the layer normalization function.

[0028] Output sequence The fused features are obtained by averaging the values ​​across the token dimension N. : , in, Represents the output sequence The first in 1 eigenvector This represents the number of channels.

[0029] Deep feature extraction can capture long-distance dependencies between any two points in an image at the same scale at once, thus breaking through the limitations of convolutional receptive field on kernel size and number of layers, and achieving efficient perception of large-scale blur or transmission distortion patterns; the multi-head attention mechanism can adaptively assign weights to each position from different subspace perspectives, automatically focusing on the region that best reflects the difference in the degree of local blur and erosion of the QR code.

[0030] S3, will , , A unified scale is used to concatenate the features to obtain a fused feature vector. The fused feature vector is then passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. Finally, the multiple probability distributions are added together to obtain the predicted duty cycle level. , , After pooling and concatenation, a global feature vector is obtained. The global feature vector is then linearly mapped and activated to obtain regression prediction. The global feature vector is linearly transformed and then nonlinearly mapped to generate multiple probability distributions. These multiple probability distributions are accumulated and added to a preset minimum pixel density to obtain a hierarchical prediction. The regression prediction and hierarchical prediction are then fused to obtain the predicted pixel density level.

[0031] QR code duty cycle classification is not inherently an unordered multi-class classification problem, nor is it a continuous regression problem; rather, it is an ordinal regression problem. The duty cycle classification task is divided into several parts. Level There is a clear sequential relationship between the levels. If it is simply treated as a normal multi-class classification task, the key prior information of the ordered levels will be ignored, resulting in the inability to capture the progressive logic between the levels. If regression methods (such as mean squared error loss) are used directly, it is difficult to ensure that the output results strictly fall into the set of discrete integers, and it is impossible to implement differentiated penalties for "adjacent level errors" and "far-distance level errors" (e.g., the penalty for errors that differ by 3 levels should be heavier than the penalty for errors that differ by 1 level), thus affecting the accuracy and rationality of the classification.

[0032] The core advantage of ordinal regression lies in accurately representing the true level of a QR code image. Split into A binary classification subtask of "whether it is greater than a threshold k", and the fused feature vector is... The raw scores of each subtask are obtained through fully connected layers and biases. The specific formula is as follows: , in, This is the transpose of the weight matrix. Here, k is the bias term, and k is the threshold corresponding to the binary classification subtask, with a value of [value missing]. .

[0033] raw fractions The probability distribution of each subtask is generated by the activation function. The specific formula is as follows: , in, This represents the sigmoid activation function.

[0034] Multiple probability distributions The sum is used to obtain the predicted duty cycle level. The specific formula is as follows: , global feature vector Regression predictions are obtained through linear mapping and activation functions. The specific formula is as follows: , in, , This is the weight matrix. This is the activation function.

[0035] global feature vector Multiple probability distributions are generated through nonlinear mapping. The specific formula is as follows: , in, For activation function, This is the transpose of the weight matrix. This is a bias term.

[0036] Multiple probability distributions The summation is then added to the preset minimum pixel density to obtain the hierarchical prediction. The specific operation is as follows: , Set the range of pixel density values ​​as follows: , Minimum pixel density The level boundaries of pixel density are ,correspond Does it exceed the level boundary? The binary classification subtask, where k is the threshold corresponding to the binary classification subtask, and takes a value of .

[0037] Fusion regression prediction With hierarchical prediction The predicted pixel density level is obtained. The specific formula is as follows: , in This is a hyperparameter.

[0038] In S2, the operations for predicting duty cycle levels and pixel density levels are implemented based on a duty cycle hierarchical branch and a pixel density prediction branch, respectively. The pixel density prediction branch further includes a hierarchical prediction branch and a regression prediction branch. To balance ordinal information and continuous accuracy, a multi-path supervision mechanism combining ordinal regression and other auxiliary constraints is adopted for both the duty cycle hierarchical branch and the pixel density prediction branch. (1) Duty cycle hierarchical branch loss Let the true level of the i-th QR code image be . Break it down into Binary classification truth labels corresponding to each binary classification subtask : , The prediction probability for each subtask "whether > k" is: The consistent rank logits (CORAL) loss is calculated using binary cross-entropy. : , This splitting method imposes a stronger penalty on long-range grade errors (such as a true grade of 3 but a predicted grade of 1 or 5), if the predicted duty cycle grade... Compared to the actual level If the difference is d, then exactly d consecutive thresholds k will be misjudged. Therefore, approximately d cross-entropy terms will be simultaneously added to the total loss. The accumulated loss of d cross-entropy terms is... : , in, "Proportional to" is used to express a direct proportional relationship between two quantities. Indicates the increment of loss The error is directly proportional to the degree of misclassification, d. Therefore, the greater the prediction error, the more binary classification thresholds are crossed, and the greater the loss. This fulfills the intuitive requirement that "the greater the difference between the predicted and true grades, the more severe the penalty." This approach has a significant advantage over ordinary Softmax (which only applies a single penalty to overall misclassification) or Mean Squared Error (MSE) regression (which has no difference in penalty intensity for large and small errors).

[0039] Duty cycle levels obtained by accumulating ordinal regression probabilities Compared to the actual level By applying mean square error constraints, the mean square error loss is obtained. To ensure that the graded probability output remains consistent with the actual grade overall, the specific formula is as follows:

[0040] Uniform rank logarithmic probability loss and mean square error loss The combined result yields the total loss based on duty cycle classification. : , in This is a hyperparameter that controls the strength of the mean square error constraint.

[0041] (2) Pixel density prediction branch loss Pixels per Module (PPM) directly reflects the size of the black-and-white QR code module in the image, and is closely related to image resolution and scaling operations. Its actual value exhibits both discrete hierarchical attributes and continuous numerical variations. This application uses pixel density to represent this influencing factor. Based on this, this invention designs a hierarchical + regression dual-path parallel supervision mechanism for the pixel density prediction branch: Set pixel density The range of values ​​is ,correspond Each level. Break it down into... There are two binary classification subtasks, and the true label of the k-th subtask is defined as follows: , The raw score output for each subtask is The probability distribution is obtained by Sigmoid. After accumulating the binary cross-entropy loss over all subtasks, the CORAL ordinal regression loss is obtained. : , When hierarchical prediction With pixel density difference At that time, there happened to be Several consecutive binary classification subtasks were misclassified, therefore The linear accumulation of errors from misjudged subtasks results in a more severe penalty for long-range rank errors (where the predicted rank differs significantly from the true rank), thereby improving the learning accuracy of rank ordinal relationships.

[0042] To ensure sensitive fitting to subtle size variations, a smoothed L1 regression loss was applied to the regression prediction branch. : , in, For regression prediction results, This represents the pixel density value.

[0043] The total pixel density loss is the CORAL ordinal regression loss. Smoothing L1 regression loss Weighted sum: , in, This is a balancing factor used to balance the contributions of PPM grading and regression. This design preserves the continuity of pixel density values ​​while imposing stricter order constraints on the error of distant grades, which not only accelerates the convergence speed but also makes the prediction curve smoother and more robust when changing across scales.

[0044] (3) Total loss from multitasking Combining the above losses yields the total multi-task loss. : , The multi-task total loss can fully leverage CORAL's advantage in penalizing rank errors. By using ordinal regression to finely fit small errors, it improves the robustness and accuracy of this invention in QR code quality enhancement tasks.

[0045] S4. The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The offset between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level. The maximum number of iterations for morphological post-processing is calculated based on the offset.

[0046] The kernel scale index is mapped to determine the size of the morphological post-processing kernel, resulting in a morphological post-processing kernel adapted to the features of each set of QR code images.

[0047] Predicted duty cycle level With pixel density level After normalization, the kernel scale index is obtained by linear combination. The specific formula is as follows: , in This is a hyperparameter.

[0048] nuclear scale index Perform mapping to determine the size of the morphological post-processing kernel. The specific formula is as follows: , in, These are hyperparameters used to limit the maximum morphological post-processing kernel radius. This indicates that the value within the parentheses is rounded up.

[0049] Let the predicted duty cycle level be and the central ideal level ,calculate and absolute difference between The specific formula is as follows: , in, It indicates the degree of deviation between the current image duty cycle level and the ideal intermediate level.

[0050] The maximum number of iterations for morphological post-processing is calculated based on the degree of offset. The specific formula is as follows: , in, This represents the degree of deviation between the current image duty cycle level and the ideal intermediate level. This indicates that the value within the parentheses is rounded down. To set the upper limit for the number of iterations, Set to half the total number of levels, using the following formula: , When the predicted level is close to the actual level, post-processing can be skipped. However, when the predicted level deviates significantly from the central ideal level, more iterations will be automatically allocated for correction. Overall, the number of iterations corresponds linearly to the duty cycle deviation, ensuring both effective correction and avoiding meaningless recalculation.

[0051] S5. Based on the maximum number of iterations, perform multiple dilation and erosion operations on the updated QR code image using morphological post-processing to obtain a QR code image with enhanced quality.

[0052] This embodiment also provides a QR code image quality enhancement system based on multi-task ordinal regression, including: Image preprocessing module: acquires the QR code image, and preprocesses the QR code image to obtain the updated QR code image; Multi-scale feature extraction and fusion module: Performs multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. ; Level prediction module: , , A unified scale is used to concatenate the features to obtain a fused feature vector. The fused feature vector is then passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. Finally, the multiple probability distributions are added together to obtain the predicted duty cycle level. , , After pooling and concatenation, a global feature vector is obtained. The global feature vector is then linearly mapped and activated to obtain regression prediction. The global feature vector is linearly transformed and then nonlinearly mapped to generate multiple probability distributions. These multiple probability distributions are accumulated and added to a preset minimum pixel density to obtain hierarchical prediction. The regression prediction and hierarchical prediction are then fused to obtain the predicted pixel density level. Morphological post-processing parameter determination module: The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The offset between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level. The maximum number of iterations of morphological post-processing is calculated based on the offset. Morphological post-processing module: Based on the maximum number of iterations, the updated QR code image is subjected to multiple dilation and erosion operations using a morphological post-processing kernel to obtain a QR code image with enhanced quality.

[0053] To verify the effectiveness of this invention, ablation experiments were conducted. The ablation experiments were performed on a high-performance Linux server running Ubuntu 22.04. This server was equipped with an Intel 13th Gen Core i9-13900K processor and two NVIDIA GeForce RTX 3090 graphics cards, each with 24GB of video memory, capable of efficiently supporting the large-scale data-parallel training tasks in the experiments. Regarding the deep learning framework, the experiments were built using the stable PyTorch 1.10.0 version. Code development, debugging, and training process management in the experiments were all completed using Visual Studio Code.

[0054] The ablation experiments are shown in Table 1. The indicators in Table 1 are as follows: MAE is the Mean Absolute Error (MAE); RMSE is the Root Mean Square Error (RMSE). The lower the value of the above indicators, the more accurate the prediction; Spearman is the Spearman rank correlation coefficient, which measures the correlation between the predicted rank and the true rank. The closer it is to 1, the better; Acc is the accuracy, which measures the proportion of samples that are correctly predicted. The closer the value is to 1, the higher the accuracy.

[0055] Table 1 Ablation Experiment

[0056] Table 1 shows the ablation experiments, which evaluate the performance of the method of the present invention and the removal of the pixel density prediction branch, duty cycle hierarchical branch, depth feature extraction, and feature fusion using four indicators: MAE, RMSE, Spearman, and Acc. The results show that as the pixel density prediction branch, duty cycle hierarchical branch, depth feature extraction operation, and feature fusion operation are removed in sequence, the MAE and RMSE indicators gradually increase, while the Acc indicator gradually decreases, indicating that each module / branch plays an important supporting role in the overall performance of the present invention.

[0057] Figure 1 , Figure 2 The images show two sets of QR code images after quality enhancement processing using the method of this invention. The first row shows the original low-quality QR code image, which suffers from problems such as incomplete black-and-white modules and noise interference; the second row shows the QR code image processed by the method of this invention, where the integrity and clarity of the black-and-white modules are significantly improved. Figure 1 , Figure 2 It can be seen that the method of the present invention effectively solves the quality problems of noise and low contrast in the original image, realizes efficient optimization of QR code image, and provides a better image foundation for subsequent recognition or application.

Claims

1. A QR code image quality enhancement method based on multi-task ordinal regression, characterized in that, This includes the following operations: S1. Obtain the QR code image. The QR code image is preprocessed to obtain the updated QR code image. S2. Perform multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. ; S3, will , , By unifying the scale and concatenating the data, a fused feature vector is obtained. The fused feature vectors are passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. The sum of these probability distributions yields the predicted duty cycle level. , , After pooling, the features are concatenated to obtain a global feature vector. The global feature vector is then subjected to linear mapping and activation function to obtain regression prediction. A linear transformation is performed on the global feature vector, and multiple probability distributions are generated through nonlinear mapping. The multiple probability distributions are accumulated and added to the preset minimum pixel density to obtain hierarchical prediction. By fusing regression prediction and hierarchical prediction, the predicted pixel density level is obtained; S4. The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The deviation between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level, and the maximum number of iterations for morphological post-processing is calculated based on the deviation level. S5. Based on the maximum number of iterations, perform multiple dilation and erosion operations on the updated QR code image using morphological post-processing to obtain a QR code image with enhanced quality.

2. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The multi-scale feature extraction operation in S2 is specifically as follows: Convolve the updated QR code image to obtain the first-scale features; The first-scale feature is expanded through channels, processed by depthwise separable convolution and activation function, and then compressed through channels. This process is repeated multiple times, and the second-scale feature is obtained through convolution. The second-scale features are then subjected to convolution and pooling operations to obtain the third-scale features.

3. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The specific operation for obtaining the predicted duty cycle level in S3 is as follows: Multiple probability distributions The sum is used to obtain the predicted duty cycle level. The specific formula is as follows: , Among them, the authenticity level of the QR code image ,correspond There are two binary classification subtasks that determine whether the value is greater than or equal to a threshold k, where k is the threshold value corresponding to the binary classification subtask. .

4. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The specific steps for obtaining the regression prediction in S3 are as follows: global feature vector Regression predictions are obtained through linear mapping and activation functions. The specific formula is as follows: , in, , This is the weight matrix. This is the activation function.

5. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The specific steps for obtaining the hierarchical prediction in S3 are as follows: Multiple probability distributions The summation is then added to the preset minimum pixel density to obtain the hierarchical prediction. The specific formula is as follows: , Set the range of pixel density values ​​as follows: , The minimum pixel density is given by the pixel density level boundary. ,correspond Does it exceed the level boundary? The binary classification subtask, where k is the threshold corresponding to the binary classification subtask, and takes a value of .

6. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The operation to obtain the predicted pixel density level in S3 is specifically as follows: Fusion regression prediction With hierarchical prediction The predicted pixel density level is obtained. The specific formula is as follows: , in This is a hyperparameter.

7. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The specific steps for obtaining the kernel scale index in S4 are as follows: Predicted duty cycle level With pixel density level After normalization, the kernel scale index is obtained by linear combination. The specific formula is as follows: , in This is a hyperparameter.

8. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The operation in S4 that determines the size of the morphological post-processing kernel specifically involves: nuclear scale index Perform mapping to determine the size of the morphological post-processing kernel. The specific formula is as follows: , in, These are hyperparameters used to limit the maximum morphological post-processing kernel radius. This indicates that the value within the parentheses is rounded up.

9. The QR code image quality enhancement method based on multi-task ordinal regression according to claim 1, characterized in that, The operation in S4 that calculates the maximum number of iterations for morphological post-processing is specifically as follows: The maximum number of iterations for morphological post-processing is calculated based on the degree of offset. The specific formula is as follows: , in, This represents the degree of deviation between the current image duty cycle level and the ideal intermediate level. This indicates that the value within the parentheses is rounded down. This represents the upper limit of the number of iterations.

10. A QR code image quality enhancement system based on multi-task ordinal regression, characterized in that, include: Image preprocessing module: acquires the QR code image, and preprocesses the QR code image to obtain the updated QR code image; Multi-scale feature extraction and fusion module: Performs multi-scale feature extraction on the updated QR code image to obtain three scale features, which are then fused to obtain the fused features. The fused features are obtained by fusing the features from the first two scales, arranged from smallest to largest. The smallest scale feature is selected for deep feature extraction and pooling to obtain the fused feature. ; Level prediction module: , , By unifying the scale and concatenating the data, a fused feature vector is obtained. The fused feature vectors are passed through a fully connected layer and a bias to obtain multiple raw scores. These raw scores are then subjected to nonlinear mapping to generate multiple probability distributions. The sum of these probability distributions yields the predicted duty cycle level. , , After pooling and concatenation, a global feature vector is obtained. The global feature vector is then linearly mapped and activated to obtain regression prediction. The global feature vector is linearly transformed and then nonlinearly mapped to generate multiple probability distributions. These multiple probability distributions are accumulated and added to a preset minimum pixel density to obtain hierarchical prediction. The regression prediction and hierarchical prediction are then fused to obtain the predicted pixel density level. Morphological post-processing parameter determination module: The predicted duty cycle level and pixel density level are normalized and then linearly combined to obtain the kernel scale index. The kernel scale index is mapped to determine the size of the morphological post-processing kernel. The offset between the current image duty cycle level and the intermediate ideal level is calculated based on the predicted duty cycle level. The maximum number of iterations of morphological post-processing is calculated based on the offset. Morphological post-processing module: Based on the maximum number of iterations, the updated QR code image is subjected to multiple dilation and erosion operations using a morphological post-processing kernel to obtain a QR code image with enhanced quality.