Image processing method, device, equipment and storage medium
By performing three-dimensional reconstruction and transformation processing on the original facial image, combined with outscaling and displacement image technology, the problem of unnatural facial image editing in the existing technology is solved, and a more realistic and natural facial image processing effect is achieved.
Patent Information
- Application Number
- CN202210626337.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-02
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-06-02
AI Technical Summary
The existing portrait editing methods are limited by the accuracy of the 3D model, which leads to unnatural facial images after editing, and unnatural transitions between the face and the background, sharp boundaries of the model, and angular problems.
By performing three-dimensional reconstruction of the original facial image, the initial 3D model is obtained; the initial 3D model is transformed based on the preset transformation information to obtain the transformed 3D model; the transformed 3D model is extended to obtain the outer expansion 3D model; the displacement image is determined based on the outer expansion 3D model and the initial 3D model; the original facial image is transformed based on the displacement image to obtain the target facial image.
By extubating the transformed 3D model, the problem of unnatural transition between the face and the background is solved; the original facial image is transformed through the displacement image, and the edges and angles caused by the intersection of the model border and the model face sheet are solved, making the facial image after the transformed process more realistic and natural, thereby improving the image display effect.
Smart Images

Figure CN115019021B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of image processing technology, and in particular, to an image processing method, apparatus, device and storage medium. Background Art
[0002] The existing portrait editing method reconstructs a three-dimensional (3D) model, adjusts the facial orientation and angle on the 3D model, and then renders it into a 2D image. This method is limited by the accuracy of the 3D model, resulting in unnatural edited facial images. Summary of the invention
[0003] The embodiments of the present disclosure provide an image processing method, apparatus, device and storage medium, which can realize transformation processing of facial images, so that the facial images after transformation processing are more natural, thereby improving the display effect of the image.
[0004] In a first aspect, an embodiment of the present disclosure provides an image processing method, including:
[0005] Perform three-dimensional reconstruction on the original facial image to obtain an initial 3D model;
[0006] Transform the initial 3D model according to preset transformation information to obtain a transformed 3D model;
[0007] Performing an outward expansion process on the transformed 3D model to obtain an outward expanded 3D model;
[0008] Determine a displacement image according to the expanded 3D model and the initial 3D model;
[0009] The original facial image is transformed according to the displacement image to obtain a target facial image.
[0010] In a second aspect, the present disclosure also provides an image processing device, including:
[0011] An initial 3D model acquisition module is used to perform three-dimensional reconstruction of the original facial image to obtain an initial 3D model;
[0012] A transformed 3D model acquisition module, used to transform the initial 3D model according to preset transformation information to obtain a transformed 3D model;
[0013] An externally expanded 3D model acquisition module, used to perform external expansion processing on the transformed 3D model to obtain an externally expanded 3D model;
[0014] A displacement image determination module, configured to determine a displacement image according to the expanded 3D model and the initial 3D model;
[0015] The target facial image acquisition module is used to transform the original facial image according to the displacement image to obtain the target facial image.
[0016] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising: one or more processors;
[0017] a storage device for storing one or more programs,
[0018] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in the embodiment of the present disclosure.
[0019] In a fourth aspect, the embodiments of the present disclosure further provide a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the image processing method as described in the embodiments of the present disclosure.
[0020] The disclosed embodiments disclose an image processing method, apparatus, device and storage medium. The original facial image is three-dimensionally reconstructed to obtain an initial 3D model; the initial 3D model is transformed according to preset transformation information to obtain a transformed 3D model; the transformed 3D model is expanded to obtain an expanded 3D model; a displacement image is determined according to the expanded 3D model and the initial 3D model; the original facial image is transformed according to the displacement image to obtain a target facial image. The image processing method provided by the disclosed embodiments can solve the problem of unnatural transition between the face and the background by expanding the transformed 3D model, and can solve the problem of sharp model boundaries and angular problems caused by the intersection of model face pieces by transforming the original facial image through the displacement image, so that the facial image after transformation is more realistic and natural, thereby improving the display effect of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.
[0022] Figure 1 is a flowchart of an image processing method provided by an embodiment of the present disclosure;
[0023] Figure 2a is a schematic diagram of determining a bounding rectangular frame of a transformed 3D model provided by an embodiment of the present disclosure;
[0024] Figure 2b is a schematic diagram of determining a bounding rectangular frame of a transformed 3D model provided by an embodiment of the present disclosure;
[0025] Figure 3 is an example graph for determining an outward expansion vertex provided by an embodiment of the present disclosure;
[0026] Figure 4 is an example diagram of a constructed outward expansion grid provided by an embodiment of the present disclosure;
[0027] Figure 5 is a schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure;
[0028] Figure 6 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0030] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0031] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0032] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0033] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0034] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0035] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0036] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0037] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0038] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0039] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0040] Most existing facial image editing methods are based on 2D image deformation. These methods generally obtain 2D facial key points through detection algorithms, change the positions of facial key points according to preset rules or user-defined rules, and deform the image according to the positions of facial key points before and after the change to achieve the function of facial deformation. However, due to the lack of facial depth information, this method cannot adjust the facial direction and angle while maintaining facial features.
[0041] Another facial image editing method is to reconstruct a 3D model, adjust the facial orientation and angle on the 3D model, and then render it into a 2D image. However, this method is limited by the accuracy of the 3D model and the reconstruction algorithm. The rendered facial boundaries are sharp and there are angular problems caused by the intersection of model patches, resulting in unnatural rendering results.
[0042] Figure 1 A flowchart of an image processing method provided in an embodiment of the present disclosure is provided. The embodiment of the present disclosure is applicable to the situation where facial images are transformed. The method can be executed by an image processing device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC or a server, etc.
[0043] like Figure 1 As shown, the method includes:
[0044] S110, performing three-dimensional reconstruction on the original facial image to obtain an initial 3D model.
[0045] The original facial image may be an image containing a face to be processed, a facial image collected in real time, a facial image authorized for use from a network database, or a facial image obtained from a local database. The 3D model may be a 3D mesh model, where the mesh is composed of vertices and lines. The 3D model includes three-dimensional coordinate information and normal information of facial 3D vertices.
[0046] In this embodiment, any 3D reconstruction algorithm can be used to perform 3D reconstruction on the original facial image, which is not limited here. For example, the original facial image can be input into a trained 3D reconstruction neural network model to output an initial 3D model.
[0047] S120, transforming the initial 3D model according to preset transformation information to obtain a transformed 3D model.
[0048] The preset transformation information may include transformation information of facial angle and / or orientation. The preset transformation information may be determined according to preset transformation parameters or according to adjustment information of the facial image triggered by the user.
[0049] In this embodiment, the initial 3D model is transformed according to the preset transformation information to obtain the transformed 3D model by: generating a transformation matrix according to the preset transformation information; and transforming the initial 3D model based on the transformation matrix to obtain the transformed 3D model.
[0050] Specifically, a transformation vector corresponding to the preset transformation information is determined, and a transformation matrix is formed by the transformation vector. The process of transforming the initial 3D model based on the transformation matrix may be: performing a dot multiplication of the transformation matrix and a matrix formed by vertex data of the initial 3D model to obtain a transformed 3D model. In this embodiment, transforming the initial 3D model based on the transformation matrix can improve the efficiency and accuracy of the 3D model transformation.
[0051] S130, performing an outward expansion process on the transformed 3D model to obtain an outward expanded 3D model.
[0052] The process of expanding the transformed 3D model outwards can be understood as expanding the transformed 3D model outwards. The process can be: firstly, new vertices are added to the periphery of the transformed 3D model, then a new mesh is constructed by the new vertices and the set vertices on the transformed 3D model, and the new mesh and the transformed 3D model are combined into an expanded 3D model.
[0053] In this embodiment, the transformed 3D model is expanded outward to obtain the expanded 3D model in the following manner: multiple target vertices are selected from the transformed 3D model; the expansion vertices corresponding to the multiple target vertices are determined to obtain multiple expansion vertices; a triangular mesh is constructed according to the multiple target vertices and the multiple expansion vertices to obtain an expansion mesh; and the expansion mesh and the transformed 3D model are combined into an expanded 3D model.
[0054] The target vertex may be a facial edge vertex of the transformed 3D model. The edge vertex may be understood as a vertex corresponding to a facial edge point of a two-dimensional image after the transformed 3D model is projected onto a two-dimensional plane. In this embodiment, the facial edge vertices include multiple facial edge vertices, and the target vertex may be all facial edge vertices or may be sampled from the facial edge vertices.
[0055] The method for determining the outward expansion vertices corresponding to the multiple target vertices may be: adding the corresponding outward expansion vertices according to the position coordinates of the target vertices. In this embodiment, the method for determining the outward expansion vertices corresponding to the multiple target vertices may be: obtaining an enclosing rectangular box of the transformed 3D model; and determining the outward expansion vertices on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex according to the size information of the enclosing rectangular box.
[0056] The size information of the bounding rectangle includes width and / or height. The bounding rectangle may be a circumscribed rectangle of the two-dimensional facial image after the transformed 3D model is projected onto a two-dimensional plane. For example, Figure 2a and Figure 2b is the bounding rectangle of the determined transformed 3D model, Figure 2a A frontal facial image. Figure 2b For a side face view, Figure 2a and Figure 2b As shown, the enclosing rectangular frame ABCD is the circumscribed rectangular frame of the facial image, which can also be understood as the range frame of the facial vertices on the x-axis and y-axis. Among them, x1=x3 is the minimum value of the facial vertex on the x-axis, x2=x4 is the maximum value of the facial vertex on the x-axis, y1=y2 is the maximum value of the facial vertex on the y-axis, and y3=y4 is the minimum value of the facial vertex on the y-axis. The width of the enclosing rectangular frame x2-x1 is expressed as w, y1-y3 is the height of the enclosing rectangular frame, expressed as h, and the facial center point (i.e., the center point of the enclosing frame) O is the intersection of the AD or BC lines.
[0057] The process of determining the outward-extending vertex on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex according to the size information of the enclosing rectangular box can be understood as: adding an outward-extending vertex on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex, so that the distance between the target vertex and the outward-extending vertex is w / n, or h / n, or max(w / n, h / n). Where n is an adjustable parameter and can take any value greater than 0, for example: n takes 5. For example, Figure 3 is an example diagram for determining the outward expansion vertex in this embodiment, such as Figure 3 As shown, O is the center point of the bounding box, E is one of the target vertices, and an additional outward expansion vertex E' is added on the extension line of the line connecting OE, where the length of EE' is w / n, or h / n, or max(w / n, h / n). In this embodiment, the outward expansion vertex is determined on the extension line of the line connecting the center point of the bounding rectangular box and the target vertex according to the size information of the bounding rectangular box, which can constrain the size of the outward expansion of the model.
[0058] In this embodiment, after obtaining multiple outward expansion vertices, a triangular mesh is constructed according to multiple target vertices and multiple outward expansion vertices. Figure 4 This is an example diagram of the outward expansion grid constructed in this embodiment, such as Figure 4 As shown, multiple target vertices and multiple outward expansion vertices are connected into lines according to certain regulations, and every three lines form a triangular mesh. Finally, the outward expansion mesh and the transformed 3D mesh model form an outward expansion 3D mesh model, that is, an outward expansion 3D model. In this embodiment, by performing outward expansion processing on the transformed 3D model, the problem of unnatural transition between the face and the background can be solved.
[0059] S140: determining a displacement image according to the expanded 3D model and the initial 3D model.
[0060] The displacement image is used to represent the displacement information between the vertices of the expanded 3D model and the initial 3D model.
[0061] Optionally, the process of determining the displacement image according to the expanded 3D model and the initial 3D model may be: determining displacement information of each vertex according to the expanded 3D model and the initial 3D model; and generating the displacement image based on the displacement information.
[0062] In this embodiment, the position coordinates of the 3D vertices of the expanded 3D model are subtracted from the position coordinates of the corresponding 3D vertices in the initial 3D model to obtain the displacement information of the 3D vertices, which is expressed as T (Tx, Ty, Tz). The method of generating a displacement image based on the displacement information may be: taking the (Tx, Ty) value and rendering it into the image to obtain the displacement image. Among them, the displacement image may be a four-channel image, or an RGBA four-channel image. The method of taking the (Tx, Ty) value and rendering it into a four-channel image may be: taking the Tx value and rounding it by 255 as the R channel value, multiplying the remainder after multiplying the Tx value by 255 by 255 as the G channel value, multiplying the Ty value and rounding it by 255 as the B channel value, and multiplying the remainder after multiplying the Ty value by 255 by 255 as the A channel value. Alternatively, the Tx value is taken as the R channel value, the Ty value is taken as the G channel value, and the values of the B channel and the A channel are set to 0.
[0063] In this embodiment, since the expanded 3D model has more expanded grids than the initial 3D model, the displacement information of the expanded vertices can be determined as (0, 0). In this embodiment, the displacement image is generated based on the displacement information of the 3D vertices, which can improve the accuracy of the displacement image generation.
[0064] S150, transforming the original facial image according to the displacement image to obtain a target facial image.
[0065] Among them, the pixels in the original facial image and the pixels in the displacement image correspond one to one, and the pixel value of each pixel in the displacement image represents the displacement information of the corresponding pixel in the original facial image. In this embodiment, the process of transforming the original facial image according to the displacement image to obtain the target facial image may be: obtaining the initial coordinates of the pixel in the original facial image and the corresponding displacement information in the displacement image; determining the transformation coordinates according to the initial coordinates and the displacement information; rendering the pixel value of the pixel to the position corresponding to the transformation coordinate to obtain the target facial image.
[0066] Among them, the method of determining the transformation coordinates according to the initial coordinates and the displacement information can be: accumulating the initial coordinates and the displacement information to obtain the transformation coordinates. For example: assuming that the initial coordinates are (x, y) and the displacement information is (Tx, Ty), the transformation coordinates are (x+Tx, y+Ty). Specifically, the process of rendering the pixel value of the pixel point to the position corresponding to the transformation coordinates can be: first creating an empty texture with the same size as the original facial image, and then rendering the pixel value of the pixel point in the original facial image to the position corresponding to the transformation coordinates in the empty texture, thereby obtaining the target facial image. Alternatively, the initial coordinates corresponding to the pixel point in the original facial image are determined according to the position coordinates of the pixel point in the empty texture and the displacement information in the displacement image, and then the pixel value of the pixel point in the initial coordinates is rendered to the position of the pixel point in the empty texture. In this embodiment, the pixel value of the pixel point is rendered to the position corresponding to the transformation coordinates, so that the original facial image can be accurately transformed.
[0067] In this embodiment, since the 3D model has boundaries and the intersections of the model patches are relatively sharp, the displacement information of adjacent pixels in the obtained displacement image has jumps. Therefore, it is necessary to perform fuzzy processing on the displacement image.
[0068] Optionally, the original facial image is transformed according to the displacement image to obtain the target facial image by: blurring the displacement image; and transforming the original facial image according to the blurred displacement image to obtain the target facial image.
[0069] The method of blurring the displacement image may be: calling any blurring algorithm to process the displacement image. Specifically, the method of blurring the displacement image may be: determining a blurring radius; and blurring the displacement image based on the blurring radius.
[0070] The blur radius can be determined according to the size of the enclosing rectangular frame of the facial image or set by the user. For example, the blur radius can be set to a set value, or w / m, or h / m, or max(w / m, h / m), etc., where m is an adjustable parameter and can take any value greater than 0. In this embodiment, the way to blur the displacement image can be: blur the entire image, or use different blur radii to blur different areas.
[0071] In this embodiment, the blur radius may be determined by dividing the displacement image into a facial area and a background area; determining the blur radius of the facial area as a first blur radius; and determining the blur radius of the background area as a second blur radius.
[0072] The second blur radius is greater than the first blur radius. The first blur radius may be a set value, or w / m, or h / m, or max(w / m, h / m), etc. In this embodiment, the displacement image may be divided into a facial area and a background area in such a manner that an area composed of pixels whose distance from the facial center point is less than a set value is determined as the facial area, and an area composed of pixels whose distance from the facial center point is greater than or equal to the set value is determined as the background area.
[0073] The second blur radius varies with the distance between the pixel point in the background area and the center point of the face, that is, the second blur radius increases with the increase of the distance between the pixel point and the center point of the face. Exemplarily, assuming that the blur radius of the face area is set to A, the blur radius in the background area increases from A as the distance between the pixel point and the center point of the face increases. In this embodiment, different blur radii are used for blurring the face area and the background area, which can solve the angular problem caused by the intersection of the face area patches to the greatest extent.
[0074] In this embodiment, after blurring the displacement image, the original facial image is transformed according to the blurred displacement image to obtain a target facial image, so that the obtained target facial image avoids corner and boundary sharpness problems.
[0075] The technical solution of the disclosed embodiment is to perform three-dimensional reconstruction on the original facial image to obtain an initial 3D model; transform the initial 3D model according to preset transformation information to obtain a transformed 3D model; perform outward expansion processing on the transformed 3D model to obtain an outward expanded 3D model; determine a displacement image according to the outward expanded 3D model and the initial 3D model; and perform transformation processing on the original facial image according to the displacement image to obtain a target facial image. The image processing method provided by the disclosed embodiment can solve the problem of unnatural transition between the face and the background by performing outward expansion processing on the transformed 3D model, and can solve the problem of sharp model boundaries and angular problems caused by the intersection of model face pieces by transforming the original facial image through the displacement image, so that the facial image after transformation processing is more realistic and natural, thereby improving the display effect of the image.
[0076] Figure 5 A schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the device comprises:
[0077] An initial 3D model acquisition module 410 is used to perform three-dimensional reconstruction on the original facial image to obtain an initial 3D model;
[0078] A transformed 3D model acquisition module 420 is used to transform the initial 3D model according to preset transformation information to obtain a transformed 3D model;
[0079] An externally expanded 3D model acquisition module 430 is used to perform external expansion processing on the transformed 3D model to obtain an externally expanded 3D model;
[0080] A displacement image determination module 440, configured to determine a displacement image according to the expanded 3D model and the initial 3D model;
[0081] The target facial image acquisition module 450 is used to transform the original facial image according to the displacement image to obtain the target facial image.
[0082] Optionally, the transformation 3D module acquisition module 420 is further used for:
[0083] Generate a transformation matrix according to preset transformation information;
[0084] The initial 3D model is transformed based on the transformation matrix to obtain a transformed 3D model.
[0085] Optionally, the external 3D model acquisition module 430 is further used to:
[0086] Select multiple target vertices from the transformed 3D model;
[0087] Determine the outward expansion vertices corresponding to the multiple target vertices respectively, and obtain the multiple outward expansion vertices;
[0088] Construct a triangular mesh according to multiple target vertices and multiple external expansion vertices to obtain an external expansion mesh;
[0089] The expanded mesh and the transformed 3D model are combined into an expanded 3D model.
[0090] Optionally, the external 3D model acquisition module 430 is further used to:
[0091] Get the bounding rectangle of the transformed 3D model;
[0092] The outward-expanding vertex is determined on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex according to the size information of the enclosing rectangular box; wherein the size information of the enclosing rectangular box includes width and / or height.
[0093] Optionally, the displacement image determination module 440 is further used to:
[0094] Determine the displacement information of each vertex according to the expanded 3D model and the initial 3D model;
[0095] A displacement image is generated based on the displacement information.
[0096] Optionally, the target facial image acquisition module 450 is further used to:
[0097] Blurring the displacement image;
[0098] The original facial image is transformed according to the displacement image after blurring to obtain the target facial image.
[0099] Optionally, the target facial image acquisition module 450 is further used to:
[0100] Determine the blur radius;
[0101] Blurs the displaced image based on the blur radius.
[0102] Optionally, the target facial image acquisition module 450 is further used to:
[0103] Divide the displacement image into a facial region and a background region;
[0104] Determine a blur radius of the facial area as a first blur radius;
[0105] The blur radius of the background area is determined as a second blur radius; wherein the second blur radius is greater than the first blur radius.
[0106] Optionally, the second blur radius varies with the distance between the pixel point in the background area and the center point of the face.
[0107] Optionally, the target facial image acquisition module 450 is further used to:
[0108] Obtaining the initial coordinates of the pixel points in the original facial image and the corresponding displacement information in the displacement image;
[0109] Determine the transformation coordinates according to the initial coordinates and the displacement information;
[0110] Render the pixel value of the pixel point to the position corresponding to the transformed coordinates to obtain the target facial image.
[0111] The image processing device provided in the embodiments of the present disclosure can execute the image processing method provided in any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0112] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0113] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6 , which shows an electronic device (eg, Figure 6The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0114] like Figure 6 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.
[0115] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0116] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0117] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0118] The electronic device provided by the embodiment of the present disclosure and the image processing method provided by the above embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0119] The embodiments of the present disclosure provide a computer storage medium on which a computer program is stored. When the program is executed by a processor, the image processing method provided by the above embodiments is implemented.
[0120] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0121] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0122] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0123] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0124] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: performs three-dimensional reconstruction on the original facial image to obtain an initial 3D model; transforms the initial 3D model according to preset transformation information to obtain a transformed 3D model; performs outward expansion processing on the transformed 3D model to obtain an outward expanded 3D model; determines a displacement image according to the outward expanded 3D model and the initial 3D model; and transforms the original facial image according to the displacement image to obtain a target facial image.
[0125] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0126] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0127] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0128] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0129] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0130] According to one or more embodiments of the present disclosure, there is provided an image processing method, comprising:
[0131] Perform three-dimensional reconstruction on the original facial image to obtain an initial 3D model;
[0132] Transform the initial 3D model according to preset transformation information to obtain a transformed 3D model;
[0133] Performing an outward expansion process on the transformed 3D model to obtain an outward expanded 3D model;
[0134] Determine a displacement image according to the expanded 3D model and the initial 3D model;
[0135] The original facial image is transformed according to the displacement image to obtain a target facial image.
[0136] Further, transforming the initial 3D model according to preset transformation information to obtain a transformed 3D model includes:
[0137] Generate a transformation matrix according to preset transformation information;
[0138] The initial 3D model is transformed based on the transformation matrix to obtain a transformed 3D model.
[0139] Further, the transformed 3D model is expanded to obtain the expanded 3D model, including:
[0140] Selecting a plurality of target vertices from the transformed 3D model;
[0141] Determine the outward expansion vertices corresponding to the multiple target vertices respectively, to obtain multiple outward expansion vertices;
[0142] Constructing a triangular mesh according to the plurality of target vertices and the plurality of outward-expanding vertices to obtain an outward-expanding mesh;
[0143] The outward-expanded mesh and the transformed 3D model are combined into an outward-expanded 3D model.
[0144] Further, determining the outward expansion vertices corresponding to the multiple target vertices respectively includes:
[0145] Obtaining a bounding rectangular frame of the transformed 3D model;
[0146] The outward-expanding vertex is determined on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex according to the size information of the enclosing rectangular box; wherein the size information of the enclosing rectangular box includes width and / or height.
[0147] Further, determining a displacement image according to the expanded 3D model and the initial 3D model includes:
[0148] Determining displacement information of each vertex according to the expanded 3D model and the initial 3D model;
[0149] A displacement image is generated based on the displacement information.
[0150] Further, transforming the original facial image according to the displacement image to obtain a target facial image includes:
[0151] Performing blur processing on the displacement image;
[0152] The original facial image is transformed according to the blurred displacement image to obtain a target facial image.
[0153] Further, blurring the displacement image includes:
[0154] Determine the blur radius;
[0155] The displacement image is blurred based on the blur radius.
[0156] Furthermore, the blur radius is determined, including:
[0157] dividing the displacement image into a facial region and a background region;
[0158] Determine the blur radius of the facial area as a first blur radius;
[0159] The blur radius of the background area is determined as a second blur radius; wherein the second blur radius is greater than the first blur radius.
[0160] Furthermore, the second blur radius varies with the distance between the pixel point in the background area and the facial center point.
[0161] Further, transforming the original facial image according to the displacement image to obtain a target facial image includes:
[0162] Obtaining initial coordinates of pixel points in the original facial image and corresponding displacement information in the displacement image;
[0163] Determine the transformed coordinates according to the initial coordinates and the displacement information;
[0164] The pixel value of the pixel point is rendered to the position corresponding to the transformed coordinate to obtain a target facial image.
[0165] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0166] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0167] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. An image processing method, characterized in that: include: Perform three-dimensional reconstruction on the original facial image to obtain an initial 3D model; Transform the initial 3D model according to preset transformation information to obtain a transformed 3D model; Performing an outward expansion process on the transformed 3D model to obtain an outward expanded 3D model; Determine a displacement image according to the expanded 3D model and the initial 3D model; Performing transformation processing on the original facial image according to the displacement image to obtain a target facial image; The step of transforming the original facial image according to the displacement image to obtain a target facial image includes: Determine the blur radius; Performing blur processing on the displacement image based on the blur radius; Transform the original facial image according to the displacement image after blur processing to obtain a target facial image; The determining of the blur radius includes: dividing the displacement image into a face area and a background area; determining the blur radius of the face area as a first blur radius; and determining the blur radius of the background area as a second blur radius.
2. The method according to claim 1, characterized in that The initial 3D model is transformed according to preset transformation information to obtain a transformed 3D model, including: Generate a transformation matrix according to preset transformation information; The initial 3D model is transformed based on the transformation matrix to obtain a transformed 3D model.
3. The method according to claim 1, characterized in that Performing an outward expansion process on the transformed 3D model to obtain an outward expanded 3D model includes: Selecting a plurality of target vertices from the transformed 3D model; Determine the outward expansion vertices corresponding to the multiple target vertices respectively, to obtain multiple outward expansion vertices; Constructing a triangular mesh according to the plurality of target vertices and the plurality of outward-expanding vertices to obtain an outward-expanding mesh; The outward-expanded mesh and the transformed 3D model are combined into an outward-expanded 3D model.
4. The method according to claim 3, characterized in that Determining the outward expansion vertices corresponding to the multiple target vertices respectively includes: Obtaining a bounding rectangular frame of the transformed 3D model; The outward-expanding vertex is determined on the extension line of the line connecting the center point of the enclosing rectangular box and the target vertex according to the size information of the enclosing rectangular box; wherein the size information of the enclosing rectangular box includes width and / or height.
5. The method according to claim 1, characterized in that: Determining a displacement image according to the expanded 3D model and the initial 3D model includes: Determining displacement information of each vertex according to the expanded 3D model and the initial 3D model; A displacement image is generated based on the displacement information.
6. The method according to claim 1, characterized in that in, The second blur radius is greater than the first blur radius.
7. The method according to claim 6, characterized in that The second blur radius varies with the distance between the pixel point in the background area and the center point of the face.
8. The method according to claim 1, characterized in that The original facial image is transformed according to the displacement image to obtain a target facial image, including: Obtaining initial coordinates of pixel points in the original facial image and corresponding displacement information in the displacement image; Determine the transformed coordinates according to the initial coordinates and the displacement information; The pixel value of the pixel point is rendered to the position corresponding to the transformed coordinate to obtain a target facial image.
9. An image processing device, characterized in that: include: An initial 3D model acquisition module is used to perform three-dimensional reconstruction of the original facial image to obtain an initial 3D model; A transformed 3D model acquisition module, used to transform the initial 3D model according to preset transformation information to obtain a transformed 3D model; An externally expanded 3D model acquisition module, used to perform external expansion processing on the transformed 3D model to obtain an externally expanded 3D model; A displacement image determination module, configured to determine a displacement image according to the expanded 3D model and the initial 3D model; A target facial image acquisition module, used for transforming the original facial image according to the displacement image to obtain a target facial image; The target facial image acquisition module is specifically used for: Determine the blur radius; Performing blur processing on the displacement image based on the blur radius; Transform the original facial image according to the displacement image after blur processing to obtain a target facial image; The target facial image acquisition module is further specifically used for: The displacement image is divided into a facial area and a background area; a blur radius of the facial area is determined as a first blur radius; and a blur radius of the background area is determined as a second blur radius.
10. An electronic device, characterized in that: The electronic device includes: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any one of claims 1 to 8.
11. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the image processing method according to any one of claims 1 to 8 when executed by a computer processor.
Citation Information
Patent Citations
Image augmentation for analytics
US20210390789A1