Method, electronic device and storage medium for processing image
Abstract
A method electronic device and storage medium for processing an image are provided. The method includes: receiving an instruction for a preset fly-away special effect; creating a facial grid and facial feature grids in the image to be processed; determining a facial image in an image region covered by the facial grid; setting a pixel value of each pixel in the facial image to a target pixel value; extracting facial feature images from an image region covered by the facial feature grids; and obtaining a target image by mapping the facial feature images onto the facial image based on a preset triangular mapping algorithm and a preset offset.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method for processing an image, comprising:
creating a facial grid and facial feature grids in an image to be processed; determining a facial image in an image region covered by the facial grid; extracting facial feature images from an image region covered by the facial feature grids; and obtaining a target image based on the facial feature images and the facial image according to a preset mapping algorithm and a preset change amount.
2 . The method according to claim 1 , wherein the preset change amount comprises offsets of the facial feature images, wherein said obtaining the target image based on the facial feature images and the facial image according to the preset mapping algorithm and the preset change amount comprises:
obtaining the target image by mapping the facial feature images onto the facial image according to the preset mapping algorithm and the offsets of the facial feature images.
3 . The method according to claim 1 , wherein the preset change amount comprises a change amount of a shape, wherein said obtaining the target image based on the facial feature images and the facial image according to the preset mapping algorithm and the preset change amount comprises:
obtaining a deformed facial feature image, by changing the shape of at least one of the facial feature images based on the change amount of the shape; and obtaining the target image by mapping the deformed facial feature image onto the facial image according to the preset mapping algorithm.
4 . The method according to claim 1 , wherein said creating the facial grid and the facial feature grids comprises:
mapping a first number of key points in a pre-stored first face template onto a facial image region of a user in the image to be processed, according to the preset mapping algorithm; and creating the facial grid and the facial feature grids based on the first number of key points and preset types of key points; wherein the preset types of key points comprise a facial type, a mouth type, a nose type, and an eye type.
5 . The method according to claim 4 , further comprising:
acquiring a pre-stored second face template comprising a second number of key points; determining a third number of key points and their types according to the second number of key points and the preset types of key points; and determining the first face template based on the second face template and the third number of key points.
6 . The method according to claim 1 , further comprising:
setting a pixel value of each pixel in the facial image to a target pixel value.
7 . The method according to claim 6 , further comprising:
extracting pixel values of pixels at a plurality of preset positions in the facial image, wherein the preset positions comprise positions at forehead and/or cheek; and determining the target pixel value to be an average value of the pixel values.
8 . An electronic device, comprising:
a processor; and a memory storing instructions to be executed by the processor, wherein execution of the instructions causes the processor to: create a facial grid and facial feature grids in an image to be processed; determine a facial image in an image region covered by the facial grid; extract facial feature images from an image region covered by the facial feature grids; and obtain a target image based on the facial feature images and the facial image according to a preset mapping algorithm and a preset change amount.
9 . The electronic device according to claim 8 , wherein the preset change amount comprises offsets of the facial feature images, and wherein the execution of the instructions further causes the processor to:
obtain the target image by mapping the facial feature images onto the facial image according to the preset mapping algorithm and the offsets of the facial feature images.
10 . The electronic device according to claim 8 , wherein the preset change amount comprises a change amount of a shape, wherein the execution of the instructions further causes the processor to:
obtain a deformed facial feature image, by changing the shape of at least one of the facial feature images based on the change amount of the shape; and obtain the target image by mapping the deformed facial feature image onto the facial image according to the preset mapping algorithm.
11 . The electronic device according to claim 8 , wherein the execution of the instructions further causes the processor to:
map a first number of key points in a pre-stored first face template onto a facial image region of a user in the image to be processed, according to the preset mapping algorithm; and create the facial grid and the facial feature grids based on the first number of key points and preset types of key points; wherein the preset types of key points comprise a facial type, a mouth type, a nose type, and an eye type.
12 . The electronic device according to claim 11 , wherein the execution of the instructions further causes the processor to:
acquire a pre-stored second face template comprising a second number of key points; determine a third number of key points and their types according to the second number of key points and the preset types of key points; and determine the first face template based on the second face template and the third number of key points.
13 . The electronic device according to claim 8 , wherein the execution of the instructions further causes the processor to:
set a pixel value of each pixel in the facial image to a target pixel value.
14 . The electronic device according to claim 13 , wherein the execution of the instructions further causes the processor to:
extract pixel values of pixels at a plurality of preset positions in the facial image, wherein the preset positions comprise positions at forehead and/or cheek; and determine the target pixel value to be an average value of the pixel values.
15 . A non-transitory computer readable storage medium carrying instructions thereon to be executed by a processor, wherein execution of the instructions causes the processor to:
create a facial grid and facial feature grids in an image to be processed; determine a facial image in an image region covered by the facial grid; extract facial feature images from an image region covered by the facial feature grids; and obtain a target image based on the facial feature images and the facial image according to a preset mapping algorithm and a preset change amount.
16 . The non-transitory computer readable storage medium according to claim 15 , wherein the preset change amount comprises offsets of the facial feature images, wherein the execution of the instructions further causes the processor to:
obtain the target image by mapping the facial feature images onto the facial image according to the preset mapping algorithm and the offsets of the facial feature images.
17 . The non-transitory computer readable storage medium according to claim 15 , wherein the preset change amount comprises a change amount of a shape, wherein the execution of the instructions further causes the processor to:
obtain a deformed facial feature image, by changing the shape of at least one of the facial feature images based on the change amount of the shape; and obtain the target image by mapping the deformed facial feature image onto the facial image according to the preset mapping algorithm.
18 . The non-transitory computer readable storage medium according to claim 15 , wherein the execution of the instructions further causes the processor to:
map a first number of key points in a pre-stored first face template onto a facial image region of a user in the image to be processed, according to the preset mapping algorithm; and create the facial grid and the facial feature grids based on the first number of key points and preset types of key points; wherein the preset types of key points comprise a facial type, a mouth type, a nose type, and an eye type.
19 . The non-transitory computer readable storage medium according to claim 18 , wherein the execution of the instructions further causes the processor to:
acquire a pre-stored second face template comprising a second number of key points; determine a third number of key points and their types according to the second number of key points and the preset types of key points; and determine the first face template based on the second face template and the third number of key points.
20 . The non-transitory computer readable storage medium according to claim 15 , wherein the execution of the instructions further causes the processor to:
extract pixel values of pixels at a plurality of preset positions in the facial image, wherein the preset positions comprise positions at forehead and/or cheek; determine target pixel value to be an average value of the pixel values; and set a pixel value of each pixel in the facial image to the target pixel value.Join the waitlist — get patent alerts
Track US2021256672A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.