CN114187206A - Image distortion correction method, device, electronic equipment, chip and storage medium - Google Patents

Image distortion correction method, device, electronic equipment, chip and storage medium Download PDF

Info

Publication number
CN114187206A
CN114187206A CN202111535083.0A CN202111535083A CN114187206A CN 114187206 A CN114187206 A CN 114187206A CN 202111535083 A CN202111535083 A CN 202111535083A CN 114187206 A CN114187206 A CN 114187206A
Authority
CN
China
Prior art keywords
area
corrected
image
grid
region
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111535083.0A
Other languages
Chinese (zh)
Inventor
沈成南
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202111535083.0A priority Critical patent/CN114187206A/en
Publication of CN114187206A publication Critical patent/CN114187206A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/80Geometric correction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/66Analysis of geometric attributes of image moments or centre of gravity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Geometry (AREA)
  • Image Processing (AREA)

Abstract

The application is applicable to the technical field of image processing, and provides an image distortion correction method, an image distortion correction device, electronic equipment, a chip and a storage medium. The method comprises the following steps: if a first body area exists in at least one body area of the image to be processed, carrying out distortion correction on the first body area; if a second body area exists in at least one body area of the image to be processed, calculating the area of the second body area and the area of a first overlapping area; calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region; and if the first area ratio is smaller than or equal to a first threshold value, performing distortion correction on the second body area. The distortion correction can be carried out on the body area with distortion in the image through the application.

Description

Image distortion correction method, device, electronic equipment, chip and storage medium
Technical Field
The present application relates to image processing technologies, and in particular, to an image distortion correction method and apparatus, an electronic device, a chip, and a storage medium.
Background
In recent years, in order to obtain an image with a wide field of view, the field of view of a camera in an electronic device is becoming larger, and an image captured by using a camera with a large field of view generally has a problem of human image distortion. When a human face in an image is distorted, the distorted human face needs to be subjected to distortion correction, so that the human face conforms to the vision of human eyes.
Disclosure of Invention
The embodiment of the application provides an image distortion correction method, an image distortion correction device, electronic equipment, a chip and a storage medium, so as to perform distortion correction on a body region with distortion in an image.
In a first aspect, an embodiment of the present application provides an image distortion correction method, including:
if a first body area exists in at least one body area of the image to be processed, carrying out distortion correction on the first body area; the body area refers to an area which does not contain face data in the portrait area of the image to be processed; the first body area is a body area which is not overlapped with a preset area; the preset area is a local area which takes a central point of the image to be processed as a center in the image to be processed;
if a second body area exists in at least one body area of the image to be processed, calculating the area of the second body area and the area of a first overlapping area; the second body area refers to the body area partially overlapping with the preset area; the first overlapping area refers to an overlapping area of the second body area and the preset area;
calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region;
and if the first area ratio is smaller than or equal to a first threshold value, performing distortion correction on the second body area.
In the embodiment of the application, whether a first body area generating distortion and a second body area possibly generating distortion exist in an image to be processed can be judged by judging whether the body area is overlapped with a preset area, and if the first body area generating distortion exists, distortion correction is carried out on the first body area; if there is a second body area which may generate distortion, calculating the area of the second body area and the area of the overlapping area of the second body area and the preset area (i.e. the area of the first overlapping area), and comparing the ratio of the area of the first overlapping area to the area of the second body area (i.e. the first area ratio) with a first threshold value, whether the second body area generates distortion can be further judged, when the first area ratio is smaller than or equal to the first threshold value, it is determined that the second body area generates distortion, and at this time, distortion correction needs to be performed on the second body area. In the above process, by performing distortion correction on the first body region and the second body region where distortion occurs, distortion correction of the body region in the image to be processed can be achieved.
In a second aspect, an embodiment of the present application provides an image distortion correction apparatus, including:
the first correction module is used for carrying out distortion correction on at least one body area of the image to be processed if the first body area exists in the body area; the body area refers to an area which does not contain face data in the portrait area of the image to be processed; the first body area is a body area which is not overlapped with a preset area; the preset area is a local area which takes a central point of the image to be processed as a center in the image to be processed;
an area calculation module, configured to calculate an area of a second body region and an area of a first overlap region if the second body region exists in at least one of the body regions of the image to be processed; the second body area refers to the body area partially overlapping with the preset area; the first overlapping area refers to an overlapping area of the second body area and the preset area;
the ratio calculation module is used for calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region;
and the second correction module is used for carrying out distortion correction on the second body area if the first area ratio is smaller than or equal to a first threshold value.
In a third aspect, an embodiment of the present application provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the image distortion correction method according to the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a chip, which includes a processor, and the processor is configured to read and execute a computer program stored in a memory to perform the steps of the image distortion correction method according to the first aspect.
Optionally, the memory and the processor are connected by a circuit or a wire.
In a fifth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the image distortion correction method according to the first aspect.
In a sixth aspect, embodiments of the present application provide a computer program product, which, when run on an electronic device, causes the electronic device to perform the steps of the image distortion correction method according to the first aspect.
It is to be understood that the second, third, fourth, fifth and sixth aspects provided above are all used to execute the corresponding methods provided above, and therefore, the beneficial effects achieved by the methods can refer to the beneficial effects in the corresponding methods provided above, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1a is an exemplary diagram of an image to be processed with human image distortion;
FIG. 1b is a diagram illustrating an example of a result of global correction of the image to be processed in FIG. 1 a;
FIG. 1c is a diagram illustrating the result of local face correction of the image to be processed in FIG. 1 a;
FIG. 1d is an exemplary illustration of the results of distortion correction of the body region of FIG. 1 c;
fig. 2 is a schematic flow chart illustrating an implementation of an image distortion correction method according to an embodiment of the present application;
FIG. 3 is an exemplary diagram of a preset area;
FIG. 4 is a schematic diagram of a flowchart of an implementation of a method for correcting image distortion according to another embodiment of the present application;
FIG. 5 is a schematic diagram illustrating an implementation flow of a method for correcting image distortion according to another embodiment of the present application;
FIG. 6 is an exemplary diagram of a body frame;
fig. 7 is a schematic structural diagram of an image distortion correction apparatus according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
The image distortion correction method provided by the embodiment of the application can be applied to electronic devices such as a mobile phone, a tablet personal computer, a wearable device, a vehicle-mounted device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), and the like, and the embodiment of the application does not limit the specific types of the electronic devices at all.
It should be understood that, the sequence numbers of the steps in this embodiment do not mean the execution sequence, and the execution sequence of each process should be determined by the function and the inherent logic of the process, and should not constitute any limitation to the implementation process of the embodiment of the present application.
When a user takes a picture with a camera having a large field angle (e.g., a wide-angle camera, a super-wide-angle camera, etc.), the edge portrait is usually stretched and deformed, resulting in distortion. As shown in fig. 1a, which is an exemplary diagram of an image to be processed with portrait distortion, 101 in fig. 1a indicates a straight line in a background region of the image to be processed, 102, 103, and 104 indicate portrait regions in the image to be processed, the portrait region 102 and the portrait region 104 are distorted, and the portrait region 103 is not distorted. Wherein, the portrait area in the image to be processed can be understood as the foreground of the image to be processed (i.e. the object of interest to the user), then the background area can refer to the area of the image to be processed except the portrait area.
In order to realize distortion correction of a portrait area in an image to be processed, two existing schemes are respectively to perform global correction on the image to be processed and perform face local correction on the image to be processed.
The global correction of the image to be processed is distortion correction of the whole image, and although the scheme can realize distortion correction of the portrait area, straight lines in the background of the image to be processed are easy to bend, and the shape of the portrait area which is not distorted in the image to be processed is changed, so that the image to be processed is distorted. As shown in fig. 1b, which is an exemplary diagram of the result of performing global correction on the image to be processed in fig. 1a, it can be known from fig. 1b that distortion correction of the portrait area 102 and the portrait area 104 in the image to be processed can be achieved by performing global correction on the image to be processed in fig. 1a, but the straight line 101 is bent and the portrait area 103 is distorted.
The local face correction of the image to be processed is to perform distortion correction on a face region with distortion in the image to be processed, and although the scheme can realize the distortion correction on the face region, the head-body proportion is easily inconsistent (for example, the face region is large and the body region is small). Fig. 1c is a diagram illustrating an example of the result of performing face local correction on the image to be processed in fig. 1 a. As can be seen from fig. 1c, by performing face local correction on the image to be processed, distortion correction on the face region in the portrait region 102 and the face region in the portrait region 104 in the image to be processed can be achieved, but there is still distortion in the body regions in the portrait region 102 and the portrait region 104, which results in inconsistent head-to-body ratios of the portrait region 102 and the portrait region 104. The body region is a region of the human image region that does not include face data. For example, the region other than the face region in the portrait region 102 and the portrait region 104 in fig. 1a, 1b, and 1c, and the entire portrait region 103 are body regions.
The method aims to reduce the influence of distortion correction on a background area and improve the problem of inconsistent head-body proportion while realizing the distortion correction of a face area in an image to be processed. The embodiment of the application provides an image distortion correction method, which is characterized in that on the basis of carrying out face local correction on an image to be processed, whether a body area is overlapped with a preset area or not is judged, and when the body area is partially overlapped with the preset area, the body area generating distortion can be screened out from the image to be processed on the basis of the area of the body area in the preset area and the ratio of the body area to the area of the body area, and the distortion correction of the body area in the image to be processed can be realized by carrying out distortion correction on the body area generating distortion. According to the method and the device, on the basis of carrying out face local correction on the image to be processed, distortion correction is carried out on the body area generating distortion, and distortion correction is not carried out on the background area, so that the influence of the distortion correction on the background area can be reduced, and the problem of uncoordinated head-body proportion is improved. An exemplary diagram of the results of distortion correction of the body region of FIG. 1c is shown in FIG. 1 d.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
Fig. 2 is a schematic view of an implementation flow of an image distortion correction method provided in an embodiment of the present application, where the image distortion correction method is applied to an electronic device. As shown in fig. 2, the image distortion correction method may include the steps of:
step 201, if a first body area exists in at least one body area of the image to be processed, performing distortion correction on the first body area.
The image to be processed may be an image stored in the electronic device, or an image sent to the electronic device by another device, or an image acquired by a camera of the electronic device in real time (for example, an image displayed in a preview area in a photographing interface of a mobile phone), which is not limited herein.
The camera of the electronic device may be a front camera or a rear camera of the electronic device, or may be a camera controlled by the electronic device in a wired manner or a wireless manner. The camera can be a wide-angle camera, a super wide-angle camera and other cameras with larger field angles.
After the electronic device obtains the image to be processed, the body area and the face area in the portrait area can be obtained based on whether the portrait area of the image to be processed contains the face data. The face data may refer to position information, size, and the like of facial features such as a nose, eyes, a mouth, eyebrows, ears, and the like.
In an optional embodiment, if a portrait area which does not contain face data exists in the image to be processed, determining that the portrait area is a body area; and if the image to be processed has a portrait area containing the face data, determining a body area in the portrait area based on the position information in the face data.
The position information in the face data may refer to position information of facial features such as a nose, eyes, a mouth, eyebrows, ears and the like in the image to be processed.
Whether a portrait area contains face data or not can be judged, and whether the portrait area contains data of all facial features such as a nose, eyes, a mouth, eyebrows, ears and the like or not can be judged. Of course, the data may also be data for determining whether the portrait area includes partial facial features of the five sense organs, such as nose, eyes, mouth, eyebrows, and ears, which is not limited herein.
For a portrait area containing face data, the electronic device may determine, based on the position information in the face data, a face area in the portrait area, and then an area other than the face area in the portrait area is a body area.
The electronic equipment can obtain all body regions and face regions in the image to be processed by carrying out portrait segmentation and face detection on the image to be processed. For example, all portrait areas can be obtained from the image to be processed by portrait segmentation, and then face detection is performed on each portrait area to detect whether each portrait area contains face data; for a portrait area containing face data, the portrait area may be divided into a face area and a body area based on position information in the face data; for a portrait area that does not contain face data, the entire portrait area may be determined to be a body area.
It should be noted that the present application does not limit the algorithm used for the portrait segmentation and the algorithm used for the face detection. For example, a human image segmentation algorithm based on a convolutional neural network model can be adopted to segment the human image of the image to be processed; face detection can be performed on the image to be processed by adopting a face detection algorithm based on the binary wavelet transform or based on the histogram coarse segmentation and the singular value characteristics.
The first body area may refer to a body area that does not overlap with a preset area.
The preset region may refer to a local region in the image to be processed centered on a central point of the image to be processed. For example, the preset region is the minimum value of the height and the width of the image to be processed with the central point of the image to be processed as the origin
Figure BDA0003412883020000081
Is a circular area of radius. The human image area in the preset area is not easy to generate distortion or the generated distortion is small and can be ignored.
The distortion in the image to be processed is generally generated from the center point of the image to be processed in bilateral symmetry, the closer the area to the center point, the smaller the distortion degree, and the farther the area to the center point, the larger the distortion degree. Therefore, the local area taking the central point of the image to be processed as the center is set as the preset area, and whether the body area in the image to be processed generates distortion or not can be judged more accurately.
In step 202, if a second body region exists in at least one body region of the image to be processed, the area of the second body region and the area of the first overlap region are calculated.
Wherein the second body area may refer to a body area partially overlapping with the preset area; the first overlap region may refer to an overlap region of the second body region and the preset region. The two regions partially overlapping may be understood as the intersection of the two regions.
The electronic device can judge whether the first body area, the second body area and the third body area exist in the image to be processed by judging whether at least one body area in the image to be processed is overlapped with the preset area. Wherein the third body area may refer to a body area located within a preset area.
Fig. 3 is an exemplary diagram of the preset region, and the circular region formed by the broken line in fig. 3 is the preset region. As can be seen from fig. 3, the body area in the portrait area 104 does not overlap with the preset area, and it can be determined that the body area in the portrait area 104 is the first body area; the body area in the portrait area 102 is partially overlapped with the preset area, and the body area in the portrait area 102 can be determined to be a second body area; the portrait area 103 is located in the preset area, and it can be determined that the portrait area 103 is not distorted, and distortion correction is not needed.
It should be noted that, in the image to be processed, the first body area and the second body area may exist at the same time, or only the first body area or the second body area may exist. If there are first body areas in the image to be processed, the number of first body areas may be one, or at least two. If there are second body regions in the image to be processed, the number of second body regions may be one, or at least two.
In order to simplify the area calculation of the second body region and the first overlap region, the number of pixels in the second body region and the number of pixels in the first overlap region may be counted, the number of pixels in the second body region may be taken as the area of the second body region, and the number of pixels in the first overlap region may be taken as the area of the first overlap region. Of course, other methods may be used to calculate the area of the second body region and the first overlapping region, and are not limited herein.
Step 203, calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region.
Taking the portrait area 102 in fig. 3 as an example, if the area of the body area of the portrait area 102 is a, the surface of the overlap area between the body area of the portrait area 102 and the preset areaThe product is B, then the first area ratio corresponding to the portrait area 102 is
Figure BDA0003412883020000091
And step 204, if the first area ratio is smaller than or equal to the first threshold, performing distortion correction on the second body area.
Wherein the first threshold is used to determine whether a distortion correction of the second body region is required. If the first area ratio is less than or equal to the first threshold, it can be determined that the second body area is distorted and distortion correction needs to be performed on the second body area; if the first area ratio is greater than the first threshold, it can be determined that the second body region is not distorted or the distortion is negligible, and no distortion correction is required for the second body region.
For example, the first threshold is set to 0.6 if the first area ratio corresponding to the portrait area 102 in fig. 3 is the same
Figure BDA0003412883020000101
It can be determined that the body region in the portrait area 102 is distorted and needs to be distortion-corrected.
The body area that produces the distortion can be screened out from the image to be processed through judging whether the body area overlaps with the preset area or not and on the basis of the area of the body area in the preset area and the ratio of the area of the body area when the body area partially overlaps with the preset area, and the distortion correction of the body area in the image to be processed can be realized through carrying out the distortion correction on the body area producing the distortion.
Fig. 4 is a schematic view of an implementation flow of an image distortion correction method provided in another embodiment of the present application, where the image distortion correction method is applied to an electronic device. As shown in fig. 4, the image distortion correction method may include the steps of:
step 401, if a first body area exists in at least one body area of the image to be processed, performing distortion correction on the first body area.
The step is the same as step 201, and reference may be made to the related description of step 201, which is not described herein again.
If a second body area exists in at least one body area of the image to be processed, calculating the area of the second body area and the area of the first overlapping area.
The step is the same as step 202, and reference may be made to the related description of step 202, which is not repeated herein.
Step 403, calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region.
The step is the same as step 203, and reference may be made to the related description of step 203, which is not described herein again.
And step 404, if the first area ratio is smaller than or equal to the first threshold, performing distortion correction on the second body area to obtain a corrected body area corresponding to the second body area.
The step is the same as step 204, and reference may be made to the related description of step 204, which is not described herein again.
Step 405, based on the original grid of the image to be processed, determining a corrected grid of the region to be corrected in the image to be processed and an original grid of the background region in the image to be processed.
In this embodiment, step 405 may be performed in the case where there is no protection region in the image to be processed. A grid (for example, grid points with low resolution represent coordinate points of each position in the image to be processed) may be established in the image to be processed, the grid is an original grid of the image to be processed, and from the original grid of the image to be processed, an original grid of a region to be corrected and an original grid of a background region in the image to be processed may be determined; and carrying out distortion correction on the original grid of the area to be corrected to obtain the corrected grid of the area to be corrected. The area to be corrected can be corrected by adopting conformal projection, so the corrected grid of the area to be corrected can also be called as the conformal projection grid of the area to be corrected.
Wherein the protection area comprises a human face area without distortion correction and/or a body area without distortion correction. The fact that no protection region exists in the image to be processed means that neither a human face region nor a body region which does not need distortion correction exists in the image to be processed.
Both the first body area in step 401 and the second body area in step 402 are body areas to be corrected. The region to be corrected in step 405 includes a body region to be corrected; if the image to be processed also comprises the face area to be corrected, the face area to be corrected is also comprised in the area to be corrected.
In an alternative embodiment, if a third body area exists in the image to be processed, the third body area may be determined to be a protection area; if a fourth body area exists in the image to be processed, it can be determined that the fourth body area is also a protection area. The fourth body area is a body area which is partially overlapped with the preset area, and the ratio of the area of the overlapped area to the area of the body area is larger than the first threshold value (namely, the second body area without distortion correction).
Compared with a body region, the area of the face region is smaller, so that when the face region exists in the image to be processed, whether the face region is in the preset region can be judged, and whether the face region needs to be subjected to distortion correction can be judged; if the face area is located in the preset area, the face area can be judged to be free from distortion correction, and the face area is a protection area; if the face area is not located in the preset area (for example, the face area is not overlapped with the preset area or partially overlapped with the preset area), it can be determined that the face area needs to be subjected to distortion correction, the face area is a face area to be corrected, and the corrected face area can be obtained by performing distortion correction on the face area.
Step 406, constructing a first optimization term based on the corrected grid of the region to be corrected and the optimized grid of the region to be corrected.
Wherein the first optimization term represents a difference between a corrected grid of the region to be corrected and an optimized grid of the region to be corrected.
The number of the regions to be corrected in the image to be processed may be one or at least two. When the number of the to-be-corrected areas is at least two, the optimization items corresponding to each to-be-corrected area can be calculated first, and the optimization items corresponding to all to-be-corrected areas are added to obtain a first optimization item.
In an alternative embodiment, the optimization term corresponding to each region to be corrected can be expressed as follows:
Figure BDA0003412883020000121
wherein E isc,kRepresenting an optimization item corresponding to the kth area to be corrected; i denotes an index of a grid point; omegaiA weight representing a grid point with index i; v. ofiRepresenting the coordinates of grid points with index i in the optimized grid of the kth area to be corrected; u. ofiRepresenting the coordinates of grid points with index i in corrected grids of the kth area to be corrected; t is tkA translation item representing the kth area to be corrected, which is used for carrying out integral translation transformation on the corrected grid of the kth area to be corrected; skAnd the similarity transformation item is used for carrying out overall similarity transformation on the corrected grids of the kth region to be corrected.
The first optimization term can be expressed as follows:
Figure BDA0003412883020000122
step 407, constructing a second optimization term based on the original grid of the background area and the optimized grid of the background area.
Wherein the second optimization term represents a difference between the original mesh of the background area and the optimized mesh of the background area.
The second optimization term may include a straight angle maintenance constraint and a grid spacing constraint. And keeping the constraint condition of the straight line angle for constraining the position offset of the original grid and the optimized grid in the background area so as to enable the finally obtained background area in the first optimized image to be similar to the background area in the image to be processed. The grid interval constraint condition is used for constraining the grid size offset of the original grid of the background area and the grid after optimization so as to prevent the abrupt grid change of the background area.
The expression of the straight-line angle holding constraint is as follows:
Figure BDA0003412883020000123
wherein g denotes an index of a grid point; j ∈ N (g) peripheral grid points representing grid points indexed g; e.g. of the typegjUnit vector in original grid as background area, egj=pg-pj,pgAnd pjRespectively representing the coordinates of grid points with indexes g and j in the original grid of the background area; v. ofgAnd vjThe coordinates of grid points indexed g and j in the optimized grid of the background region are respectively represented.
The expression of the grid spacing constraint is as follows:
Figure BDA0003412883020000131
step 408, a first optimization function is constructed based on the first optimization term and the second optimization term.
The first optimization function is a function which aims at minimizing the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected and the difference between the original grid of the background area and the optimized grid of the background area.
And performing weighted summation on the first optimization term and the second optimization term to obtain a first optimization function.
The first optimization function may be expressed as follows:
Et1=ωcEcbEbrEr
wherein, ω iscA weight representing a first optimization term; omegabA weight representing a straight-line angle holding constraint; ebRepresenting a straight line angle holding constraint; omegarWeights representing grid interval constraints; erRepresenting the grid spacing constraints.
Step 409, the optimized grid of the region to be corrected and the optimized grid of the background region are adjusted to minimize the first optimization function, so as to obtain a first optimized image.
By solving the first optimization function, a first optimized grid of the image to be processed can be obtained, and the first optimized grid is interpolated to obtain a first optimized image. Wherein the first optimized mesh includes an optimized mesh of the region to be corrected that minimizes the first optimization function and an optimized mesh of the background region.
According to the method and the device, the first optimization function is constructed based on the to-be-corrected area and the background area in the to-be-processed image, the corrected area can be optimized through the first optimization function, the shape of the background area in the first optimization image is consistent with the shape of the background area in the to-be-processed image, and therefore the first optimization image is natural and real.
Fig. 5 is a schematic view of an implementation flow of an image distortion correction method according to another embodiment of the present application, where the image distortion correction method is applied to an electronic device. As shown in fig. 5, the image distortion correction method may include the steps of:
step 501, if a first body area exists in at least one body area of the image to be processed, performing distortion correction on the first body area.
The step is the same as step 201, and reference may be made to the related description of step 201, which is not described herein again.
Step 502, if a second body region exists in at least one body region of the image to be processed, calculating the area of the second body region and the area of the first overlapping region.
The step is the same as step 202, and reference may be made to the related description of step 202, which is not repeated herein.
Step 503, calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region.
The step is the same as step 203, and reference may be made to the related description of step 203, which is not described herein again.
And step 504, if the first area ratio is smaller than or equal to the first threshold, performing distortion correction on the second body area.
The step is the same as step 204, and reference may be made to the related description of step 204, which is not described herein again.
And 505, determining a corrected grid of a region to be corrected in the image to be processed and an original grid of a background region in the image to be processed based on the original grid of the image to be processed.
The step is the same as step 405, and reference may be made to the related description of step 405, which is not described herein again.
Step 506, a first optimization item is constructed based on the corrected grid of the area to be corrected and the optimized grid of the area to be corrected.
The step is the same as the step 406, and reference may be made to the related description of the step 406, which is not described herein again.
And step 507, constructing a second optimization item based on the original grid of the background area and the optimized grid of the background area.
The step is the same as step 407, and reference may be made to the related description of step 407, which is not described herein again.
And step 508, constructing a third optimization item based on the original grid of the protection area and the optimized grid of the protection area.
Wherein the third optimization term represents a difference between the original mesh of the protection region and the optimized mesh of the protection region. The third optimization term may reduce the tensile deformation of the shape of the protection region such that the shape of the protection region in the second optimized image remains consistent with the shape in the image to be processed.
The number of the protection regions in the image to be processed may be one or at least two. When the number of the protection regions is at least two, the optimization term corresponding to each protection region may be calculated first, and the optimization terms corresponding to all the protection regions are added to obtain a third optimization term.
In an alternative embodiment, the optimization term corresponding to each protection region can be expressed as follows:
Figure BDA0003412883020000151
wherein E isp,hRepresenting an optimization item corresponding to the h-th protection area; d denotes an index of the grid point; omegadA weight representing a grid point with index d; v. ofdRepresenting the coordinates of grid points with index d in the optimized grid of the h-th protection area; p is a radical ofdCoordinates of grid points with index d in the original grid of the h-th protection area are represented; t is thAnd a translation item representing the h protective area is used for carrying out integral translation transformation on the original grid of the h protective area.
The third optimization term may be expressed as follows:
Figure BDA0003412883020000152
step 509, construct a second optimization function based on the first, second, and third optimization terms.
The second optimization function is a function which aims at minimizing the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected, the difference between the original grid of the background area and the optimized grid of the background area, and the difference between the original grid of the protection area and the optimized grid of the protection area.
And performing weighted summation on the first optimization term, the second optimization term and the third optimization term to obtain a second optimization function.
The second optimization function may be expressed as follows:
Et2=ωPEpcEcbEbrEr
wherein, ω isPRepresenting the weight of the third optimization term.
And step 510, minimizing the second optimization function by adjusting the optimized grids of the region to be corrected, the optimized grids of the background region and the optimized grids of the protection region, so as to obtain a second optimized image.
And solving the second optimization function to obtain a second optimized grid of the image to be processed, and interpolating the second optimized grid to obtain a second optimized image. The second optimized grid comprises an optimized grid of the area to be corrected, an optimized grid of the background area and an optimized grid of the protection area, wherein the optimized grid of the area to be corrected enables the second optimization function to be minimized.
In an optional embodiment, when the number of the protection regions is at least two and there are protection regions in the at least two protection regions where overlap occurs, the method further includes:
calculating the area of the first protection area, the area of the second protection area and the area of the second overlapping area; the first protection area and the second protection area refer to any two protection areas which are overlapped in at least two protection areas; the second overlapping area refers to the overlapping area of the first protection area and the second protection area;
determining the minimum value of the area of the first protection area and the second protection area based on the area of the first protection area and the area of the second protection area;
calculating a second area ratio, wherein the second area ratio is the ratio of the area of the second overlapped area to the minimum area;
and if the second area ratio is larger than the second threshold, combining the first protection area and the second protection area into one protection area.
The electronic equipment can reduce the calculation amount in the solving process of the second optimization function by combining the two protection areas with larger overlapping areas into one protection area, quickens the solving of the second optimization function and improves the optimization speed of the image to be processed.
According to the method and the device, the second optimization function is constructed based on the to-be-corrected area, the protection area and the background area in the to-be-processed image, the corrected area can be optimized through the second optimization function, meanwhile, the shape of the background area in the second optimization image is kept consistent with the shape of the to-be-processed image, and the shape of the protection area in the second optimization image is kept consistent with the shape of the to-be-processed image, so that the second optimization image is more natural and real.
For the embodiments of the image distortion correction method shown in fig. 4 and 5, the first optimization term in the two embodiments may include an optimization term corresponding to the corrected body region; the first optimization item comprises an optimization item corresponding to the body area to be corrected; before constructing the first optimization term based on the corrected grid of the region to be corrected and the optimized grid of the region to be corrected, the method further comprises the following steps:
acquiring a target correction degree of a body area to be corrected;
determining the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected based on the target correction degree;
constructing a first optimization item based on the corrected grids of the area to be corrected and the optimized grids of the area to be corrected, wherein the first optimization item comprises the following steps:
and constructing an optimization term corresponding to the body area to be corrected based on the corrected grid of the body area to be corrected, the optimized grid of the body area to be corrected, and the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected, so that the distortion correction degree of the body area to be corrected reaches the target correction degree through the optimization term.
By adjusting the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected, distortion correction of different degrees can be performed on the body area to be corrected, so that the distortion correction degree of the body area to be corrected can be adjusted in a self-adaptive manner.
In an alternative embodiment, the body area to be corrected is framed by a body frame; acquiring a target distortion correction degree of a body region to be corrected, comprising:
judging whether the transverse coordinate of the left vertex of the body frame is smaller than a third threshold value and/or whether the transverse coordinate of the right vertex of the body frame is larger than a fourth threshold value, wherein the third threshold value is larger than zero and smaller than the fourth threshold value;
and if the transverse coordinate of the left vertex of the body frame is smaller than a third threshold value and/or the transverse coordinate of the right vertex of the body frame is larger than a fourth threshold value, determining that the target correction degree is a first target correction degree, otherwise, determining that the target correction degree is a second target correction degree, wherein the first target correction degree is larger than the second target correction degree.
Wherein the body frame may be a minimum bounding rectangle of the body region to be corrected.
The distortion in the image to be processed is generally generated from the center point of the image to be processed in bilateral symmetry, the closer the area to the center point, the smaller the distortion degree, and the farther the area to the center point, the larger the distortion degree. Therefore, the transverse coordinate of the left vertex of the body frame can be compared with the third threshold value on the left side of the image to be processed, and the transverse coordinate of the right vertex of the body frame can be compared with the fourth threshold value on the right side of the image to be processed, so that the distortion degree of the body area to be corrected is judged, and the target correction degree corresponding to the distortion degree of the body area to be corrected is obtained. As shown in fig. 6, an exemplary diagram of the body frame is shown, and the rectangular frame indicated by the dotted line in fig. 6 is the body frame.
By acquiring the target correction degree of the body area to be corrected, the target correction degree of the body area to be corrected can be adaptively adjusted based on the distortion degree of the body area to be corrected in the image to be processed.
In an optional embodiment, before determining whether the lateral coordinate of the left vertex of the body frame is smaller than the third threshold and/or whether the lateral coordinate of the right vertex of the body frame is larger than the fourth threshold, the method further includes:
and determining a third threshold and a fourth threshold based on the maximum value of the transverse coordinate of the image to be processed, wherein the fourth threshold is larger than zero and smaller than the maximum value of the transverse coordinate.
The electronic device sets a third threshold and a fourth threshold based on the maximum value of the lateral coordinate of the image to be processed (for example, the third threshold is the maximum value of the lateral coordinate)
Figure BDA0003412883020000181
The fourth threshold being the maximum of the lateral coordinate
Figure BDA0003412883020000182
) Different thresholds can be set for the images to be processed with different maximum values of the transverse coordinates, so that the self-adaptive setting of the third threshold and the fourth threshold is realized. Wherein, the maximum value of the transverse coordinates refers to the width of the image to be processed.
Fig. 7 is a schematic structural diagram of an image distortion correction apparatus according to an embodiment of the present application, and only a part related to the embodiment of the present application is shown for convenience of description.
The image distortion correction device includes:
a first correction module 71, configured to, if a first body region exists in at least one body region of the image to be processed, perform distortion correction on the first body region; the body area is an area which does not contain face data in the portrait area of the image to be processed; the first body area is a body area which is not overlapped with the preset area; the preset area is a local area which takes a central point of the image to be processed as a center in the image to be processed;
an area calculation module 72, configured to calculate an area of the second body region and an area of the first overlap region if the second body region exists in the at least one body region of the image to be processed; the second body area is a body area which is overlapped with the preset area; the first overlapping area refers to the overlapping area of the second body area and the preset area;
a ratio calculation module 73 for calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region;
a second correction module 74 for performing distortion correction on the second body region if the first area ratio is less than or equal to the first threshold.
Optionally, the first body region and the second body region for distortion correction are body regions to be corrected, and the image distortion correction apparatus further includes:
the first determining module is used for determining corrected grids of a to-be-corrected area in the to-be-processed image and original grids of a background area in the to-be-processed image on the basis of original grids of the to-be-processed image under the condition that a protection area does not exist in the to-be-processed image; the protection area comprises a human face area without distortion correction and/or a body area without distortion correction; the region to be corrected comprises a body region to be corrected; when the face area to be corrected exists in the image to be processed, the face area to be corrected also comprises the face area to be corrected;
the first construction module is used for constructing a first optimization item based on the corrected grids of the area to be corrected and the optimized grids of the area to be corrected; the first optimization item represents the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected;
the second construction module is used for constructing a second optimization item based on the original grid of the background area and the optimized grid of the background area; the second optimization item represents the difference between the original grid of the background area and the optimized grid of the background area;
the first optimization module is used for constructing a first optimization function based on the first optimization term and the second optimization term; the first optimization function is a function which aims at minimizing the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected and the difference between the original grid of the background area and the optimized grid of the background area;
and the first adjusting module is used for minimizing the first optimization function by adjusting the optimized grids of the region to be corrected and the optimized grids of the background region to obtain a first optimized image.
Optionally, the first body region and the second body region for distortion correction are regions to be corrected, and the image distortion correction apparatus further includes:
the second determination module is used for determining corrected grids of the to-be-corrected area in the to-be-processed image, original grids of the background area in the to-be-processed image and original grids of the protection area on the basis of the original grids of the to-be-processed image under the condition that the protection area exists in the to-be-processed image; the protection area comprises a human face area without distortion correction and/or a body area without distortion correction; the region to be corrected comprises a body region to be corrected; when the face area to be corrected exists in the image to be processed, the face area to be corrected also comprises the face area to be corrected;
the first construction module is used for constructing a first optimization item based on the corrected grids of the area to be corrected and the optimized grids of the area to be corrected; the first optimization item represents the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected;
the second construction module is used for constructing a second optimization item based on the original grid of the background area and the optimized grid of the background area; the second optimization item represents the difference between the original grid of the background area and the optimized grid of the background area;
the third construction module is used for constructing a third optimization item based on the original grid of the protection area and the optimized grid of the protection area; the third optimization item represents the difference between the original grid of the protection area and the optimized grid of the protection area;
the second optimization module is used for constructing a second optimization function based on the first optimization term, the second optimization term and the third optimization term; the second optimization function is a function which aims at minimizing the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected, the difference between the original grid of the background area and the optimized grid of the background area, and the difference between the original grid of the protection area and the optimized grid of the protection area;
and the second adjusting module is used for minimizing the second optimization function by adjusting the optimized grids of the region to be corrected, the optimized grids of the background region and the optimized grids of the protection region to obtain a second optimized image.
Optionally, when the number of the protection regions is at least two and there is a protection region where overlap occurs in at least two protection regions, the image distortion correction apparatus further includes:
the first calculation module is used for calculating the area of the first protection area, the area of the second protection area and the area of the second overlapping area; the first protection area and the second protection area refer to any two protection areas which are overlapped in at least two protection areas; the second overlapping area refers to the overlapping area of the first protection area and the second protection area;
the minimum value determining module is used for determining the minimum value of the areas in the first protection area and the second protection area based on the area of the first protection area and the area of the second protection area;
the second calculation module is used for calculating a second area ratio, wherein the second area ratio is the ratio of the area of the second overlapping area to the minimum area;
and the area synthesis module is used for merging the first protection area and the second protection area into one protection area if the second area ratio is larger than a second threshold.
Optionally, the first optimization term comprises an optimization term corresponding to the body region to be corrected; the image distortion correction apparatus further includes:
the target acquisition module is used for acquiring the target correction degree of the body area to be corrected;
the weight determining module is used for determining the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected based on the target correction degree;
the first building block is specifically configured to:
and constructing an optimization term corresponding to the body area to be corrected based on the corrected grid of the body area to be corrected, the optimized grid of the body area to be corrected, and the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected, so that the distortion correction degree of the body area to be corrected reaches the target correction degree through the optimization term.
Optionally, the body area to be corrected is framed by a body frame; the target acquisition module includes:
a threshold value judging unit, configured to judge whether the lateral coordinate of the left vertex of the body frame is smaller than a third threshold value, and/or whether the lateral coordinate of the right vertex of the body frame is larger than a fourth threshold value, where the third threshold value is larger than zero and smaller than the fourth threshold value;
and the degree determining unit is used for determining the target correction degree to be a first target correction degree if the transverse coordinate of the left vertex of the body frame is smaller than a third threshold value and/or the transverse coordinate of the right vertex of the body frame is larger than a fourth threshold value, otherwise, determining the target correction degree to be a second target correction degree, wherein the first target correction degree is larger than the second target correction degree.
Optionally, the target obtaining module further includes:
and the threshold calculation unit is used for determining a third threshold and a fourth threshold based on the maximum value of the transverse coordinate of the image to be processed, and the fourth threshold is larger than zero and smaller than the maximum value of the transverse coordinate.
The image distortion correction device provided in the embodiment of the present application can be applied to the foregoing method embodiments, and for details, reference is made to the description of the foregoing method embodiments, and details are not repeated here.
Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application. As shown in fig. 8, the electronic apparatus 8 of this embodiment includes: one or more processors 80 (only one of which is shown), a memory 81, and a computer program 82 stored in the memory 81 and executable on the at least one processor 80. The processor 80 implements the steps in the various image distortion correction method embodiments described above when executing the computer program 82.
The electronic device may include, but is not limited to, a processor 80, a memory 81. Those skilled in the art will appreciate that fig. 8 is merely an example of an electronic device 8 and does not constitute a limitation of the electronic device 8 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the electronic device may also include input-output devices, network access devices, buses, etc.
The Processor 80 may be a Central Processing Unit (CPU), or other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 81 may be an internal storage unit of the electronic device 8, such as a hard disk or a memory of the electronic device 8. The memory 81 may also be an external storage device of the electronic device 8, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 8. Further, the memory 81 may also include both an internal storage unit and an external storage device of the electronic device 8. The memory 81 is used for storing the computer program and other programs and data required by the electronic device. The memory 81 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the above-mentioned apparatus may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps that can be implemented in the above method embodiments.
The embodiments of the present application further provide a computer program product, which when executed on an electronic device, enables the electronic device to implement the steps in the above method embodiments when executed.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other ways. For example, the above-described apparatus/electronic device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (12)

1. An image distortion correction method, comprising:
if a first body area exists in at least one body area of the image to be processed, carrying out distortion correction on the first body area; the body area refers to an area which does not contain face data in the portrait area of the image to be processed; the first body area is a body area which is not overlapped with a preset area; the preset area is a local area which takes a central point of the image to be processed as a center in the image to be processed;
if a second body area exists in at least one body area of the image to be processed, calculating the area of the second body area and the area of a first overlapping area; the second body area refers to the body area partially overlapping with the preset area; the first overlapping area refers to an overlapping area of the second body area and the preset area;
calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region;
and if the first area ratio is smaller than or equal to a first threshold value, performing distortion correction on the second body area.
2. The image distortion correction method according to claim 1, wherein the first body region and the second body region subjected to distortion correction are body regions to be corrected, further comprising:
under the condition that a protection area does not exist in the image to be processed, determining corrected grids of the area to be corrected in the image to be processed and original grids of a background area in the image to be processed based on the original grids of the image to be processed; the protection area comprises a human face area without distortion correction and/or a body area without distortion correction; the region to be corrected comprises the body region to be corrected; when a face area to be corrected exists in the image to be processed, the face area to be corrected also comprises the face area to be corrected;
constructing a first optimization item based on the corrected grids of the area to be corrected and the optimized grids of the area to be corrected; the first optimization term represents the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected;
constructing a second optimization item based on the original grid of the background area and the optimized grid of the background area; the second optimization term represents the difference between the original grid of the background area and the optimized grid of the background area;
constructing a first optimization function based on the first optimization term and the second optimization term; the first optimization function is a function which aims at minimizing the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected and the difference between the original grid of the background area and the optimized grid of the background area;
and minimizing the first optimization function by adjusting the optimized grid of the area to be corrected and the optimized grid of the background area to obtain a first optimized image.
3. The image distortion correction method according to claim 1, wherein the first body region and the second body region subjected to distortion correction are regions to be corrected, further comprising:
under the condition that a protection area exists in the image to be processed, determining a corrected grid of the area to be corrected in the image to be processed, an original grid of a background area in the image to be processed and an original grid of the protection area based on an original grid of the image to be processed; the protection area comprises a human face area without distortion correction and/or a body area without distortion correction; the region to be corrected comprises the body region to be corrected; when a face area to be corrected exists in the image to be processed, the face area to be corrected also comprises the face area to be corrected;
constructing a first optimization item based on the corrected grids of the area to be corrected and the optimized grids of the area to be corrected; the first optimization term represents the difference between the corrected grid of the area to be corrected and the optimized grid of the area to be corrected;
constructing a second optimization item based on the original grid of the background area and the optimized grid of the background area; the second optimization term represents the difference between the original grid of the background area and the optimized grid of the background area;
constructing a third optimization item based on the original grid of the protection area and the optimized grid of the protection area; the third optimization term represents the difference between the original grid of the protection area and the optimized grid of the protection area;
constructing a second optimization function based on the first, second, and third optimization terms; the second optimization function is a function with the objective of minimizing the difference between the corrected grid of the region to be corrected and the optimized grid of the region to be corrected, the difference between the original grid of the background region and the optimized grid of the background region, and the difference between the original grid of the protection region and the optimized grid of the protection region;
and minimizing the second optimization function by adjusting the optimized grid of the area to be corrected, the optimized grid of the background area and the optimized grid of the protection area to obtain a second optimized image.
4. The image distortion correction method according to claim 3, further comprising, when the number of the protection regions is at least two and there is a protection region where overlap occurs in at least two of the protection regions:
calculating the area of the first protection area, the area of the second protection area and the area of the second overlapping area; the first protection area and the second protection area refer to any two protection areas which are overlapped in at least two protection areas; the second overlapping area refers to an overlapping area of the first protection area and the second protection area;
determining a minimum area value in the first protection region and the second protection region based on the area of the first protection region and the area of the second protection region;
calculating a second area ratio, which is a ratio of an area of the second overlapping region to the minimum of the areas;
if the second area ratio is greater than a second threshold, the first protection area and the second protection area are combined into one protection area.
5. The image distortion correction method according to claim 2 or 3, characterized in that the first optimization term includes an optimization term corresponding to the body region to be corrected; before constructing the first optimization term based on the corrected grid of the region to be corrected and the optimized grid of the region to be corrected, the method further includes:
acquiring a target correction degree of the body area to be corrected;
determining the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected based on the target correction degree;
constructing a first optimization item based on the corrected grid of the region to be corrected and the optimized grid of the region to be corrected, wherein the first optimization item comprises the following steps:
and constructing an optimization term corresponding to the body area to be corrected based on the corrected grid of the body area to be corrected, the optimized grid of the body area to be corrected, and the weight of each grid point in the corrected grid of the body area to be corrected and the optimized grid of the body area to be corrected, so that the distortion correction degree of the body area to be corrected reaches the target correction degree through the optimization term.
6. The image distortion correction method according to claim 5, characterized in that the body region to be corrected is framed by a body frame; the obtaining of the target distortion correction degree of the body region to be corrected includes:
judging whether the transverse coordinate of the left vertex of the body frame is smaller than a third threshold value and/or whether the transverse coordinate of the right vertex of the body frame is larger than a fourth threshold value, wherein the third threshold value is larger than zero and smaller than the fourth threshold value;
if the lateral coordinate of the left vertex of the body frame is smaller than the third threshold value and/or the lateral coordinate of the right vertex of the body frame is larger than the fourth threshold value, determining that the target correction degree is a first target correction degree, otherwise, determining that the target correction degree is a second target correction degree, wherein the first target correction degree is larger than the second target correction degree.
7. The image distortion correction method according to claim 6, before determining whether the lateral coordinate of the left side vertex of the body frame is smaller than a third threshold value and/or whether the lateral coordinate of the right side vertex of the body frame is larger than a fourth threshold value, further comprising:
determining the third threshold and the fourth threshold based on a maximum value of the transverse coordinate of the image to be processed, wherein the fourth threshold is greater than zero and smaller than the maximum value of the transverse coordinate.
8. The image distortion correction method according to any one of claims 1 to 3, characterized by further comprising:
if a portrait area which does not contain face data exists in the image to be processed, determining the portrait area as the body area;
and if the image to be processed has a portrait area containing face data, determining the body area in the portrait area based on the position information in the face data.
9. An image distortion correction apparatus, characterized by comprising:
the first correction module is used for carrying out distortion correction on at least one body area of the image to be processed if the first body area exists in the body area; the body area refers to an area which does not contain face data in the portrait area of the image to be processed; the first body area is a body area which is not overlapped with a preset area; the preset area is a local area which takes a central point of the image to be processed as a center in the image to be processed;
an area calculation module, configured to calculate an area of a second body region and an area of a first overlap region if the second body region exists in at least one of the body regions of the image to be processed; the second body area refers to the body area partially overlapping with the preset area; the first overlapping area refers to an overlapping area of the second body area and the preset area;
the ratio calculation module is used for calculating a first area ratio; the first area ratio is the ratio of the area of the first overlap region to the area of the second body region;
and the second correction module is used for carrying out distortion correction on the second body area if the first area ratio is smaller than or equal to a first threshold value.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the image distortion correction method according to any one of claims 1 to 8 when executing the computer program.
11. A chip comprising a processor, characterized in that the processor is adapted to read and execute a computer program stored in a memory for performing the steps of the image distortion correction method according to any of claims 1 to 8.
12. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the image distortion correction method according to any one of claims 1 to 8.
CN202111535083.0A 2021-12-15 2021-12-15 Image distortion correction method, device, electronic equipment, chip and storage medium Pending CN114187206A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111535083.0A CN114187206A (en) 2021-12-15 2021-12-15 Image distortion correction method, device, electronic equipment, chip and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111535083.0A CN114187206A (en) 2021-12-15 2021-12-15 Image distortion correction method, device, electronic equipment, chip and storage medium

Publications (1)

Publication Number Publication Date
CN114187206A true CN114187206A (en) 2022-03-15

Family

ID=80543974

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111535083.0A Pending CN114187206A (en) 2021-12-15 2021-12-15 Image distortion correction method, device, electronic equipment, chip and storage medium

Country Status (1)

Country Link
CN (1) CN114187206A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114612342A (en) * 2022-03-28 2022-06-10 Oppo广东移动通信有限公司 Face image correction method and device, computer readable medium and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114612342A (en) * 2022-03-28 2022-06-10 Oppo广东移动通信有限公司 Face image correction method and device, computer readable medium and electronic equipment

Similar Documents

Publication Publication Date Title
CN111145238B (en) Three-dimensional reconstruction method and device for monocular endoscopic image and terminal equipment
CN111275626B (en) Video deblurring method, device and equipment based on ambiguity
WO2021088473A1 (en) Image super-resolution reconstruction method, image super-resolution reconstruction apparatus, and computer-readable storage medium
CN109064428B (en) Image denoising processing method, terminal device and computer readable storage medium
WO2020119527A1 (en) Human action recognition method and apparatus, and terminal device and storage medium
US20190251675A1 (en) Image processing method, image processing device and storage medium
CN108428214B (en) Image processing method and device
CN110852310B (en) Three-dimensional face recognition method and device, terminal equipment and computer readable medium
CN110378837B (en) Target detection method and device based on fish-eye camera and storage medium
CN108717704B (en) Target tracking method based on fisheye image, computer device and computer readable storage medium
CN105405104B (en) A kind of method and device of face image correcting
CN112686824A (en) Image correction method, image correction device, electronic equipment and computer readable medium
CN111861938B (en) Image denoising method and device, electronic equipment and readable storage medium
CN112470192A (en) Dual-camera calibration method, electronic device and computer-readable storage medium
CN112651380A (en) Face recognition method, face recognition device, terminal equipment and storage medium
CN111667504A (en) Face tracking method, device and equipment
CN114187206A (en) Image distortion correction method, device, electronic equipment, chip and storage medium
CN114283095A (en) Image distortion correction method, system, electronic equipment and storage medium
CN111222446B (en) Face recognition method, face recognition device and mobile terminal
CN113570725A (en) Three-dimensional surface reconstruction method and device based on clustering, server and storage medium
CN110032941B (en) Face image detection method, face image detection device and terminal equipment
CN111340722A (en) Image processing method, processing device, terminal device and readable storage medium
CN113497886B (en) Video processing method, terminal device and computer-readable storage medium
CN115205111A (en) Image splicing method and device, terminal equipment and storage medium
CN114863030A (en) Method for generating user-defined 3D model based on face recognition and image processing technology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination