An image correction method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202310692832.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-12
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2043-06-12
AI Technical Summary
这种方式会因为图像的不完整或图像背景较为复杂,造成校正的准确率较低
[0007]在上述的实现过程中,基于待校正图像中的图像关键点进行图像分块,改善直接对图像块进行分块的情况下,图像块经过透视变换后,不同图像块交界处的产生错位的现象,提高了图像校正的效果。
Smart Images

Figure CN117011512B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more specifically, to an image correction method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, commonly used image distortion correction methods are based on the principle of perspective transformation. They obtain four anchor points with a known fixed positional relationship through methods such as line detection, and then calculate the distortion matrix by determining the mapping relationship between the detected four points and the four anchor points in the fixed positional relationship, thus correcting the distorted image to a normal, distortion-free image. This method suffers from low accuracy due to image incompleteness or complex backgrounds. Another image distortion correction method involves dividing the image into blocks before correction. This method can lead to pixel inconsistencies at the boundaries, resulting in lower accuracy as well. Summary of the Invention
[0003] The purpose of this invention is to provide an image correction method, apparatus, electronic device, and storage medium, which is a block image correction method based on image key point detection to improve the accuracy of image correction.
[0004] In a first aspect, embodiments of this application provide an image correction method, comprising: performing keypoint detection on an image to be corrected to obtain image keypoints; grouping the image keypoints according to their spatial locations to obtain keypoint groups; performing image transformation on each keypoint group to obtain corrected image blocks corresponding to each keypoint group; and stitching the corrected image blocks together to obtain a target corrected image.
[0005] In the above implementation process, keypoint detection is performed on the image to be corrected, the detected keypoints are grouped, and perspective transformation is performed on the image block to be corrected corresponding to each keypoint group to obtain the corrected image. Image segmentation and correction based on keypoints ensures that each pixel in the image has a unique coordinate point after perspective transformation. This improves upon existing technologies where points at the boundaries of image segments are mapped to different pixels, causing pixel misalignment and thus enhancing the accuracy of image correction.
[0006] Optionally, in this embodiment of the application, the key points of the image are grouped according to their spatial location to obtain key point groups, including: dividing four adjacent key points of the image into a group according to their spatial location to obtain key point groups; wherein, the four key points in each key point group form a quadrilateral, and the four key points are the four vertices of the quadrilateral.
[0007] In the above implementation process, image blocks are formed based on key points in the image to be corrected. This improves the misalignment phenomenon at the boundaries of different image blocks after perspective transformation when the image blocks are directly divided, thus enhancing the image correction effect.
[0008] Optionally, in this embodiment of the application, after stitching together the correction image blocks to obtain the target correction image, the method further includes: obtaining the transformation matrix parameters of the correction image blocks; and performing an inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters, so as to correct the pixels and obtain the corrected correction image.
[0009] In the above implementation process, the inverse mapping of the transformation matrix is used to perform inverse transformation mapping on the pixels in the target correction image, correct the pixel values in the target correction image, eliminate the influence of uneven image changes, and improve the accuracy of image correction.
[0010] Optionally, in this embodiment of the application, the pixels in the target correction image are subjected to inverse transformation mapping according to the transformation matrix parameters to correct the pixels and obtain the corrected correction image. This includes: performing inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters to obtain the coordinates of the corrected pixels; correcting the coordinates of the corrected pixels based on the weights of the corrected pixel coordinates to obtain the final coordinates; the final coordinates are the coordinates in the image to be corrected; and obtaining the corrected correction image based on the final coordinates.
[0011] In the above implementation process, all pixels on the target image to be corrected are sequentially mapped back to the original image to be corrected using multiple transformation matrices, generating a set of mapped points for each pixel. The mapped point sets are then processed to reconstruct the corrected image, resulting in a more accurate and effective image correction.
[0012] Optionally, in this embodiment of the application, the correction of the correction pixel coordinates based on the weights of the correction pixel coordinates to obtain the final coordinates includes: obtaining the center coordinates of the correction image block; obtaining the weights of the correction pixel coordinates based on the center coordinates of the correction image block; and correcting the correction pixel coordinates according to the weights of the correction pixel coordinates to obtain the final coordinates.
[0013] In the above implementation process, all pixels on the target image to be corrected are mapped back to the original image to be corrected according to multiple transformation matrices. The set of mapped pixels is weighted and summed according to spatial distance to obtain the corrected image, thereby improving the accuracy of image correction.
[0014] Optionally, in this embodiment of the application, obtaining the corrected image based on the final coordinates includes: determining the pixel value corresponding to the final coordinates in the image to be corrected; assigning the pixel value to the pixel point corresponding to the coordinates of the corrected pixel point in the target corrected image, thereby obtaining the corrected image.
[0015] In the above implementation process, the pixel values of the pixels in the target correction image are corrected to obtain the corrected image, thereby eliminating the influence of uneven image changes and improving the accuracy of image correction.
[0016] Optionally, in this embodiment of the application, key point detection of the image to be corrected to obtain image key points includes: adding a border to the image to be corrected to obtain a border image to be corrected; and using a key point network to detect key points in the border image to be corrected to obtain image key points.
[0017] In the above implementation process, a key point detection network is used to detect key points in the image to be corrected, so that subsequent image correction is based on key points. This improves the situation in the prior art where points at the boundaries of the image blocks are mapped to different pixels, causing pixel misalignment, and improves the accuracy of image correction.
[0018] Secondly, embodiments of this application also provide an image correction device, comprising: a key point module for detecting key points in an image to be corrected to obtain image key points; a grouping module for grouping image key points according to their spatial positions to obtain key point groups; a preliminary correction module for performing image transformation on each key point group to obtain corrected image blocks corresponding to each key point group; and a stitching module for stitching the corrected image blocks to obtain a target corrected image.
[0019] Thirdly, embodiments of this application also provide an electronic device, including: a processor and a memory, the memory storing machine-readable instructions executable by the processor, which, when executed by the processor, perform the method described above.
[0020] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the methods described above.
[0021] The image correction method, apparatus, electronic device, and storage medium provided in this application perform key point detection on the image to be corrected, group the detected key points, and perform perspective transformation on the image block corresponding to each key point group to obtain the corrected image. By segmenting and correcting the image based on key points, each pixel in the image has a unique coordinate point after perspective transformation. This improves the accuracy of image correction by addressing the issue in existing technologies where points at the boundaries of image segments are mapped to different pixels, causing pixel misalignment. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 A schematic flowchart of an image correction method provided in an embodiment of this application;
[0024] Figure 2 This is a schematic diagram illustrating the process of obtaining the corrected image according to an embodiment of this application.
[0025] Figure 3 This is a schematic diagram of the image correction device provided in the embodiments of this application;
[0026] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0027] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this application.
[0029] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0030] Existing image correction methods involve finding reference points in the image so that each selected reference point in the image to be corrected corresponds one-to-one with a reference point in the undistorted image. A mapping relationship is fitted between these reference points, and the distorted image is corrected using the obtained mapping function. Existing correction methods include: The first method uses affine transformations and perspective transformations to correct the image. The second method utilizes deep learning methods, employing networks commonly used in semantic segmentation to model the problem as a regression problem and training the model with a large amount of data.
[0031] The first correction method described above, affine transformation, requires finding three reference points on the distorted image, while perspective transformation requires four. It also necessitates knowing the corresponding positions of these points on the undistorted image. By calculating the parameters of the transformation matrix, the mapping relationship from the distorted image to the corrected image is obtained. A common method for obtaining reference points is to use corner detection to find four points in the document image. This method directly obtains the corrected image from the entire distorted image through perspective transformation. However, in practice, some areas of the image do not meet the requirements of perspective transformation, such as areas where the image is curved or unevenly varied. Therefore, image correction results are relatively poor when using affine or perspective transformations by finding reference points on the image.
[0032] The second correction method mentioned above uses deep learning. This typically involves using semantic segmentation models to model deformed document images, transforming a pixel-level problem into a pixel-level regression problem. However, this approach requires a large amount of data for model training, and training data for different scenarios is difficult to obtain, resulting in significant training time. Therefore, insufficient training data may lead to inaccurate corrections in different scenarios.
[0033] Existing image correction methods sometimes involve dividing the image into blocks, performing perspective transformation on each local region, and then stitching the transformed images together. However, because the transformation matrices for each local region are different, the pixels at the boundaries between the image blocks become inconsistent, resulting in some pixels being misaligned. This leads to uneven changes in image features such as color and texture at the boundaries of the image blocks, resulting in low correction accuracy or even correction failure.
[0034] The image correction method provided in this application involves detecting key points in the image to be corrected, grouping the key points in the image into multiple key point groups, and performing perspective transformation on the image block to be corrected corresponding to each key point group to obtain the corrected image. Since each key point has a corresponding coordinate point in the image to be corrected, this method improves upon the prior art where points at the boundaries of blocks are mapped to different pixels, thereby improving the accuracy of image correction.
[0035] Please see Figure 1 The illustrated diagram shows a flowchart of an image correction method provided in an embodiment of this application. The image correction method provided in this application can be applied to an electronic device, which may include a terminal and a server; specifically, the terminal may be a smartphone, tablet computer, computer, personal digital assistant (PDA), etc.; the server may be an application server or a web server. The image correction method may include:
[0036] Step S110: Perform key point detection on the image to be corrected to obtain image key points.
[0037] Step S120: Group the key points of the image according to their spatial location to obtain key point groups.
[0038] Step S130: Perform image transformation on each key point group to obtain the corrected image block corresponding to each key point group.
[0039] Step S140: Stitch together the corrected image blocks to obtain the target corrected image.
[0040] In step S110, the image to be corrected can be an image captured by an image acquisition device or an image obtained directly from a database that requires image correction. Keypoint detection is performed on the image to be corrected to obtain multiple image keypoints. Keypoint detection can be implemented using a network model algorithm; there can be multiple image keypoints distributed throughout the entire image.
[0041] In step S120, the spatial location of the image keypoints can be either the positional relationship between image keypoints or the distance between them. Specifically, for example, based on the positional relationship, multiple adjacent image keypoints can be grouped together as a keypoint group; alternatively, they can be grouped based on the distance between them, for instance, multiple image keypoints whose distance is within a threshold can be grouped together as a keypoint group. It should be noted that one image keypoint corresponds to one keypoint group, and one keypoint group contains multiple image keypoints.
[0042] In step S130, each keypoint group can form a polygon. For example, if a keypoint group has four image keypoints, these four keypoints can form a quadrilateral, with each keypoint representing one of the quadrilateral's four vertices. The polygon formed by the keypoint group corresponds to a patch of the image to be corrected. Based on the image keypoints in the keypoint group, image transformation is performed on the patch of the image to be corrected corresponding to each keypoint group to obtain the corrected image patch for each keypoint group. The image transformation can include affine transformations or perspective transformations, etc.
[0043] In step S140, the correction image blocks corresponding to the key point groups are stitched together according to their spatial positions in the image to be corrected, to obtain the target correction image. The target correction image is the image obtained after image correction of the image to be corrected. It can be understood that, in addition to quadrilaterals, other polygons can also be used.
[0044] In the above implementation process, keypoint detection is performed on the image to be corrected, the detected keypoints are grouped, and perspective transformation is performed on the image block to be corrected corresponding to each keypoint group to obtain the corrected image. Image segmentation and correction based on keypoints ensures that each pixel in the image has a unique coordinate point after perspective transformation. This improves upon existing technologies where points at the boundaries of image segments are mapped to different pixels, causing pixel misalignment and thus enhancing the accuracy of image correction.
[0045] Optionally, in this embodiment of the application, the key points of the image are grouped according to their spatial location to obtain key point groups, including: dividing four adjacent key points of the image into a group according to their spatial location to obtain key point groups; wherein, the four key points in each key point group form a quadrilateral, and the four key points are the four vertices of the quadrilateral.
[0046] In the specific implementation process: image keypoints are grouped according to their spatial location, with four adjacent image keypoints forming a group, called a keypoint group. The keypoint groups and the corresponding image keypoints are recorded; for example, keypoint grouping can be done using Pgroup. m The four image keypoints in the keypoint group are labeled as P. m1 P m2 P m3 and P m4 Pgroup m ={P m1 ,P m2 ,P m3 ,P m4}. Pgroup mThe four image key points P can divide a quadrilateral S on the image to be corrected, satisfying the following relationship: Image key points P m1 Represents the top-left corner of quadrilateral S; image keypoint P m2 Represents the upper right corner of quadrilateral S; image keypoint P m3 Let P represent the lower left corner of quadrilateral S and the image keypoint P. m4 This represents the lower right corner point of quadrilateral S.
[0047] Even with finer-grained image segmentation, existing technologies still cannot resolve the misalignment between different image blocks. In the implementation of this application, image segmentation is performed based on key image points in the image to be corrected. This improves upon the misalignment that occurs at the boundaries of different image blocks after perspective transformation when image blocks are directly segmented, thus enhancing the image correction effect.
[0048] Optionally, in this embodiment of the application, after stitching together the correction image blocks to obtain the target correction image, the method further includes: obtaining the transformation matrix parameters of the correction image blocks; and performing an inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters, so as to correct the pixels and obtain the corrected correction image.
[0049] In the specific implementation process: when performing image transformation on the image blocks to be corrected corresponding to each keypoint group, the parameters of the transformation matrix corresponding to each corrected image block can be recorded. Taking perspective transformation as an example, the essence of perspective transformation is to project the image onto a new view plane, that is, to map the points on the image to be corrected to the points on the target corrected image. The transformation matrix parameters of the corrected image block can specifically include image linear transformation parameters, image perspective transformation parameters, and image translation parameters.
[0050] Based on the transformation matrix parameters, the inverse transformation matrix parameters of the perspective transformation can be obtained. Using these parameters, the pixels in the target image are inversely transformed and mapped to their corresponding pixels in the image to be corrected. In other words, the pixels in the target image correspond to the pixels in the image to be corrected. The pixel values of the pixels in the target image are then corrected based on the pixels in the image to be corrected, resulting in the corrected image.
[0051] In the above implementation process, the inverse mapping of the transformation matrix is used to perform inverse transformation mapping on the pixels in the target correction image, correct the pixel values in the target correction image, eliminate the influence of uneven image changes, and improve the accuracy of image correction.
[0052] Optionally, in this embodiment of the application, the pixels in the target correction image are subjected to inverse transformation mapping according to the transformation matrix parameters to correct the pixels and obtain the corrected correction image. This includes: performing inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters to obtain the coordinates of the corrected pixels; correcting the coordinates of the corrected pixels based on the weights of the corrected pixel coordinates to obtain the final coordinates; the final coordinates are the coordinates in the image to be corrected; and obtaining the corrected correction image based on the final coordinates.
[0053] In the specific implementation process: the correction process specifically involves mapping pixel k in the target correction image I' to m points on the image to be corrected through an inverse transformation, i.e., the coordinates of the corrected pixel points, labeled as I. k1 I k2 I k3 ... I km Correcting pixel coordinates I km The coordinates are obtained through P km =(X km ,Y km () represents a point I on the target-corrected image. k 'S' is the set of coordinates of m points on the image to be corrected k ={P k1 P k2 P k3 ... P km Each corrected image patch in the target corrected image corresponds to a weight, i.e., for S... k Each coordinate in the graph has a corresponding weight.
[0054] The weights can be obtained by measuring the distance between the center coordinates of the corrected image patch and the pixel coordinates in the target corrected image. Based on the weights of the corrected pixel coordinates, the pixel coordinates are corrected, the final coordinates are determined in the image to be corrected, and the pixel values of the final coordinate points in the image to be corrected are assigned to the corrected pixel coordinates to obtain the corrected image.
[0055] In the above implementation process, all pixels on the target image to be corrected are sequentially mapped back to the original image to be corrected using multiple transformation matrices, generating a set of mapped points for each pixel. The mapped point sets are then processed to reconstruct the corrected image, resulting in a more accurate and effective image correction.
[0056] Optionally, in this embodiment of the application, the correction of the correction pixel coordinates based on the weights of the correction pixel coordinates to obtain the final coordinates includes: obtaining the center coordinates of the correction image block; obtaining the weights of the correction pixel coordinates based on the center coordinates of the correction image block; and correcting the correction pixel coordinates according to the weights of the correction pixel coordinates to obtain the final coordinates.
[0057] In the specific implementation process, the calculation of the weights for correcting pixel coordinates is as follows: based on the Pgroup in the corrected image patch... m The four corner points P' m1 P m2 P m3 and P m4 Calculate the geometric center coordinates C of the corrected image patch. m ', Geometric center coordinates C m ' is the average of the coordinates of the four corner points.
[0058] Obtain the pixel I in the target corrected image corresponding to the coordinates of the corrected pixel. k 'The coordinates of the pixel are used to calculate pixel I. k 'and the center coordinates C of the corrected image patch m The distance. For example, the coordinates I of a pixel in the target correction image. k 'and the center coordinates C of the j-th corrected image patch j The distance between two points is the reciprocal of the Euclidean distance, and the specific calculation formula is as follows:
[0059]
[0060] Among them, Dis(I k ',C j ') is for correcting pixel coordinates I k 'and the center coordinates C of the j-th corrected image patch j ' distance; ( k Y k ) represents pixel I in the target correction image. k 'coordinates, ( j Y j ) represents the center coordinates of the j-th corrected image block.
[0061] The pixel I in the target corrected image is obtained using the above formula. k The m distance values to the center coordinates of each corrected image patch are labeled as {( k ',C1'), Dis(I k ',C2'), ...,Dis(I k ',C mNormalizing these m distance values yields m weights, which are the weights for each corrected pixel coordinate. The calculation formula is as follows:
[0062]
[0063] Where Wkj represents the weight of the corrected pixel coordinates. Dis(I k ',C j ') Correcting pixels I in the target image k 'C to the center coordinates of the first corrected image patch j The distance value of '.
[0064] The coordinates of the corrected pixels are adjusted based on their weights. Specifically, the final coordinates on the image to be corrected are obtained by multiplying the corrected pixel coordinates by their corresponding weights and then summing the results. The calculation formula is as follows:
[0065]
[0066] Among them, Out k For the final coordinates, P kj To correct pixel coordinates, W kj The weights for correcting pixel coordinates. m is the number of image patches to be corrected.
[0067] In the above implementation process, all pixels on the target image to be corrected are mapped back to the original image to be corrected according to multiple transformation matrices. The set of mapped pixels is weighted and summed according to spatial distance to obtain the corrected image, thereby improving the accuracy of image correction.
[0068] Optionally, in this embodiment of the application, obtaining the corrected image based on the final coordinates includes: determining the pixel value corresponding to the final coordinates in the image to be corrected; assigning the pixel value to the pixel point corresponding to the coordinates of the corrected pixel point in the target corrected image, thereby obtaining the corrected image.
[0069] In the specific implementation process: the final coordinates are the coordinates in the image to be corrected, and the pixel value I corresponding to the final coordinates in the image to be corrected is determined. k , will pixel value I k Assign the value to the pixel I corresponding to the coordinates of the corrected pixel in the target corrected image. k ', to obtain the corrected image.
[0070] In the above implementation process, the pixel values of the pixels in the target correction image are corrected to obtain the corrected image, thereby eliminating the influence of uneven image changes and improving the accuracy of image correction.
[0071] Optionally, in this embodiment of the application, key point detection of the image to be corrected to obtain image key points includes: adding a border to the image to be corrected to obtain a border image to be corrected; and using a key point network to detect key points in the border image to be corrected to obtain image key points.
[0072] In the specific implementation process: computer vision and machine learning software libraries can be used to add borders to the image to be corrected. For example, OpenCV functions can be used to add borders to the image to be corrected, obtaining the border image to be corrected. A keypoint detection network is then used to detect keypoints in the border image to be corrected, obtaining multiple keypoints at the edges and center of the border image. The keypoint network can be the Move Net keypoint detection network.
[0073] In the above implementation process, a key point detection network is used to detect key points in the image to be corrected, so that subsequent image correction is based on key points. This improves the situation in the prior art where points at the boundaries of the image blocks are mapped to different pixels, causing pixel misalignment, and improves the accuracy of image correction.
[0074] Please see Figure 2 The illustration shows a flowchart of obtaining a corrected image according to an embodiment of this application.
[0075] In an optional embodiment, the image to be corrected is preprocessed by using a MoveNet network to obtain key points, which are then grouped according to their spatial location. The image blocks corresponding to these key point groups are then subjected to perspective transformation for initial correction. Based on the transformation matrix corresponding to each image block, an inverse transformation is performed, taking into account the distance between pixels, to further correct the image and obtain the corrected image, thus completing the image correction process.
[0076] Please see Figure 3 The diagram shown is a structural schematic of an image correction device provided in an embodiment of this application; this application provides an image correction device 200, including:
[0077] Key point module 210 is used to detect key points in the image to be corrected and obtain image key points;
[0078] Grouping module 220 is used to group key points in an image according to their spatial location to obtain key point groups;
[0079] The preliminary correction module 230 is used to perform image transformation on each key point group to obtain the corrected image block corresponding to each key point group.
[0080] The stitching module 240 is used to stitch together the correction image blocks to obtain the target correction image.
[0081] Optionally, in this embodiment of the application, the image correction device, grouping module 220, is specifically used to divide four adjacent image key points into a group according to the spatial position of the image key points to obtain key point groups; wherein, the four image key points in each key point group form a quadrilateral, and the four image key points are the four vertices of the quadrilateral.
[0082] Optionally, in this embodiment of the application, the image correction device further includes a correction module, configured to obtain the transformation matrix parameters of the correction image block; and to perform an inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters, so as to perform correction processing on the pixels and obtain a corrected image.
[0083] Optionally, in this embodiment of the application, the image correction device and the correction module are further configured to perform an inverse transformation mapping on the pixels in the target correction image according to the transformation matrix parameters to obtain the coordinates of the correction pixels; correct the coordinates of the correction pixels based on the weights of the correction pixels to obtain the final coordinates; the final coordinates are the coordinates in the image to be corrected; and obtain the corrected image based on the final coordinates.
[0084] Optionally, in this embodiment of the application, the image correction device and the correction module are further configured to obtain the center coordinates of the corrected image block; obtain the weight of the corrected pixel coordinates based on the center coordinates of the corrected image block; and correct the corrected pixel coordinates according to the weight of the corrected pixel coordinates to obtain the final coordinates.
[0085] Optionally, in this embodiment of the application, the image correction device and the correction module are further configured to determine the pixel value corresponding to the final coordinates in the image to be corrected; assign the pixel value to the pixel point corresponding to the coordinates of the corrected pixel point in the target corrected image, and obtain the corrected image.
[0086] Optionally, in this embodiment of the application, the image correction device, key point module 210, is used to add a border to the image to be corrected to obtain a border image to be corrected; and to perform key point detection on the border image to be corrected through a key point network to obtain the image key points.
[0087] It should be understood that this device corresponds to the image correction method embodiment described above and is capable of performing the various steps involved in the above method embodiment. The specific functions of this device can be found in the description above, and detailed descriptions are omitted here to avoid repetition. The device includes at least one software function module that can be stored in memory or embedded in the device's operating system (OS) in the form of software or firmware.
[0088] Please see Figure 4 The diagram shows a structural schematic of an electronic device provided in an embodiment of this application. An electronic device 300 provided in this application includes a processor 310 and a memory 320. The memory 320 stores machine-readable instructions executable by the processor 310. When the machine-readable instructions are executed by the processor 310, the method described above is performed.
[0089] This application also provides a storage medium storing a computer program, which is executed by a processor to perform the above-described method.
[0090] The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0091] It should be understood that the disclosed apparatus and methods can also be implemented in other ways, given the several embodiments provided in this application. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0092] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0093] The above description is only an optional implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be covered within the protection scope of the embodiments of this application.
Claims
1. An image correction method, characterized in that, include: Key point detection is performed on the image to be corrected to obtain the key points of the image; The key points in the image are grouped according to their spatial locations to obtain key point groups. Image transformation is performed on each of the key point groups to obtain the corrected image blocks corresponding to each key point group; The corrected image blocks are stitched together to obtain the target corrected image; After stitching the corrected image blocks to obtain the target corrected image, the method further includes: Obtain the transformation matrix parameters of the corrected image block; Based on the transformation matrix parameters, the pixels in the target corrected image are inversely transformed and mapped to obtain the coordinates of the corrected pixels; Based on the weights of the corrected pixel coordinates, the corrected pixel coordinates are corrected to obtain the final coordinates; the final coordinates are the coordinates in the image to be corrected; wherein, the calculation steps of the weights of the corrected pixel coordinates are: calculating the distance between the coordinates of the pixel in the target image corresponding to the corrected pixel coordinates and the center coordinates of the corrected image block; the distance value is the reciprocal of the Euclidean distance between the two points, and the weights are obtained after normalizing the distance value; Based on the final coordinates, the corrected image is obtained; Based on the final coordinates, the corrected image is obtained, including: Determine the pixel value corresponding to the final coordinates in the image to be corrected; The pixel value is assigned to the pixel corresponding to the coordinates of the corrected pixel in the target corrected image to obtain the corrected image; Correcting the coordinates of the corrected pixel points includes: The final coordinates on the image to be corrected are obtained by multiplying the corrected pixel coordinates by their corresponding weights and then summing the results; the calculation formula is as follows: in, For the final coordinates, The coordinates of the corrected pixel point, The weights for the coordinates of the corrected pixel points; To correct the number of image patches.
2. The method according to claim 1, characterized in that, The key points in the image are grouped according to their spatial locations to obtain key point groups, including: Based on the spatial position of the image key points, four adjacent image key points are grouped together to obtain key point groups; wherein, the four image key points in each key point group form a quadrilateral, and the four image key points are the four vertices of the quadrilateral.
3. The method according to claim 1, characterized in that, Based on the weights of the corrected pixel coordinates, the corrected pixel coordinates are adjusted to obtain the final coordinates, including: Obtain the center coordinates of the corrected image block; The weights of the coordinates of the corrected pixels are obtained based on the center coordinates of the corrected image block. The coordinates of the corrected pixel are corrected according to the weights of the corrected pixel coordinates to obtain the final coordinates.
4. The method according to any one of claims 1-3, characterized in that, The key point detection of the image to be corrected, to obtain image key points, includes: The image to be corrected is bordered to obtain a border image to be corrected; By using a keypoint network, keypoint detection is performed on the border image to be corrected to obtain the keypoints of the image.
5. An image correction device, characterized in that, include: The key point module is used to detect key points in the image to be corrected and obtain the key points of the image. The grouping module is used to group the key points of the image according to their spatial location to obtain key point groups; The preliminary correction module is used to perform image transformation on each of the key point groups to obtain the corrected image blocks corresponding to each key point group. The stitching module is used to stitch the corrected image blocks together to obtain the target corrected image; A correction module is used to obtain the transformation matrix parameters of the image block to be corrected; according to the transformation matrix parameters, perform an inverse transformation mapping on the pixels in the target image to obtain the coordinates of the corrected pixels; based on the weights of the corrected pixel coordinates, correct the coordinates of the corrected pixels to obtain the final coordinates; the final coordinates are the coordinates in the image to be corrected; wherein, the calculation steps of the weights of the corrected pixel coordinates are: calculating the distance between the coordinates of the pixel in the target image corresponding to the corrected pixel coordinates and the center coordinates of the image block to be corrected; the distance value is the reciprocal of the Euclidean distance between the two points, and the distance value is normalized to obtain the weight; based on the final coordinates, obtain the corrected image; The correction module is further configured to determine the pixel value corresponding to the final coordinates in the image to be corrected; assign the pixel value to the pixel point corresponding to the coordinates of the corrected pixel point in the target corrected image, and obtain the corrected image; It is also used to multiply the coordinates of the corrected pixel point and the corresponding weights of the corrected pixel point, and then sum them to obtain the final coordinates selected on the image to be corrected; the calculation formula is as follows: in, For the final coordinates, The coordinates of the corrected pixel point, The weights for the coordinates of the corrected pixel points; To correct the number of image patches.
6. An electronic device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, which, when executed by the processor, perform the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Driving assistance system, special vehicle and method
CN111098785A
Image processing method and device, electronic equipment and storage medium
CN115761207A
