Image rotation angle identification and correction method and system

By collecting and labeling image rotation angles, a training set is constructed. The model is iteratively trained using random rotation enhancement and improved loss functions. The learning rate is optimized by combining PSNR and SSIM. This solves the problem of high deviation rate in image rotation angle recognition in existing technologies and achieves high-precision image correction.

CN121353084APending Publication Date: 2026-01-16SUZHOU CHUANGLUTIANXIA INFORMATION TECH CO LTD

Patent Information

Application Number
CN202511257842.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2026-01-16

AI Technical Summary

Technical Problem

Existing technologies cannot recognize the rotation angle of images at arbitrary angles, resulting in an excessively high deviation rate in image correction.

Method used

By collecting and labeling the rotation angles of the original images, a training set is constructed. An initial regression model is built using a specific neural network and an improved loss function. The initial regression model is then enhanced by random rotation and an improved loss function. Diverse samples are generated for iterative training. Image correction is performed using an affine transformation function. Finally, a closed-loop feedback mechanism is constructed using dual quality assessments of PSNR and SSIM to optimize the learning rate.

Benefits of technology

It significantly improves the model's generalization ability and stability in different rotation scenarios, enhances the accuracy and robustness of image rotation angle recognition, and achieves high-precision image correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121353084A_ABST
    Figure CN121353084A_ABST
Patent Text Reader

Abstract

The invention relates to an image rotation angle recognition and correction method and system, and relates to the technical field of image processing, and the method comprises the steps: collecting an original image, marking and rotating a corresponding image rotation angle, obtaining a corrected image, and constructing a training set; selecting a corresponding neural network according to the model architecture, and constructing an initial regression model in combination with a preset improved loss function; rotating the corrected image according to a random angle, constructing a training sample, and iteratively training the initial regression model in combination with the training set to obtain a rotation angle recognition model; recognizing and judging the original image through the rotation angle recognition model, and outputting an image rotation angle; rotating the original image according to the image rotation angle to obtain a corrected image; the recognition of any rotation angle of the image is realized by improving the L1 loss function, and the robustness and accuracy of the rotation angle recognition model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an image rotation angle recognition and correction method and system. Background Technology

[0002] Image rotation angle recognition aims to address the visual discomfort and processing difficulties caused by incorrect rotation angles in images. By automatically identifying the rotation angle in an image and rotating it to the correct orientation, the visibility and processability of the image can be improved. With the successful application of deep learning in the image processing field, some researchers have attempted to use deep learning technology to achieve rotation angle recognition and have achieved some results. Currently, deep learning-based rotation angle recognition algorithms typically treat angle recognition as a classification problem, dividing it into 12 categories, with each category representing a 30-degree interval.

[0003] Patent No. CN201910601151.5 discloses an angle-based target detection training method, target detection method, and apparatus. The angle-based target detection training method includes: an image acquisition step, acquiring a training image; a prediction box acquisition step, acquiring prediction boxes using a neural network based on the acquired training image; a marker point acquisition step, acquiring a first vertex of the marker box, a second vertex of the prediction box corresponding to the first vertex, and a third point within the marker box; a loss acquisition step, obtaining a loss based on a target loss, wherein the target loss includes an angle loss, obtained based on the angle between the line connecting the first and third vertices and the line connecting the second and third vertices; and an optimization step, training the neural network based on the target loss. By introducing an angle loss function to constrain the target detection process, the constraint on the overlap between the marker box and the prediction box is enhanced, thereby improving the accuracy of target detection.

[0004] The existing technical solutions described above have the following drawbacks: 1. Existing technology cannot achieve recognition at any angle, i.e., from 0 to 359 degrees, resulting in an excessively high deviation rate in image correction. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention is achieved through the following technical solution: An image rotation angle recognition and correction method includes: Acquire the original image, label and rotate the corresponding image rotation angle to obtain the corrected image, and construct the training set; Select the corresponding neural network based on the model architecture, and construct the initial regression model by combining it with the preset improved loss function; Based on the corrected image rotated at a random angle, training samples are constructed, and the initial regression model is iteratively trained using the training set to obtain a rotation angle recognition model. The original image is identified and judged by the rotation angle recognition model, and the image rotation angle is output. The original image is rotated according to the rotation angle of the original image to obtain the corrected image.

[0006] By employing the above technical solution, a corrected image is generated by acquiring and labeling the rotation angle of the original image to construct a training set. An initial regression model is built based on a specific neural network architecture and an improved loss function (such as HuberLoss or circular distance loss). Diverse samples are generated using the corrected image with random angle rotation for iterative training, thereby obtaining a highly robust rotation angle recognition model. Finally, this model outputs the rotation angle of the original image, and image rotation algorithms such as affine transformation functions are used to correct the original image, resulting in the final corrected image. By introducing random rotation enhancement and an improved loss function, the model's generalization ability and stability under different rotation scenarios are significantly improved.

[0007] Preferably, this method further includes: The corrected image is matched with the modified image, and the structural similarity and peak signal-to-noise ratio are calculated. If the peak signal-to-noise ratio is greater than the preset signal-to-noise threshold, it indicates that the corrected image and the modified image are aligned successfully, and the structural similarity and the peak signal-to-noise ratio are weighted and calculated to obtain the fusion deviation term; The learning rate is optimized based on the fusion bias term to obtain a dynamic learning function; The angle correction weight matrix is ​​obtained by iteratively training the training set according to the dynamic learning function. The preprocessed original image is identified based on the angle correction weight matrix to obtain the rotation correction angle; The original image is corrected according to the rotation correction angle, and matched with the corrected image to calculate the correction similarity and correction signal-to-noise ratio, which are then compared with the structural similarity and the peak signal-to-noise ratio. If the corrected similarity is greater than the structural similarity and the corrected signal-to-noise ratio is greater than the peak signal-to-noise ratio, then the current rotation angle recognition model optimization is complete. Otherwise, the current learning rate is determined to be the optimal solution, and the loss function is optimized and improved based on the fusion bias term δ to obtain the composite loss function Closs; Closs=δ*min(|pred-target|,360-|pred-target|) δ=a*PSNR+(1-a)*SSIM Where 'a' is the fusion weight, 'PSNR' is the peak signal-to-noise ratio, and 'SSIM' is the structural similarity.

[0008] By employing the above technical solution, the peak signal-to-noise ratio (PSNR) and structural similarity (SSIM) of the corrected and modified images are calculated. When the PSNR exceeds a preset threshold, the two are weighted and fused into a bias term. Based on this, the learning rate is dynamically optimized to generate an angle correction weight matrix, thereby identifying and correcting the rotation angle of the original image. By iteratively comparing the similarity and SNR of the images before and after correction, if the quality is improved after correction, the model optimization is completed; otherwise, a composite loss function is constructed based on the fused bias term to further adjust the model. By utilizing the dual quality assessment of PSNR and SSIM to construct a closed-loop feedback mechanism, and achieving adaptive optimization of the model through dynamic learning rate and composite loss function, the accuracy and robustness of rotation angle recognition are significantly improved.

[0009] The present invention is further configured such that: the specific steps of acquiring the original image, labeling and rotating the corresponding image rotation angle to obtain the corrected image, and constructing the training set include: The image acquisition device is rotated according to a preset random angle control function to obtain several original images at different angles, and the rotation angle of the device is recorded. Interpolate the acquisition timestamp of the original image and the recording timestamp of the device rotation angle to obtain the instantaneous acquisition angle of the device; The instantaneous angles acquired by the device are subjected to coordinate transformation and projection decomposition to extract the yaw angle from the three-dimensional rotation matrix; The original image is edge-compensated according to its resolution to obtain a compensated image; Optical flow matching is performed on adjacent compensated images to calculate the rotation amount and compare it with the yaw angle; If the rotation amount is consistent with the yaw angle, then the current rotation amount is determined to be the image rotation angle, and it is labeled to obtain the corresponding rotation angle label; The original image is rotated according to the image rotation angle to obtain the corrected image; All the corrected images are aggregated and combined with the rotation angle labels to construct a training set.

[0010] By adopting the above technical solution, the rotation of the image acquisition device is controlled and the rotation angle is recorded. The instantaneous angle of the acquisition is calculated by combining the timestamp interpolation, and the three-dimensional yaw angle is extracted through coordinate transformation. Then, the rotation consistency of the original image after edge compensation is verified by optical flow matching. After confirmation, the image rotation angle is labeled and a rotation-corrected image is generated. Finally, a training set with continuous angle labels is constructed. Through the dual verification mechanism of physical device rotation and image optical flow algorithm, the problem of insensitivity to angle error calculation in traditional discrete classification labeling (such as treating 30° and 90° errors equally) is solved, realizing high-precision continuous rotation angle labeling, and significantly improving the robustness and correction accuracy of rotation-sensitive models.

[0011] The present invention is further configured such that: the model architecture includes a feature extraction layer and a regression prediction layer; the feature extraction layer uses a CNN network or a transform network to extract image features of the corrected image; the regression prediction layer is used to predict and identify the image rotation angle; the regression prediction layer includes a flattening transformation block, a fully connected block, and an improved loss function; the improved loss function is... loss=min(|pred-target|,360-|pred-target|); Where pred is the predicted rotation angle and target is the actual rotation angle.

[0012] By adopting the above technical solution, the depth features of the corrected image are extracted by using CNN or Transformer network as the feature extraction layer, and the image rotation angle is directly predicted by the regression prediction layer (including flattening transformation block, fully connected block and improved loss function). The loss function uses absolute error instead of traditional mean square error, which avoids the problem of outlier amplification, is computationally efficient and more robust to angle deviation optimization.

[0013] The present invention is further configured such that: the specific steps of rotating the corrected image according to a random angle, constructing training samples, and iteratively training the initial regression model in combination with the training set to obtain the rotation angle recognition model include: Based on the preset iterative training batches, the feature extraction layer of the initial regression model extracts features from the training set to obtain several batches of image feature values. Based on the preset learning rate and maximum number of training iterations, the regression prediction layer of the initial regression model iteratively trains the feature values ​​of all image batches to obtain the angle recognition weight matrix. The modified images of each iterative training batch are randomly rotated according to a preset angle rotation range to obtain a rotation-enhanced image and generate a corresponding rotation angle label. Training samples are constructed based on the rotation-enhanced image and the rotation angle label; Repeatability detection is performed on the corrected images of each of the iterative training batches based on the training samples; If the training sample is different from the corrected image, it is determined that there is no duplicate image in the current iteration training batch, and the angle recognition weight matrix is ​​optimized through the training sample to obtain the rotation angle recognition model.

[0014] By adopting the above technical solution, the training set image features are extracted through CNN or Transformer. The regression layer combines the learning rate and the maximum number of training iterations to generate a weight matrix. Based on a preset angle range, the modified image is randomly rotated to generate enhanced samples and labels. After ensuring sample diversity through repetition detection, the weight matrix is ​​optimized. By integrating random rotation enhancement and repetition detection mechanisms, the generalization ability and robustness of the model to angle changes are significantly improved.

[0015] The present invention is further configured such that the specific steps of identifying and judging the original image through the rotation angle recognition model and outputting the image rotation angle include: All original images are aligned and transformed according to the preset image size to obtain several identical images; Edge reflection filling is performed on all the aforementioned isomorphic images to obtain several edge-filled images; Filter and denoise all the edge-filled images to obtain several noise-free edge images; Based on the feature extraction layer of the rotation angle recognition model, feature extraction is performed on the noiseless edge image to obtain the image center point, the original image vector, and the original edge contour. The optimized angle recognition weight matrix is ​​analyzed to obtain the reference center point, reference vector and edge reference contour; Based on the image center point, a matching operation is performed on all the reference center points to obtain the target reference point; Based on the target reference point, the difference operation is performed between the original vector of the image and the corresponding reference vector to obtain the vector angle difference; Based on the target reference point, optical flow registration calculation is performed on the original edge contour and the corresponding edge reference contour to obtain the contour fitting angle difference; If the vector angle difference is the same as the contour fitting angle difference, then the image rotation angle is output according to the preset angle conversion function; Otherwise, calculate the absolute difference between the vector angle difference and the contour fitting angle difference; If the absolute difference is a flat angle value, then the image rotation angle is output according to the angle conversion function.

[0016] By employing the above technical solution, after preprocessing the image through edge reflection filling and filtering denoising, the model extracts the image center point, original vector, and edge contour features, and performs target reference point matching by combining the pre-trained reference weight matrix. Subsequently, the angle difference between the original image vector and the reference vector is calculated, and the contour fitting angle difference is obtained by comparing the original contour and the reference contour through optical flow registration. When the two are consistent, the rotation angle is directly output. If there is a deviation, the absolute difference is checked to see if it is a flat angle (180°) for error tolerance. Finally, the result is output through the angle transformation function. By integrating multi-feature cross-validation (vector + contour) and the flat angle error tolerance mechanism, the robustness and anti-interference ability of angle recognition are significantly improved.

[0017] Secondly, the present invention also provides an image rotation angle recognition and correction system, which adopts the following technical solution: An image rotation angle recognition and correction system includes: The acquisition and processing module is used to acquire the original image, rotate the image by the corresponding rotation angle to obtain the corrected image, and construct the training set; The model building module is used to select the corresponding neural network and combine it with a preset improved loss function to build an initial regression model; The model training module is used to construct training samples by rotating the corrected image at random angles, and to iteratively train the initial regression model in combination with the training set to obtain the rotation angle recognition model. The rotation prediction module is used to identify and judge the original image through the rotation angle recognition model and output the image rotation angle. The image correction module is used to rotate the original image according to the image rotation angle to obtain a corrected image.

[0018] By employing the above technical solution, a training set is constructed by acquiring and rotating the original image. An initial model is built using a neural network combined with an improved loss function. A rotation angle recognition model is then trained using randomly rotated augmented data. Finally, efficient rotation angle prediction and correction are achieved through Canny edge detection and a grouped angle histogram voting algorithm. By automating image orientation correction and utilizing edge feature grouping and angle histogram voting mechanisms, computational efficiency and anti-interference capabilities are significantly improved, while low-contrast feature interference is reduced, ensuring high robustness.

[0019] Thirdly, the present invention also provides an electronic device, which adopts the following technical solution: An electronic device, comprising: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method described above.

[0020] By adopting the above technical solution, the above image rotation angle recognition and correction method is presented in the form of computer-readable code and stored in the memory. When the processor runs the computer-readable code in the memory, the steps of the above image rotation angle recognition and correction method are executed to achieve the effect of reducing the intensity of manual labor and improving the degree of automation.

[0021] Fourthly, the present invention also provides a computer storage medium, which adopts the following technical solution: A computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above.

[0022] In summary, the beneficial technical effects of the present invention are as follows: 1. By introducing random rotation enhancement and improving the loss function, the generalization ability and stability of the model under different rotation scenarios are significantly improved.

[0023] 2. By constructing a closed-loop feedback mechanism using dual quality assessments of PSNR and SSIM, and achieving adaptive optimization of the model through dynamic learning rate and composite loss function, the accuracy and robustness of rotation angle recognition are significantly improved.

[0024] 3. By integrating random rotation enhancement and repetition detection mechanisms, the model's generalization ability and robustness to angle changes are significantly improved. Attached Figure Description

[0025] Figure 1 This is a flowchart of an image rotation angle recognition and correction method according to one embodiment of the present invention.

[0026] Figure 2 This is a flowchart of an image rotation angle recognition and correction method according to one embodiment of the present invention.

[0027] Figure 3 This is a flowchart of an image rotation angle recognition and correction method according to one embodiment of the present invention.

[0028] Figure 4 This is a structural diagram of an image rotation angle recognition and correction system according to one embodiment of the present invention. Detailed Implementation

[0029] The present invention will be further described in detail below with reference to the accompanying drawings.

[0030] Reference Figure 1 The present invention discloses an image rotation angle recognition and correction method, comprising: S1: Acquire the original image, label and rotate the corresponding image rotation angle to obtain the corrected image, and construct the training set; S2: Select the corresponding neural network based on the model architecture, and construct the initial regression model by combining it with the preset improved loss function; S3: Rotate the corrected image at a random angle, construct training samples, and iteratively train the initial regression model using the training set to obtain the rotation angle recognition model; S4: Identify and judge the original image through the rotation angle recognition model, and output the image rotation angle; S5: Rotate the original image according to the image rotation angle to obtain the corrected image; In this embodiment, 1. Images with rotation angles are acquired, labeled, and rotated according to the labeling results to obtain images with a rotation angle of 0 as the training set; 2. Construct a regression model. The model structure includes a feature extraction module and a regression module. The feature extraction module is used to extract image features. It can use a CNN-based model or a transform model, such as ResNet or VIT. The regression model is used to predict angles. A fully connected layer is added after the flattened features. The number of nodes in the fully connected layer is 1. The loss function is the improved L1 loss. 3. Train the model with the training set obtained in step 1 until the model converges. During the training process, samples are dynamically constructed. For a batch of original training images, an angle theta is randomly selected for each image in the range of 0 to 359. The image is rotated by theta angle, and the label of the image is theta. By dynamically constructing training samples, it is ensured that the training images in each batch are not repeated, thereby speeding up the convergence speed of the model. 4. For the image to be recognized, calculate the model output p based on the trained model. The range of p is (-inf, inf). Then the actual rotation angle theta = p%360, and the range of theta is [0, 359].

[0031] 5. Rotate the image by -theta degrees to obtain the corrected image.

[0032] Reference Figure 2 The corrected image and the modified image are matched, and the structural similarity and peak signal-to-noise ratio are calculated. If the peak signal-to-noise ratio is greater than a preset signal-to-noise threshold, it indicates that the corrected image and the modified image are aligned successfully. The structural similarity and the peak signal-to-noise ratio are then weighted to obtain the fusion deviation term. The learning rate is optimized based on the fusion bias term to obtain a dynamic learning function; The angle correction weight matrix is ​​obtained by iteratively training the training set according to the dynamic learning function. The preprocessed original image is identified based on the angle correction weight matrix to obtain the rotation correction angle; The original image is corrected according to the rotation correction angle, and matched with the corrected image to calculate the correction similarity and correction signal-to-noise ratio, which are then compared with the structural similarity and the peak signal-to-noise ratio. If the corrected similarity is greater than the structural similarity and the corrected signal-to-noise ratio is greater than the peak signal-to-noise ratio, then the current rotation angle recognition model optimization is complete. Otherwise, the current learning rate is determined to be the optimal solution, and the loss function is optimized and improved based on the fusion bias term δ to obtain the composite loss function Closs; Closs=δ*min(|pred-target|,360-|pred-target|) δ=a*PSNR+(1-a)*SSIM Where 'a' is the fusion weight, 'PSNR' is the peak signal-to-noise ratio, and 'SSIM' is the structural similarity.

[0033] The implementation principle of this embodiment is as follows: First, the original image is acquired and the rotation angle is labeled. A training set is constructed by generating a corrected image with the angle returned to zero through reverse rotation. A regression model is designed based on a CNN or Transformer architecture, and its output layer uses an improved L1 loss to constrain angle prediction. During training, samples are dynamically constructed: each batch of images is randomly rotated by θ∈[0,359) degrees and labeled accordingly to improve data diversity. After the model converges, the rotation angle p is predicted for the original image, and the actual angle θ∈[0,359] is obtained through model operation and then corrected by reverse rotation. The key improvement lies in closed-loop optimization: the PSNR and SSIM of the corrected and modified images are calculated and weighted to form a bias term δ; if the PSNR exceeds the threshold, the learning rate is dynamically adjusted using δ (η_new=η·e^(-kδ), where k is the static coefficient, η_new is the dynamic learning rate, and η is the original learning rate) for multiple rounds of fine-tuning to generate an angle correction weight matrix; if the PSNR and SSIM of the corrected image after fine-tuning both exceed the initial results, the model optimization is complete; otherwise, δ is injected into the loss function to form a composite loss L'=L1+γ·δ, where γ is the composite coefficient, and the model is retrained until it simultaneously optimizes the angle error and visual alignment effect, ultimately achieving high-precision rotation correction.

[0034] Example 2: The specific steps of step S1 include: The image acquisition device is rotated according to a preset random angle control function to obtain several original images at different angles, and the rotation angle of the device is recorded. Interpolate the acquisition timestamp of the original image and the recording timestamp of the device rotation angle to obtain the instantaneous acquisition angle of the device; The instantaneous angles acquired by the device are subjected to coordinate transformation and projection decomposition to extract the yaw angle from the three-dimensional rotation matrix; The original image is edge-compensated according to its resolution to obtain a compensated image; Optical flow matching is performed on adjacent compensated images to calculate the rotation amount and compare it with the yaw angle; If the rotation amount is consistent with the yaw angle, then the current rotation amount is determined to be the image rotation angle, and it is labeled to obtain the corresponding rotation angle label; The original image is rotated according to the image rotation angle to obtain the corrected image; All the corrected images are aggregated and combined with the rotation angle labels to construct a training set.

[0035] The implementation principle of this embodiment is as follows: The image acquisition device is rotated using a preset random angle control function to acquire original images from multiple angles. The device rotation angle and IMU data are recorded synchronously. A high-precision instantaneous angle is obtained by fusion with timestamps and interpolation using Kalman filtering. The instantaneous angle is then decomposed into a three-dimensional rotation matrix to extract the yaw angle of the projection plane. An adaptive edge compensation is used to generate a compensated image. Rotation consistency is verified through dual-modal matching of optical flow and SIFT features. Images that pass the verification are rotated in reverse to generate corrected images and labels. Noise and affine perturbations are injected during training set construction to enhance generalization. Finally, a high-quality dataset for the rotation correction model is formed, achieving dual closed-loop verification of physical angle and visual alignment.

[0036] Example 3: The model architecture includes a feature extraction layer and a regression prediction layer; the feature extraction layer uses a CNN network or a transform network to extract image features of the corrected image; the regression prediction layer is used to predict and identify the image rotation angle; the regression prediction layer includes a flattening transformation block, a fully connected block, and an improved loss function; the improved loss function is loss = min(|pred-target|, 360 - |pred-target|); Where pred is the predicted rotation angle and target is the actual rotation angle.

[0037] The implementation principle of this embodiment is as follows: local and global features are fused through a dual-branch feature extraction layer (EfficientNet+ViT), and rotation invariance is enhanced through rotation-equivariant convolution; the regression prediction layer uses spatial pyramid pooling to retain multi-scale information, and coordinates classification and regression tasks through an angle decomposition module; the periodic consistency loss function is used to optimize the training process, and the rotation angle range is gradually improved by combining a course learning strategy; adversarial example enhancement improves the robustness of the model, and finally the model performance is verified by the periodic mean absolute error, achieving high-precision and interference-resistant image rotation angle recognition, providing reliable input for subsequent geometric correction.

[0038] Example 4: The specific steps of step S3 include: Based on the preset iterative training batches, the feature extraction layer of the initial regression model extracts features from the training set to obtain several batches of image feature values. Based on the preset learning rate and maximum number of training iterations, the regression prediction layer of the initial regression model iteratively trains the feature values ​​of all image batches to obtain the angle recognition weight matrix. The modified images of each iterative training batch are randomly rotated according to a preset angle rotation range to obtain a rotation-enhanced image and generate a corresponding rotation angle label. Training samples are constructed based on the rotation-enhanced image and the rotation angle label; Repeatability detection is performed on the corrected images of each of the iterative training batches based on the training samples; If the training sample is different from the corrected image, it is determined that there is no duplicate image in the current iteration training batch, and the angle recognition weight matrix is ​​optimized through the training sample to obtain the rotation angle recognition model.

[0039] The implementation principle of this embodiment is as follows: local and global features of the rotated image are extracted through a dual-branch CNN-Transformer fusion network, and training samples with cyclic constraints are generated by combining periodic consistency data enhancement; duplicate samples are filtered using feature space cosine similarity, and the weight matrix of the regression prediction layer is dynamically optimized through L2 regularized gradient descent; in the iterative training, a periodic loss function min(∣Δθ∣,360-∣Δθ∣)+λ(1-cosΔθ) is introduced to constrain the continuity of angle prediction, and finally, a rotation angle recognition model is output based on the periodic mean absolute error early stopping mechanism to achieve high-precision and interference-resistant image geometric correction.

[0040] Example 5: Reference Figure 3 The specific steps of step S4 include: All original images are aligned and transformed according to the preset image size to obtain several identical images; Edge reflection filling is performed on all the aforementioned isomorphic images to obtain several edge-filled images; Filter and denoise all the edge-filled images to obtain several noise-free edge images; Based on the feature extraction layer of the rotation angle recognition model, feature extraction is performed on the noiseless edge image to obtain the image center point, the original image vector, and the original edge contour. The optimized angle recognition weight matrix is ​​analyzed to obtain the reference center point, reference vector and edge reference contour; Based on the image center point, a matching operation is performed on all the reference center points to obtain the target reference point; Based on the target reference point, the difference operation is performed between the original vector of the image and the corresponding reference vector to obtain the vector angle difference; Based on the target reference point, optical flow registration calculation is performed on the original edge contour and the corresponding edge reference contour to obtain the contour fitting angle difference; If the vector angle difference is the same as the contour fitting angle difference, then the image rotation angle is output according to the preset angle conversion function; Otherwise, calculate the absolute difference between the vector angle difference and the contour fitting angle difference; If the absolute difference is a flat angle value, then the image rotation angle is output according to the angle conversion function.

[0041] The implementation principle of this embodiment is as follows: a noiseless image that retains key structures is generated through an adaptive edge filling strategy; the image center point, original vector, and contour are obtained using a multi-scale feature extraction layer of a rotation angle recognition model; the weight matrix of the reference center point, vector, and contour is dynamically optimized using a momentum update mechanism; the target reference point is located through nearest neighbor matching, and the vector angle difference and contour optical flow registration angle difference are calculated; a periodic consistency verification module is introduced to perform cyclic normalization processing on the two types of angle differences; when the two are consistent, the rotation angle is directly output; if there is a difference, the cyclic absolute difference is calculated, and the 180° rotation ambiguity is eliminated by combining the semantic feature verification module; finally, a highly robust image geometric correction is achieved through an angle conversion function, which is suitable for scenarios such as medical image alignment and satellite image attitude estimation.

[0042] Example 6: Reference Figure 4 An image rotation angle recognition and correction system, comprising: The acquisition and processing module is used to acquire the original image, rotate the image by the corresponding rotation angle to obtain the corrected image, and construct the training set; The model building module is used to select the corresponding neural network and combine it with a preset improved loss function to build an initial regression model; The model training module is used to construct training samples by rotating the corrected image at random angles, and to iteratively train the initial regression model in combination with the training set to obtain the rotation angle recognition model. The rotation prediction module is used to identify and judge the original image through the rotation angle recognition model and output the image rotation angle. The image correction module is used to rotate the original image according to the image rotation angle to obtain a corrected image.

[0043] The implementation principle of this embodiment is as follows: a real rotation angle label is generated for the original image through an independent annotation module to construct an uncontaminated training set. An improved cycle consistency loss function is used in combination with incremental adversarial perturbation samples to train the initial regression model. In the rotation prediction stage, a multi-scale feature fusion mechanism is introduced to extract the geometric features of the image, and a semantic discriminator is used to eliminate 180° rotation ambiguity. Finally, the correction parameters are output based on the dynamically optimized rotation angle recognition model to achieve high-precision image geometric correction in scenarios such as medical imaging and satellite remote sensing.

[0044] Example 7: An electronic device, comprising: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method described above.

[0045] Example 8: A computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above.

[0046] The embodiments described herein are preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape, and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. An image rotation angle recognition correction method, characterized by, The method comprises the following steps: Collecting original images, and labeling and rotating corresponding image rotation angles to obtain corrected images and construct a training set; According to the model architecture, a corresponding neural network is selected, and an initial regression model is constructed by combining a preset improved loss function; According to the random angle, the corrected images are rotated to construct training samples, and the initial regression model is iteratively trained in combination with the training set to obtain a rotation angle recognition model; The original image is identified and judged by the rotation angle recognition model, and an image rotation angle is output; According to the image rotation angle, the original image is rotated to obtain a corrected image.

2. The image rotation angle recognition correction method according to claim 1, characterized in that, The specific steps of collecting original images, labeling and rotating corresponding image rotation angles to obtain corrected images and constructing a training set comprise: According to a preset random angle control function, the image acquisition device is rotated to obtain a plurality of original images at different angles, and the device rotation angle is recorded; The collection time stamp of the original image and the record time stamp of the device rotation angle are interpolated to obtain a device collection instantaneous angle; The device collection instantaneous angle is subjected to coordinate transformation and projection decomposition to extract the yaw angle in the three-dimensional rotation matrix; According to the resolution, the original image is edge compensated to obtain a compensated image; Adjacent compensated images are matched by optical flow to calculate a rotation amount, which is compared with the yaw angle; If the rotation amount is consistent with the yaw angle, the current rotation amount is determined as the image rotation angle, which is labeled to obtain a corresponding rotation angle label; According to the image rotation angle, the original image is rotated to obtain a corrected image; All the corrected images are aggregated to construct a training set in combination with the rotation angle label. 3.The image rotation angle identification correction method of claim 1, wherein: The model architecture comprises a feature extraction layer and a regression prediction layer; the feature extraction layer uses a CNN network or a transform network to extract image features of the corrected image; the regression prediction layer is used for predicting and identifying the image rotation angle; the regression prediction layer comprises a flattening conversion block, a full connection block and an improved loss function; the improved loss function loss is loss = min(|pred-target|, 360-|pred-target|); Wherein, pred is the predicted rotation angle, and target is the actual rotation angle.

4. The image rotation angle recognition correction method of claim 1, wherein, The specific steps of rotating the corrected images according to the random angle, constructing the training samples, and iteratively training the initial regression model in combination with the training set to obtain the rotation angle recognition model comprise: According to a preset iterative training batch, the feature extraction layer of the initial regression model extracts features from the training set to obtain a plurality of image batch feature values; According to a preset learning rate and a maximum training number, the regression prediction layer of the initial regression model iteratively trains all the image batch feature values to obtain an angle recognition weight matrix; According to a preset angle rotation interval, the corrected images of each iterative training batch are randomly rotated to obtain rotation enhanced images, and corresponding rotation angle labels are generated; According to the rotation enhanced images and the rotation angle labels, training samples are constructed; According to the training sample, the modified image of each iteration training batch is repeatedly detected; If the training sample is different from the modified image, it is determined that there is no repeated image in the current iteration training batch, and the angle recognition weight matrix is optimized by the training sample to obtain a rotation angle recognition model.

5. The image rotation angle recognition correction method according to claim 1, characterized by, The specific steps of identifying and judging the original image by the rotation angle recognition model and outputting the image rotation angle include: According to the preset image size, all original images are aligned and converted to obtain a plurality of isomorphic images; All the isomorphic images are edge reflection filled to obtain a plurality of edge filled images; All the edge filled images are filtered and denoised to obtain a plurality of noise-free edge images; According to the feature extraction layer of the rotation angle recognition model, the noise-free edge images are feature extracted to obtain image center points, image original vectors and original edge contours; The optimized angle recognition weight matrix is analyzed to obtain a reference center point, a reference vector and an edge reference contour; According to the image center point, all the reference center points are matched to obtain a target reference point; According to the target reference point, the image original vector and the corresponding reference vector are difference operated to obtain a vector angle difference; According to the target reference point, the original edge contour and the corresponding edge reference contour are optical flow registration calculated to obtain a contour fitting angle difference; If the vector angle difference and the contour fitting angle difference are the same, the image rotation angle is output according to the preset angle conversion function; Otherwise, the absolute difference value of the vector angle difference and the contour fitting angle difference is calculated; If the absolute difference value is a flat angle value, the image rotation angle is output according to the angle conversion function.

6. The image rotation angle recognition correction method of claim 1, wherein, The method further includes: matching the corrected image and the modified image, and calculating the structural similarity and the peak signal-to-noise ratio; If the peak signal-to-noise ratio is greater than the preset signal-to-noise threshold, it indicates that the corrected image and the modified image are aligned and qualified, and the structural similarity and the peak signal-to-noise ratio are weighted calculated to obtain a fusion bias term; According to the fusion bias term, the learning rate is optimized to obtain a dynamic learning function; According to the dynamic learning function, the training set is iteratively trained for several times to obtain an angle correction weight matrix; According to the angle correction weight matrix, the preprocessed original image is identified to obtain a rotation correction angle; According to the rotation correction angle, the original image is corrected and matched with the modified image, the modified similarity and the modified signal-to-noise ratio are calculated, and compared with the structural similarity and the peak signal-to-noise ratio; If the modified similarity is greater than the structural similarity, and the modified signal-to-noise ratio is greater than the peak signal-to-noise ratio, the current rotation angle recognition model optimization is completed; Otherwise, it is determined that the current learning rate is the optimal solution, and the fusion bias term δ is used to optimize and improve the loss function to obtain a composite loss function Clloss; Closs = δ * min (|pred-target|, 360-|pred-target|) δ = a * PSNR + (1-a) * SSIM Wherein, a is a fusion weight, PSNR is a peak signal to noise ratio, and SSIM is a structural similarity.

7. An image rotation angle recognition and correction system, characterized in that, The method comprises the steps of: The acquisition processing module is configured to acquire an original image, rotate the original image by a corresponding image rotation angle, obtain a corrected image, and construct a training set. The model construction module is configured to select a corresponding neural network and a preset improved loss function to construct an initial regression model. The model training module is configured to rotate the corrected image by a random angle, construct a training sample, and iteratively train the initial regression model in combination with the training set to obtain a rotation angle recognition model. The rotation prediction module is configured to identify and judge the original image by using the rotation angle recognition model and output an image rotation angle. The image correction module is configured to rotate the original image by the image rotation angle to obtain a corrected image.

8. An electronic device, comprising: The method comprises the steps of: One or more processors; Memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1-6.

9. A computer storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to implement the method of any one of claims 1-6.

Citation Information

Patent Citations

  • Angle-based target detection training method and device and target detection method and device

    CN110348460A

Cited By

  • Recognition training system for rotary verification code

    CN122116377A