Digital human image generation method, apparatus and device, and readable storage medium
Through cropping and fusion technology, the distortion problem of the SadTalker algorithm when generating digital human images is solved, the high quality and natural movement of digital human images are achieved, and the user's visual effects and interactive experience are improved.
Patent Information
- Application Number
- CN202410873148.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-18
AI Technical Summary
When the SadTalker algorithm generates a digital human image, if the input image includes many other parts except the human head area, it will cause distortion of the digital human head and body, resulting in image distortion, and it cannot effectively decouple the generation of digital human images containing head movements and facial movements. .
By determining the area of interest in the digital human image (such as the hair area), crop it into the first image, and generate a second image based on its head motion coefficient-driven processing, and then linearly fuse the second image with the original image to generate a match The digital human image solves the problem of image distortion and improves the quality and naturalness of the digital human image.
It achieves a smooth transition of the fusion boundary between the hair area and the background area in the generated digital human image when other parts except the human head area exist in the input image. The head movement of the digital human is natural, which improves the quality and naturalness of the digital human image. sex.
Smart Images

Figure CN118799440A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, equipment and readable storage medium for generating a digital human image. Background Art
[0002] With the rapid iterative development of digital human technology, it is now possible to simulate the head posture and facial expression of a digital human that matches the text or audio input through a machine learning model based on the original image that describes the initial expression state of the digital human, so that the digital human can express naturally based on the text or audio input. Among them, the SadTalker algorithm, as an open source technology, drives the head and facial deformation of the digital human in the original image through 3DMM (3D Morphable Model) based on the head motion coefficient corresponding to the input audio, and generates a matching digital human image.
[0003] However, the SadTalker algorithm has certain limitations in practical applications. Since the algorithm drives all pixels of the input image when generating a matching digital human image, when the input image includes a large number of images other than the head area (such as a full-body image of a digital human), the head and body of the digital human in the generated matching digital human image will be significantly distorted, resulting in a distorted digital human image. Summary of the invention
[0004] In view of this, in order to solve the above technical problems, the present application provides a method, device, equipment and readable storage medium for generating a digital human image.
[0005] Specifically, the present application is implemented through the following technical solutions:
[0006] According to a first aspect of an embodiment of the present application, a method for generating a digital human image is provided, the method comprising:
[0007] Determine an area of interest in the original image of the digital person; the area of interest includes a first hair area of the digital person;
[0008] Cropping the region of interest in the original image to obtain a first image;
[0009] According to the head motion coefficient of the digital human in the first image, driving processing is performed on the head posture and facial expression of the digital human in the first image to generate a second image;
[0010] The second image is fused with the original image according to the position information of the first image on the original image to generate a digital human image corresponding to the original image.
[0011] Optionally, determining the region of interest in the original image of the digital human includes:
[0012] Determine a first hair region of the digital human in the original image of the digital human, and obtain position information of boundaries of the first hair region in horizontal and vertical directions;
[0013] Obtaining the center coordinates of the first hair area according to the position information of the boundary;
[0014] The region of interest is determined according to the central coordinates and the region widths of the first hair region in the horizontal direction and the vertical direction.
[0015] Optionally, determining the region of interest according to the central coordinates and the width of the first hair region in the horizontal direction and the vertical direction includes:
[0016] determining a horizontal side length of the region of interest according to a region width of the first hair region in a horizontal direction;
[0017] determining a vertical side length of the region of interest according to a region width of the first hair region in a vertical direction;
[0018] The region of interest is determined according to the horizontal side length and the vertical side length in combination with the center coordinates.
[0019] Optionally, determining the region of interest according to the horizontal side length and the vertical side length in combination with the center coordinates includes:
[0020] When the horizontal side length is greater than the width of the original image, or the vertical side length is greater than the height of the original image, adjusting the horizontal side length and the vertical side length according to the size of the original image;
[0021] The region of interest is determined according to the adjusted horizontal side length and vertical side length.
[0022] Optionally, the fusing the second image with the original image according to position information of the first image on the original image includes:
[0023] constructing a target mask image of the second image according to the second hair area and the key points of the face of the digital person on the second image; the target mask image is used to identify the head area and the non-head area;
[0024] Determining a fusion weight corresponding to each pixel point on the second image according to a pixel value of each pixel point on the target mask image;
[0025] The second image is linearly fused with the original image according to the fusion weight.
[0026] Optionally, before constructing the target mask image, the method further includes:
[0027] Acquire a first eye-mouth vector in the first image corresponding to the second image; the first eye-mouth vector is predetermined according to key point coordinate information of the mouth and eyes of the digital human;
[0028] Detecting facial key points of the digital person on the second image, and generating a second eye-mouth vector according to coordinate information of the mouth and eyes among the facial key points;
[0029] Determining a vector transformation parameter according to the first eye-mouth vector and the second eye-mouth vector;
[0030] determining a second hair vector of the second image according to a first hair vector of the digital human in the first image and the vector transformation parameter; the first hair vector is predetermined according to coordinate information of a hair top and a hair bottom of the first hair region in the first image;
[0031] A second hair region of the digital person on the second image is determined according to the second hair vector.
[0032] Optionally, the method further comprises the step of predetermining a first hair vector:
[0033] For the first hair region on the first image, in the horizontal direction, respectively obtain the coordinates of the lowest point on the left side and the lowest point on the right side of the hair bottom region, and use the average coordinates thereof as the hair bottom coordinates;
[0034] In the vertical direction, the coordinates of the top of the hair are determined according to the coordinates of each point in the top area of the hair;
[0035] The first hair vector is generated according to the hair bottom coordinates and the hair top coordinates.
[0036] Optionally, constructing a target mask image of the second image according to the second hair region and facial key points of the digital person in the second image includes:
[0037] Creating a blank image; wherein the pixels of the blank image correspond one-to-one to the pixels at corresponding positions on the second image;
[0038] Determine a head region and a non-head region on the blank image according to the second hair region and the facial key points on the second image;
[0039] Pixel values are set for the pixel points in the head area and the non-head area respectively to generate the target mask image.
[0040] Optionally, after generating the target mask image, the method further includes:
[0041] Detecting a pixel value mutation region in the target mask image;
[0042] Gaussian blur is applied to each pixel point in the pixel value mutation area for smoothing to obtain an updated target mask image.
[0043] Optionally, determining the fusion weight corresponding to each pixel point on the second image according to the pixel value of each pixel point on the target mask image includes:
[0044] For each pixel point on the target mask image, normalize the pixel value of the pixel point;
[0045] The normalized result is used as the fusion weight corresponding to the pixel points at the same pixel position on the second image.
[0046] Optionally, the linearly fusing the second image with the original image according to the fusion weight includes:
[0047] Obtain a second pixel value of each pixel point on the second image, and obtain a first pixel value of the same pixel position on the original image;
[0048] According to the fusion weight corresponding to each pixel point on the second image, the first pixel value and the second pixel value are linearly superimposed to obtain the digital human image.
[0049] Optionally, in the case where the original image of the digital human includes multiple frames of images of the original video, the method further includes a step of generating a target video of the digital human, including:
[0050] According to the inter-frame sequence of multiple frames of images in the original video, the digital human image corresponding to each original image is combined according to the inter-frame sequence to generate a first video;
[0051] The input driving voice data is synchronized with the first video to generate a digital human target video matching the driving voice data.
[0052] According to a second aspect of an embodiment of the present application, a digital human image generating device is provided, the device comprising:
[0053] An area of interest determination module, used to determine an area of interest in the original image of the digital human; the area of interest includes a first hair area of the digital human;
[0054] A first image acquisition module, used for cropping the region of interest in the original image to obtain a first image;
[0055] A driving processing module, configured to drive and process the head posture and facial expression of the digital human in the first image according to the head motion coefficient of the digital human in the first image, so as to generate a second image;
[0056] The digital human image generation module is used to fuse the second image with the original image according to the position information of the first image on the original image, so as to generate a digital human image corresponding to the original image.
[0057] Optionally, the region of interest determination module is specifically used to:
[0058] A boundary position information acquisition module, used to determine a first hair region of the digital human in the original image of the digital human, and to acquire position information of the boundaries of the first hair region in the horizontal and vertical directions;
[0059] a center coordinate determination module, configured to obtain the center coordinates of the first hair region according to the position information of the boundary;
[0060] The determination module is used to determine the region of interest according to the central coordinates and the region width of the first hair region in the horizontal direction and the vertical direction.
[0061] Optionally, the region of interest determination module is specifically used to:
[0062] determining a horizontal side length of the region of interest according to a region width of the first hair region in a horizontal direction;
[0063] determining a vertical side length of the region of interest according to a region width of the first hair region in a vertical direction;
[0064] The region of interest is determined according to the horizontal side length and the vertical side length in combination with the center coordinates.
[0065] Optionally, the region of interest determination module is used to determine the region of interest according to the horizontal side length and the vertical side length in combination with the center coordinates, including:
[0066] When the horizontal side length is greater than the width of the original image, or the vertical side length is greater than the height of the original image, adjusting the horizontal side length and the vertical side length according to the size of the original image;
[0067] The region of interest is determined according to the adjusted horizontal side length and vertical side length.
[0068] Optionally, the digital human image generation module includes:
[0069] A target mask image construction module is used to construct a target mask image of the second image according to the second hair area and the key points of the face of the digital person on the second image; the target mask image is used to identify the head area and the non-head area;
[0070] A fusion weight determination module, used to determine the fusion weight corresponding to each pixel point on the second image according to the pixel value of each pixel point on the target mask image;
[0071] An image fusion module is used to linearly fuse the second image with the original image according to the fusion weight.
[0072] Optionally, before constructing the target mask image, the device further includes:
[0073] A first eye-mouth vector acquisition module, used to acquire a first eye-mouth vector in the first image corresponding to the second image; the first eye-mouth vector is predetermined according to the key point coordinate information of the mouth and eyes of the digital human;
[0074] A second eye-mouth vector acquisition module is used to detect the facial key points of the digital human on the second image, and generate a second eye-mouth vector according to the coordinate information of the mouth and eye key points among the facial key points;
[0075] a vector transformation parameter determination module, used to determine a vector transformation parameter according to the first eye-mouth vector and the second eye-mouth vector;
[0076] A second hair vector determination module, used to determine a second hair vector of the second image according to the first hair vector of the digital human in the first image and the vector transformation parameter; the first hair vector is predetermined according to the coordinate information of the hair top and the hair bottom of the first hair region in the first image;
[0077] The second hair region determining module is used to determine a second hair region of the digital person on the second image according to the second hair vector.
[0078] Optionally, the device further comprises a first hair vector predetermining module, specifically configured to:
[0079] For the first hair region on the first image, in the horizontal direction, respectively obtain the coordinates of the lowest point on the left side and the lowest point on the right side of the hair bottom region, and use the average coordinates thereof as the hair bottom coordinates;
[0080] In the vertical direction, the coordinates of the top of the hair are determined according to the coordinates of each point in the top area of the hair;
[0081] The first hair vector is generated according to the hair bottom coordinates and the hair top coordinates.
[0082] Optionally, the target mask image construction module is specifically used to:
[0083] Creating a blank image; wherein the pixels of the blank image correspond one-to-one to the pixels at corresponding positions on the second image;
[0084] Determine a head region and a non-head region on the blank image according to the second hair region and the facial key points on the second image;
[0085] Pixel values are set for the pixel points in the head area and the non-head area respectively to generate the target mask image.
[0086] Optionally, after generating the target mask image, the device further includes:
[0087] Detecting a pixel value mutation region in the target mask image;
[0088] Gaussian blur is applied to each pixel point in the pixel value mutation area for smoothing to obtain an updated target mask image.
[0089] Optionally, the fusion weight determination module is specifically used to:
[0090] For each pixel point on the target mask image, normalize the pixel value of the pixel point;
[0091] The normalized result is used as the fusion weight corresponding to the pixel points at the same pixel position on the second image.
[0092] Optionally, the image fusion module is specifically used for:
[0093] Obtain a second pixel value of each pixel point on the second image, and obtain a first pixel value of the same pixel position on the original image;
[0094] According to the fusion weight corresponding to each pixel point on the second image, the first pixel value and the second pixel value are linearly superimposed to obtain the digital human image.
[0095] Optionally, in the case where the original image of the digital human includes multiple frames of images of an original video, the device further comprises:
[0096] A first video generation module, configured to combine the digital human image corresponding to each original image according to the inter-frame sequence of multiple frames of images in the original video according to the inter-frame sequence to generate a first video;
[0097] The audio synchronization module is used to synchronize the input driving voice data with the first video to generate a digital human target video matching the driving voice data.
[0098] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a memory and a processor; the memory is used to store a computer program; the processor is used to execute the above-mentioned digital human image generation method by calling the computer program.
[0099] According to a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned digital human image generation method is implemented.
[0100] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0101] In the technical solution provided by the present application, an area of interest image including the head area for driving processing is determined through the hair area of the digital human in the input original image, which is then cropped into a first image to generate a digital human image including the head motion that matches the digital human head motion coefficient, and the digital human image is re-fused into the input original image, thereby solving the image distortion problem caused when the input image includes a large number of images other than the head area, and making the fusion boundary transition between the hair area and the background area in the generated digital human image smooth, and the head movement of the digital human is natural, thereby improving the quality of the digital human image as well as the naturalness and realism of the digital human. BRIEF DESCRIPTION OF THE DRAWINGS
[0102] Figure 1A is a schematic diagram of a digital human driving image distortion in a related technology shown in an exemplary embodiment of the present application;
[0103] Figure 1B is a schematic diagram of image distortion driven by a digital human in another related technology shown in an exemplary embodiment of the present application;
[0104] Figure 2A is a flow chart of a method for generating a digital human image shown in an exemplary embodiment of the present application;
[0105] Figure 2B is a schematic diagram of a hair region of a digital person in an original image shown in an exemplary embodiment of the present application;
[0106] Figure 2C is a schematic diagram of an image fusion situation shown in an exemplary embodiment of the present application;
[0107] Figure 3 is a flowchart of a step of determining a region of interest from an original image, shown in an exemplary embodiment of the present application;
[0108] Figure 4A is a schematic diagram showing a fusion boundary transition rigidity according to an exemplary embodiment of the present application;
[0109] Figure 4B is a flowchart of steps for fusing a second image with an original image based on a mask image, shown in an exemplary embodiment of the present application;
[0110] Figure 4C is a schematic diagram for comparing fusion results under different image fusion modes shown in an exemplary embodiment of the present application;
[0111] Figure 5 is a flow chart showing a step of determining a hair area of a digital person on a second image according to an exemplary embodiment of the present application;
[0112] Figure 6 is a flowchart of a step of predetermining a first hair vector of a digital person on a first image, shown in an exemplary embodiment of the present application;
[0113] Fig. 7A is a flow chart of target mask image pre-construction steps shown in an exemplary embodiment of the present application;
[0114] Figure 7B is a target mask image for identifying a head area and a non-head area shown in an exemplary embodiment of the present application;
[0115] Figure 8 is a flowchart of an image fusion step for fusing a second image with the original image, shown in an exemplary embodiment of the present application;
[0116] Fig. 9 is an overall block diagram of a method for generating a digital human image as shown in an exemplary embodiment of the present application;
[0117] Fig.10 is a structural schematic diagram of a digital human image generation device shown in an exemplary embodiment of the present application;
[0118] Fig.11 It is a hardware schematic diagram of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0119] With the rapid iterative development of digital human technology, it is now possible to use machine learning models to simulate the head posture and facial expressions of digital humans that match text or audio inputs based on original images that describe the initial expression state of the digital humans, enabling digital humans to express and move naturally based on text or audio inputs, bringing convenience to the fields of intelligent question-and-answer interactive digital humans in the live broadcast industry, e-commerce industry, and other industries.
[0120] When generating a matching digital human image based on input audio, a commonly used implementation method is the open source SadTalker algorithm. For the input audio, the SadTalker algorithm first uses the mapping network to generate the corresponding t-frame 3DMM head motion coefficients, including head posture coefficients and facial expression coefficients, and then obtains the original image of the digital human, and uses the head motion coefficients corresponding to the original image to drive the head and facial deformation of the digital human in the original image, thereby generating a matching digital human image.
[0121] The image preprocessing stage of the SadTalker algorithm includes three processing modes: cropping mode, deformation mode, and full-body mode. In the cropping mode and deformation mode, the algorithm requires that the input original image is at most a half-length portrait. When the input original image exceeds the algorithm limit, the generated matching digital human image will have obvious face and body distortion, such as Figure 1A As shown in the figure, the input original image is larger than the half-length portrait, and the face and body of the corresponding output digital human image are distorted. Because the input original image area in the "deformation" mode is larger than the input original image area in the "crop" mode, when the digital human's head moves too much in the deformation mode, the face and neck are easily distorted. Figure 1B The distortion diagram shown in the figure shows that the neck and facial contour of the digital human are obviously distorted compared to the original image. In contrast, the full-body mode supports the input of full-body portraits as the original image. However, due to algorithm limitations, the digital human image output in this mode will use a static head model, which can only achieve the correct change of the mouth shape but not the change of the head posture, resulting in the lack of naturalness and realism of the head movement of the generated digital human.
[0122] It can be seen that the SadTalker algorithm has corresponding limitations in practical applications and cannot decouple the generation of digital human images that include head and facial movements. When the input image includes a large number of images other than the head area (such as a full-body image of a digital human), when it is necessary to drive the head and face movements of the digital human in the original image at the same time, the head and body of the digital human in the generated digital human image will be significantly distorted, resulting in a distorted image of the generated digital human, which affects the user's visual effect and interactive experience.
[0123] It is understandable that the above description of the SadTalker algorithm and technical issues is only for the purpose of facilitating the understanding of the spirit and principle of the present application, and the applicable scenarios of the present application are not limited in this respect. On the contrary, the present application can be adapted and applied to any image processing process with the above limitations, including but not limited to the SadTalker algorithm.
[0124] In view of this, in order to solve the above technical problems, the present application provides a method for generating a digital human image, which determines an area of interest image including a head area for driving processing through the hair area of the digital human in the input original image, and then cuts it into a first image to generate a digital human image including head motion that matches the digital human head motion coefficient, and then re-integrates the digital human image into the input original image, thereby solving the image distortion problem caused when the input image includes a large number of images other than the head area, and making the fusion boundary transition between the hair area and the background area in the generated digital human image smooth, and the head movement of the digital human is natural, thereby improving the quality of the digital human image as well as the naturalness and realism of the digital human.
[0125] The digital human image generation method can be applied to various scenarios involving driving and generating digital human images, such as virtual digital human teaching, virtual live broadcast, etc., and can also be extended to any other applicable scenarios including but not limited to SadTalker algorithm to generate digital human images, and this application does not limit this. The digital human involved in the embodiments of this application includes a two-dimensional digital human, which may include but is not limited to a simulation type virtual digital human and a cartoon virtual digital human.
[0126] Next, combine Figure 2A-Figure 11 The digital human image generation method provided in the present application is described. The method can be executed by a terminal device or a server. The terminal device may include but is not limited to smart devices such as mobile phones, wireless handheld devices, tablet computers or personal computers, and the server may include but is not limited to edge servers, cloud servers and multi-server clusters.
[0127] See also Figure 2A The method for generating a digital human image is shown in the flowchart of steps, and the method may at least include the following steps:
[0128] S201, determining a region of interest in an original image of a digital person; the region of interest includes a first hair region of the digital person;
[0129] The original image of the digital human is used to provide the initial state of the head posture and facial expression of the digital human. The original image can be a static photo of the digital human, or each frame of an original video that is pre-recorded or generated and contains the image, movements and expressions of the digital human. Each frame of the original video includes the digital human.
[0130] The first hair region refers to a set of pixels representing the hair of the digital person in the original image, which is usually visually connected to the face and neck of the digital person and covers the head to form a specific pixel region, which is different from other elements in the image such as skin, clothing, background, etc. The first hair region can be obtained by detecting and identifying the original image using an open source detection algorithm, such as Canny edge detection, or by applying machine learning or deep learning models. Those skilled in the art should understand that the "first" in the first hair region is only used to distinguish the same type of information from the hair regions of the digital person on other images in this application, and has no specific indicative meaning.
[0131] like Figure 2B The schematic diagram of the first hair area on the original image shown is used to accurately locate the first hair area of the digital person in the original image by setting the non-hair area to black and the hair area to white.
[0132] The region of interest refers to the image region on the original image to be further processed. In this embodiment, the region of interest at least includes the first hair region of the digital person on the original image, that is, the range of the region of interest is greater than or equal to the range of the first hair region of the digital person.
[0133] Based on this, after determining the first hair region of the digital human in the original image, the region of interest can be determined by proportionally enlarging the pixel width and height of the first hair region, or by combining the position information of the key points of the digital human face in the original image, so that the region of interest includes the head region of the digital human and avoids too many unnecessary background features, such as the image background or the body parts of the digital human.
[0134] S202, cropping the region of interest in the original image to obtain a first image;
[0135] That is, for the region of interest on the original image, based on the position of the region of interest on the original image, a regional image corresponding to the region of interest is cropped from the original image as the first image. In the implementation process, the cropping function of an image processing library or framework, such as OpenCV (Open Source Computer Vision Library) or PIL (Python Imaging Library), can be used to ensure that the boundary of the region of interest is clear and complete.
[0136] S203, driving and processing the head posture and facial expression of the digital human in the first image according to the head motion coefficient of the digital human in the first image to generate a second image;
[0137] The digital human head motion coefficient includes the digital human head posture coefficient and facial expression coefficient, which are used to describe the head motion state of the digital human at a specific time point and speech content in the input driving voice data. The driving voice data is used to store the content that the digital human wants to speak, and may include a text-to-speech audio file or user-recorded audio.
[0138] During the SadTalker algorithm processing, the input driving voice data is aligned with at least one frame of original image of the digital human obtained in advance, so that each frame of the original image corresponds to the voice content at a specific time point in the driving voice data. Based on the fact that the first image is extracted from the original image, the head motion coefficient of the digital human of the first image can be generated by the mapping network for the specific time point and voice content in the driving voice data corresponding to the original image.
[0139] The second image is based on the initial state of the digital human head provided by the first image, and drives the head posture of the digital human in the first image to change according to the head posture coefficient, and drives the facial expression and lip shape of the digital human in the first image to change according to the facial expression coefficient, so as to generate an image matching the digital human head motion coefficient, and the driving of the head posture and facial expression of the digital human in the first image to change can be realized by SadTalker algorithm or other machine learning models. The second image corresponds to a specific time point and voice content in the driving voice data, and the head state and facial expression of the digital human presented in the image accurately match the head state of the digital human expressing the voice content at that specific time point.
[0140] S204: According to the position information of the first image on the original image, fuse the second image with the original image to generate a digital human image corresponding to the original image.
[0141] The above fusion of the second image with the original image refers to fusion of the second image with a partial image of the same area in the original image to update the pixels of the same area on the original image, and the same area refers to an area on the original image that matches the pixel area of the second image, that is, an image area corresponding to the first image on the original image. In this embodiment, the difference between the generated digital human image and the original image is that the first image area on the digital human image corresponding to the position information of the first image retains the pixel information of the second image, and the other image areas except the first image area retain the pixel information of the original image.
[0142] like Figure 2CThe image fusion situation shown is schematically shown. The image on the left is the original image. The rectangle ABCD in the image is the first image determined based on the region of interest on the original image. The second image is generated based on the first image through the digital human head motion coefficient. When the second image is fused with the original image, the second image is aligned pixel by pixel with the rectangle ABCD on the original image, and the second image is fused with the pixel area of the rectangle ABCD on the original image to generate a digital human image matching the digital human head motion coefficient. The digital human image includes a rectangle A'B'C'D' corresponding to the original image. The difference between the digital human image and the original image is that the pixels in the rectangle ABCD area are updated due to image fusion.
[0143] The image fusion of the second image and the original image can be achieved through a Poisson fusion method, or by directly replacing the first image on the original image with the second image and combining it with edge smoothing processing, or by another image fusion method based on a mask image provided in the present application. For the specific implementation process, please refer to the following embodiment.
[0144] In the disclosed embodiment, by extracting the first image containing the human head area from the input original image, and driving the head and face of the digital human in the first image, and then re-merging the processed second image back into the original image, a digital human image matching the digital human head motion coefficient is generated, avoiding the problem of digital human distortion when the digital human head and face are driven to move simultaneously on the input original image, thereby generating a more realistic and natural digital human image, improving the user's visual effect and interactive experience. In addition, by extracting the first image containing the human head area from the input original image, the digital human image driving process no longer depends on a specific input image type, thereby improving processing flexibility and processing efficiency.
[0145] In some embodiments, for the region of interest described in step S201 above, based on the fact that the region of interest includes the first hair region of the digital person in the original image, for step S201, see Figure 3 As shown in the flowchart, the region of interest can be determined by the following steps:
[0146] S301, determining a first hair region of the digital human in the original image of the digital human, and obtaining position information of boundaries of the first hair region in horizontal and vertical directions;
[0147] For the first hair area, it can be obtained by using an open source detection algorithm, such as Canny edge detection, or by applying machine learning or deep learning models, etc., to detect and identify the original image, and this application does not limit this.
[0148] The horizontal direction refers to the direction from the left side to the right side of the face of the digital person in the original image, which can correspond to the X-axis of the two-dimensional image coordinate system. The vertical direction is the direction from the chin to the top of the head of the digital person, which corresponds to the Y-axis of the two-dimensional image coordinate system.
[0149] The position information of the boundary in the horizontal direction refers to the leftmost boundary (minimum X coordinate value) and the rightmost boundary (maximum X coordinate value) of the first hair region in the horizontal direction, defining the range of the first hair region in the horizontal direction. Similarly, the position information of the boundary in the vertical direction refers to the lowest point (minimum Y coordinate value) and the highest point (maximum Y coordinate value) of the first hair region in the vertical direction, defining the range of the first hair region in the vertical direction. It can be understood that the "maximum" and "minimum" are defined according to the direction of the coordinate axis.
[0150] S302, obtaining the center coordinates of the first hair area according to the position information of the boundary;
[0151] According to the position information of the boundaries in the horizontal direction and the vertical direction, the spans of the hair area in the horizontal direction and the vertical direction can be determined, wherein the span value △X in the horizontal direction=the maximum value of the X coordinate-the minimum value of the X coordinate, and the span value △Y in the vertical direction=the maximum value of the Y coordinate-the minimum value of the Y coordinate.
[0152] According to the horizontal span value △X and the vertical span value △Y, combined with the position information of the boundary, the center coordinates of the first hair area can be determined. For example, the center coordinates can be based on and According to the minimum X coordinate min and the minimum Y coordinate min Calculated, the center coordinates can be expressed as
[0153] S303: Determine the region of interest according to the central coordinates and the width of the first hair region in the horizontal direction and the vertical direction.
[0154] The area width of the first hair area in the horizontal direction and the vertical direction is the span values △X and △Y of the first hair area in the horizontal direction and the vertical direction. When determining the region of interest according to the central coordinates, the central coordinates can be directly determined as the geometric center of the region of interest, and the set multiple values of the span values △X and △Y of the first hair area in the horizontal direction and the vertical direction are used as the side length of the region of interest, and the corresponding region of interest is obtained in combination with the geometric center of the region of interest.
[0155] Based on the fact that the hair area usually extends from the top of the head to around the neck, and the face is located below and in the center of the hair, and the center coordinates of the region of interest are determined based on the geometric center of the first hair area, the region of interest set with the center coordinates as the center can include the entire head area of the digital human, that is, including the hair area and face area of the digital human, so as to facilitate the subsequent driving of the head posture and facial expression changes of the digital human.
[0156] After obtaining the center coordinates of the first hair area, facial key points may be further detected on the original image, and the center coordinates of the first hair area may be adjusted based on the facial key points, so that the center coordinates can represent the geometric center of the entire head area of the digital human on the original image, and a more accurate region of interest may be obtained based on the adjusted center coordinates combined with the region width of the first hair area in the horizontal and vertical directions.
[0157] When determining the region of interest according to the center coordinates and the area widths of the first hair area in the horizontal direction and the vertical direction, the horizontal side length of the region of interest can be determined according to the area width of the first hair area in the horizontal direction, i.e., ΔX, and the vertical side length of the region of interest can be determined according to the area width of the first hair area in the vertical direction, i.e., ΔY. Then, the center coordinates are taken as the center of the region of interest, and the rectangular size of the region of interest is defined according to the horizontal side length and the vertical side length to determine the region of interest. When determining the horizontal side length and the vertical side length, a set multiple of ΔX and ΔY greater than 1 can be taken as the horizontal side length and the vertical side length, and the multiple values of ΔX and ΔY can be the same or different. For example, 1.2 times of Δx and Δy can be taken as the side length of the region of interest, or 1.2 times of Δx and 1.4 times of Δy can be taken as the side length of the region of interest.
[0158] In the disclosed embodiment, the boundary position information of the hair region in the horizontal and vertical directions in the original image is identified, and then the center coordinates of the hair region are calculated. Based on the center coordinates and the width of the hair region, a region of interest including the hair region is determined. Since the hair region usually extends from the top of the head to the neck, the region of interest set with the center coordinates of the hair region as the center can include the entire head region of the digital human, which provides accurate region positioning for the subsequent driving of the digital human's head posture and facial expression changes, reduces unnecessary background information, and reduces the probability of digital human distortion during the driving process.
[0159] In some embodiments, in the process of determining the region of interest according to the central coordinates and the region widths of the first hair region in the horizontal direction and the vertical direction, there may be a case where the determined region of interest exceeds the image boundary of the original image. In this case, after determining the horizontal side length and the vertical side length of the region of interest according to the region widths of the first hair region in the horizontal direction and the vertical direction, if there is any case where the horizontal side length is greater than the width of the original image or the vertical side length is greater than the height of the original image, the horizontal side length and the vertical side length may be adjusted according to the size of the original image, and the region of interest may be determined according to the adjusted horizontal side length and vertical side length.
[0160] That is, for the side length that exceeds the boundary of the original image, it can be reduced to within the original image size according to the image size of the original image. In order to maintain the original shape and proportion of the region of interest, the other side length can be reduced according to the same proportion.
[0161] In the embodiment of the present disclosure, in order to solve the problem of exceeding the boundaries of the original image when determining the region of interest, the horizontal and vertical lengths of the region of interest are adjusted according to the size of the original image so that the region of interest is completely within the original image, thereby avoiding data loss and processing errors caused by accessing non-existent pixel data, and at the same time maintaining the integrity of the image and preventing image distortion or stretching due to improper cropping.
[0162] In some embodiments, for the aforementioned step S204, the second image is fused with the original image according to the position information of the first image on the original image. Since the Poisson fusion algorithm is highly complex and requires large amounts of calculation, if the first image on the original image is directly replaced with the second image, the generated second image is regenerated based on the original image through a machine learning model, and the complex details of the digital human in the original image in terms of color, posture, lighting, texture, etc. cannot be fully reproduced. There may be a problem that the background color of the second image is inconsistent with the original image. Directly replacing it with the original image will result in obvious problems of stiff boundary transition and image fragmentation. For example, see Figure 4A The schematic diagram of the fusion boundary transition being stiff is shown as an example. The image on the left is a second image containing the head area of the digital human. When the second image is fused to the original image, there is a large color difference at the fusion boundary as shown by the arrow in the figure, resulting in an obvious boundary distinction (the contrast is enhanced for the display effect).
[0163] Therefore, in order to achieve a better image fusion effect and reduce the amount of calculation in the fusion process, this embodiment provides an image fusion method based on a mask image, see Figure 4BAs shown in the flowchart, the aforementioned step S204 can achieve image fusion through the following steps:
[0164] S401, constructing a target mask image of the second image according to a second hair region and facial key points of the digital person in the second image; the target mask image is used to identify a head region and a non-head region;
[0165] The second hair area of the digital human refers to the hair area presented by the digital human on the second image after the head posture and facial expression drive changes. The hair area can be determined by open source hair detection algorithm or other machine learning model detection, or can also be quickly determined by the vector transformation method provided in another embodiment of the present application. Please refer to the following embodiment for details.
[0166] The facial key points refer to a series of predefined points in the second image used to describe the facial features of the digital person, and are used to locate different feature areas such as the face contour, eyebrows, eyes, nose, mouth, etc. The facial key points can be obtained by performing facial key point detection on the second image through machine learning or deep learning algorithms.
[0167] The mask image is used to distinguish and process different areas in the image to specify areas that need to be retained or paid special attention to during the image processing process. In this embodiment, the target mask image is constructed according to the second hair area and facial key points of the digital human in the second image. Based on the hair area and facial key points on the second image, the head area and the non-head area can be accurately identified. The head area includes the hair area and the face area, so as to retain the head area information on the second image in the subsequent image fusion process, while retaining the non-head area information on the original image.
[0168] Based on this, different regional pixel values are set for the head area and non-head area in the target mask image, and the regional pixel values are used to characterize the contribution of the same regional pixel points on the second image during the image fusion process. In order to correctly retain the head area information on the second image during the fusion process, the pixel value of the head area is set to be significantly higher than the pixel value of the non-head area. The pixel value setting of the target mask image can be achieved by grayscale mask images, three-channel mask images, etc., so as to correctly distinguish the head area and reasonably allocate weights during the fusion process.
[0169] S402, determining a fusion weight corresponding to each pixel point on the second image according to the pixel value of each pixel point on the target mask image;
[0170] The pixel values of the pixels on the target mask image are used to represent the contribution of the pixels in the corresponding area on the second image to the image fusion. Therefore, the pixel value of each pixel in the target mask image can be used as a basis. By mapping the pixel value of the pixel to the interval [0,1], a fusion weight is assigned to each pixel on the second image in turn. The fusion weight is used to represent the contribution of the second image at the pixel position to the fused image.
[0171] In the process of assigning a fusion weight to each pixel on the second image, if the constructed target mask image has the same image size and resolution as the second image, then for each pixel on the target mask image, a unique corresponding pixel can be found at the same pixel position on the second image. In this case, the fusion weight corresponding to the pixel at the same pixel position on the second image can be determined based on the pixel value of the pixel on the target mask image.
[0172] If the image size and resolution of the target mask image are different from those of the second image, and the target mask image of the second image does not satisfy a one-to-one correspondence with the pixels of the second image, the target mask image needs to be adjusted. Bilinear interpolation can be used to adjust the size and resolution of the target mask image to match the second image, and an updated target mask image is generated to determine the fusion weight corresponding to each pixel in the second image based on the updated target mask image.
[0173] Among them, bilinear interpolation is a method for calculating interpolated pixel values in two-dimensional space. The interpolated pixel value of the target pixel is calculated by considering the pixel values of the four nearest neighbor pixels around the target pixel and the horizontal and vertical distances between the four nearest neighbor pixels and the target pixel, thereby generating a smooth scaled image and avoiding the jagged edges that may be caused by nearest neighbor interpolation.
[0174] For example, the centroid coordinates of the target pixel relative to the four nearest neighboring pixels can be expressed as (u, v), which is used to describe the relative position of the target pixel relative to the four nearest neighboring pixels. Assuming that the coordinates of the four nearest neighboring pixels are (i, j), (i+1, j), (i, j+1), (i+1, j+1), the coordinates of the target pixel can be expressed as (i+u, j+v), and the pixel value f obtained by bilinear interpolation can be expressed as:
[0175] f(i+u,j+v)=(1-u)(1-v)f(i,j)+(1-u)vf(i,j+1)
[0176] +u(1-v)f(i+1,j)+uvf(i+1,j+1)
[0177] S403: linearly fuse the second image with the original image according to the fusion weight to generate a digital human image corresponding to the original image.
[0178] Since the fusion weight is set for each pixel on the second image, each pixel can be processed independently during the image fusion process. Specifically, according to the fusion weight corresponding to each pixel on the second image, each pixel on the second image can be traversed, and the pixel value of the pixel on the second image and the pixel at the same pixel position on the corresponding original image can be linearly superimposed to obtain the pixel value of the pixel on the fused image.
[0179] This linear superposition is essentially a weighted calculation, that is, by multiplying the pixel values of the same pixel points on the second image and the original image by their respective fusion weights and adding the two results, the new pixel value of the fused pixel point can be obtained. If the weight of a pixel point on the second image is high, the fused pixel value will be closer to the pixel value of the point on the second image, and vice versa, the fused pixel value will be closer to the pixel value of the pixel point on the original image.
[0180] By fusing each generated second image with its corresponding original image in the above manner, the head movement state of the digital human contained in the second image can be effectively and accurately fused to the original image while maintaining the background and other information of the original image, ensuring a smooth and natural transition of the fused image, so that the head movement state of the digital human after the drive processing is perfectly integrated with the original image, presenting a realistic visual effect. Figure 4C As shown in the schematic diagram for comparing fusion results, the image on the left is a digital human image generated by fusion using a traditional method (the contrast is enhanced for display effect), and the image on the right is a digital human image generated by fusion using the method provided in this embodiment. Compared with the obvious fusion boundary marks and color differences on the digital human image on the left, the fusion boundary of the image on the right has a smooth transition.
[0181] In the disclosed embodiment, a target mask image is constructed to identify the head area and the non-head area, and the pixel values of the target mask image are set to represent the contribution of the pixel points on the second image to the image fusion. Therefore, during image fusion, the fusion weight of each pixel point on the second image is determined according to the pixel value of the mask image. The accurate fusion of the second image containing the movement state of the digital human head and the original image is achieved through the linear superposition of pixel values, which effectively solves the problem of inconsistent background color of the fused image. By forming a color gradient effect at the boundary part, the rigid color transition of the image boundary is eliminated, presenting a more natural and realistic visual effect.
[0182] In some embodiments, the target mask image based on the aforementioned step S401 is constructed based on the second hair region and facial key points of the digital human on the second image. In order to reduce the amount of calculation in the mask image construction process, the second hair region can be determined by vector transformation without being obtained through a hair detection algorithm.
[0183] Based on this, before the aforementioned step S401, the method may further include a step of determining a second hair region of the digital person on the second image, see Figure 5 The flowchart of the steps of determining the hair area of the digital person on the second image shown may include:
[0184] S501, obtaining a first eye-mouth vector in a first image corresponding to the second image; the first eye-mouth vector is predetermined according to key point coordinate information of the mouth and eyes of the digital human;
[0185] The first eye-mouth vector is used to describe the relative position relationship between the eyes and mouth of the digital human in the first image, and can be obtained by calculating the difference between the average coordinates of the digital human's mouth area and the eye area.
[0186] After obtaining the first image, facial key point detection can be performed on the first image to obtain position information of facial key points, and the average coordinates of the mouth area and the average coordinates of the eye area can be determined according to the position information of the facial key points, and then the average coordinates of the eye area are subtracted from the average coordinates of the mouth area, and the result is determined as the first eye-mouth vector. The facial key point detection of the digital human on the first image and the first eye-mouth vector can be pre-executed and stored in the preprocessing stage, and the pre-stored first eye-mouth vector can be directly called in the process of determining the second hair area.
[0187] S502, detecting the facial key points of the digital human on the second image, and generating a second eye-mouth vector according to the coordinate information of the mouth and eye key points among the facial key points;
[0188] The second eye-mouth vector is used to describe the relative positional relationship between the eyes and the mouth after the head state of the digital human undergoes a driving transformation in the second image after the driving processing. After the second image is generated through the driving processing, the facial key points of the digital human in the second image can be identified by the existing facial key point detection method, and the second eye-mouth vector is determined by the same calculation method as the first eye-mouth vector. The coordinate information of the facial key points on the second image and the coordinate information of the facial key points on the first image use the same coordinate system and coordinate determination method.
[0189] That is, based on the coordinate information of the key points of the mouth and eye areas of the digital person on the second image, the average coordinates of the mouth area and the average coordinates of the eye area of the digital person on the second image are determined respectively, and the difference between the average coordinates of the mouth area and the average coordinates of the eye area is determined as the second eye-mouth vector.
[0190] S503, determining a vector transformation parameter according to the first eye-mouth vector and the second eye-mouth vector;
[0191] In the process of driving the facial expression change of the digital human according to the head motion coefficient of the digital human, each part of the face (including eyes, mouth, etc.) will undergo a certain displacement or rotation relative to the original position. The vector transformation parameter can be used to describe this change, that is, the second eye-mouth vector B' on the second image can be expressed as the product of the first eye-mouth vector B on the first image and the eye-mouth vector transformation matrix C, which can be expressed as B'=CB. Then the vector transformation parameter, that is, the eye-mouth vector transformation matrix C=B'B -1 .
[0192] S504, determining a second hair vector of the second image according to the first hair vector of the digital human in the first image and the vector transformation parameter; the first hair vector is predetermined according to the coordinate information of the hair top and the hair bottom of the first hair region in the first image;
[0193] The hair vector is used to describe the position and direction of the digital human's hair in the image. It is determined based on the key feature points or regions of the hair region to represent the overall shape, direction or position change of the hair. In this embodiment, the hair vector can be defined as the difference between the average coordinates of the hair bottom and the hair top, where the average coordinates of the hair bottom are the average of the coordinates of the lowest point on the left and the lowest point on the right in the hair region, and the hair top coordinates are the minimum y coordinate of the top of the head in the vertical direction.
[0194] The first hair vector is used to describe the position and direction of the first hair area of the digital human in the first image, and the second eye-mouth vector is used to describe the position and direction of the second hair area after the head state of the digital human undergoes a driven transformation in the second image after the driven processing.
[0195] Based on the consistency of the overall head movement, the vector transformation parameters used to describe the movement of the eye and mouth regions can be approximately used to describe the movement of the hair region. Therefore, after determining the vector transformation parameters of the movement of the eye and mouth regions of the digital human from the first image to the second image, the second hair region on the second image can be determined based on the vector transformation parameters and the first hair region on the first image.
[0196] Based on the aforementioned step S201, the first hair region on the original image is determined, and the first image is an image extracted from the original image and includes the first hair region. Therefore, the position information of the first hair region on the original image can be mapped to the first image, so as to determine the first hair vector according to the position information of the first hair region on the first image. The first hair vector of the digital human on the first image can be pre-executed and stored in the pre-processing stage, and the pre-stored first hair vector can be directly called in the process of determining the second hair region.
[0197] For example, it is known that the vector transformation parameter of the eye and mouth region is the transformation matrix C, and assuming that the first hair vector is vector A, the second hair vector A' on the second image can be expressed as A'=CA.
[0198] S505: Determine a second hair region of the digital person on the second image according to the second hair vector.
[0199] After obtaining the second hair vector, the first hair region of the digital human on the first image is mapped onto the second image as a transformation starting point, and the key points of the first hair region are transformed according to the vector transformation parameters to match the second hair vector. The second image region of the digital human on the second image can be quickly located according to the coordinate information of the transformed key points.
[0200] In the embodiment of the present disclosure, by pre-storing the eye and mouth vectors and hair vectors of the digital person on the first image, after generating the second image, the vector transformation relationship between the eye and mouth regions in the images before and after the driving process is utilized, and the hair region of the digital person on the second image is quickly determined based on the hair vectors on the first image, thereby avoiding performing hair region detection on the second image. In addition, by pre-storing the eye and mouth vectors and hair vectors of the digital person on the first image, the amount of calculation in the image fusion process is reduced, and the processing efficiency is improved.
[0201] In some embodiments, the first hair vector of the digital person in the first image involved in the above step S501 can be pre-determined and stored according to the first hair region information of the digital person in the first image, so as to facilitate direct acquisition and use in the image fusion process. Figure 6 As shown in the flowchart, the step of predetermining the first hair vector may include:
[0202] S601, for a first hair region on the first image, respectively obtain the coordinates of the lowest point on the left side and the lowest point on the right side of the hair bottom region in the horizontal direction, and use the average coordinates thereof as the hair bottom coordinates;
[0203] The horizontal direction refers to the direction from the left face boundary to the right face boundary; the hair bottom area refers to the area where the hair ends of the first hair area are located in the vertical direction, and the vertical direction refers to the direction from the chin to the top of the head of the digital person. The left lowest point and the right lowest point of the hair bottom area refer to the lowest points of the hair ends on both sides of the face in the horizontal direction, and the left and right lowest points are usually the edge points where the hair intersects with the background or other non-hair parts.
[0204] After obtaining the lowest point on the left and the lowest point on the right, based on the coordinates of the two points in the two-dimensional image coordinate system, the average value of the horizontal coordinates of the two points (corresponding to the X coordinates of the two-dimensional coordinates) is taken in the horizontal direction. Similarly, the average value of the vertical coordinates of the two points (corresponding to the Y coordinates of the two-dimensional coordinates) is taken in the vertical direction, or the smaller vertical coordinate of the two points can be taken to obtain the coordinates of the bottom of the hair in the first hair area, which represents the center position of the hair tail in the horizontal direction.
[0205] S602, in the vertical direction, determining the coordinates of the top of the hair according to the coordinates of each point in the top area of the hair;
[0206] For the coordinates of each point in the hair top region, the point with the smallest vertical coordinate among all the points can be directly used as the hair top coordinate. If there are multiple points with the smallest vertical coordinates, the average of the horizontal coordinates of the multiple points can be further calculated, and the point determined by the average and the smallest vertical coordinate can be used as the hair top coordinate. Alternatively, if the hair top region presents a certain specific shape, the coordinates of the hair top can be determined by fitting the shape. For example, the least squares method can be used to fit a straight line to the point at the top edge, and the top point of the straight line can be used as the hair top coordinate.
[0207] S603: Generate the first hair vector according to the hair bottom coordinates and the hair top coordinates.
[0208] That is, the difference between the hair bottom coordinate and the hair top coordinate is taken as the first hair vector.
[0209] For example, the middle points M1 (x1, y1) and M2 (x2, y2) in the first hair region on the first image represent the lowest points on the left and right of the hair bottom region, respectively, and the point M3 (x3, y3) represents the point where the hair top coordinates are located. Then the hair bottom coordinates can be expressed as The first hair vector can be expressed as
[0210] In some embodiments, for the aforementioned step S401, according to the second hair region and the facial key points of the digital person in the second image, constructing the target mask image of the second image, see Fig. 7AThe mask image construction step flowchart shown in the figure can generate the target mask image in the following way:
[0211] S701, creating a blank image; the pixels of the blank image correspond one-to-one with the pixels at corresponding positions on the second image;
[0212] The image size and resolution of the blank image are the same as those of the second image. Based on the image size and resolution of the second image, a blank image is created. The pixel values of all pixels of the blank image can be initialized to pixel values (0, 0, 0) or to grayscale values 0.
[0213] S702, determining a head region and a non-head region on the blank image according to a second hair region and facial key points on the second image;
[0214] The position information of the facial key points and the second hair region in the second image is mapped to the blank image. Based on the same image size and resolution as the second image, the boundary coordinates of the facial key points and the second hair region can be directly applied to the corresponding positions of the blank image. Based on the boundary of the hair region and the facial region determined based on the facial key points, the head region including the hair region and the facial region and the non-head region can be accurately identified on the blank image.
[0215] S703, setting pixel values for the pixel points in the head area and the non-head area respectively to generate the target mask image.
[0216] In this embodiment, since the target mask image is used to indicate that the head region on the second image is retained during the image fusion process, and the pixel value of the target mask image is used to characterize the contribution of the pixel points of the same region on the second image to the fused image during the image fusion process, therefore, when the blank image is set in the form of a grayscale image, the pixel value of the head region can be set to the maximum grayscale value of 255, and the pixel value of the non-head region can be set to the minimum grayscale value of 0; or, the target mask image can be set in the form of a three-channel mask image, the pixel value of the head region is set to the first three-channel pixel value, and the non-head region is set to the second three-channel pixel value. Among them, each channel value in the first three-channel pixel value takes the maximum value, that is, the first three-channel pixel value is (255,255,255), and each channel value in the second three-channel pixel value takes the minimum value, that is, the second three-channel pixel value is (255,255,255).
[0217] Through the above pixel value setting method, the image effect presented by the target mask image is an image including two black and white areas, wherein the black area represents the non-head area and the white area represents the head area. Figure 7BThe target mask image shown as an example can locate the head area and the non-head area through the facial key points and the second hair area, and black and white pixels are set for the non-head area and the head area respectively to generate the target mask image shown in the figure. The white area boundary in the figure, including the facial contour boundary of the digital person and the boundary of the second hair area, matches the head area of the digital person in the second image.
[0218] In the disclosed embodiment, by accurately detecting the key points of the face of the digital person and the second hair area on the second image, and determining the head area and the non-head area on the preset blank image based on the key points of the face and the boundary of the hair area, and then setting different pixel values to mark the head area on the second image to be retained during the image fusion process, the construction of the target mask map is realized, and effective fusion boundary information is provided for the fusion of the second image and the original image. In addition, the position of the head area can be accurately indicated based on the target mask map, and the pixel information of the head area on the second image can be ensured to be completely retained during the fusion process.
[0219] In some embodiments, after the target mask image is generated, based on the fact that the boundary between the head area and the non-head area in the target mask image is a hard boundary, that is, the pixel value directly jumps from 255 (white) to 0 (black), a jagged effect may be generated at the mask boundary during the image fusion process, resulting in an unnatural fused image. Therefore, in order to soften the hard boundary of the mask image pixel value mutation area to make its transition natural, the method may further include a Gaussian blur processing step for the current target mask image, that is, the pixel value mutation area in the target mask image may be first detected, and Gaussian blur may be applied to each pixel point in the pixel value mutation area for smoothing to obtain an updated target mask image.
[0220] Regarding Gaussian blur processing, it can be achieved through the following steps: determine the Gaussian kernel and standard deviation of the Gaussian blur processing according to the image size of the target mask image; determine the weight value of each position in the Gaussian kernel according to the two-dimensional Gaussian distribution formula; for each pixel point to be processed in the target mask image, align the center of the Gaussian kernel with the pixel point to be processed, and perform a convolution operation on the pixel point and its neighboring pixels according to each weight value in the Gaussian kernel to obtain the pixel value of the pixel point after Gaussian blur; the neighboring pixels are determined according to the coverage range of the Gaussian kernel.
[0221] The Gaussian kernel and standard deviation of the Gaussian blur can be preset based on experience, or can be determined based on the resolution of the target mask image, and different Gaussian kernels can be set for target mask images of different resolutions. For example, if the resolution of the image is a*b, the Gaussian kernel size can be determined as (a / 16+b / 16).
[0222] The two-dimensional Gaussian distribution formula can be expressed as:
[0223]
[0224] Wherein, the (m, n) represents the offset of each position in the Gaussian kernel relative to the center of the Gaussian kernel, σ is the standard deviation, and f(m, n) represents the weight value of the position in the Gaussian kernel.
[0225] For example, suppose there is a 3*3 Gaussian kernel. The coordinates of each position in the Gaussian kernel are shown in Table 1. (0,0) is the center of the Gaussian kernel, and the coordinates of each position around it represent the offset from the center of the Gaussian kernel:
[0226] (-1,-1) (-1,0) (-1,1) (0,-1) (0,0) (0,1) (1,-1) (1,0) (1,1)
[0227] By substituting the coordinates of each position into the above two-dimensional Gaussian distribution formula, the weight value of the position can be obtained. The weight value determines the relative importance between the pixel to be processed and its surrounding neighborhood pixels. The center of the Gaussian kernel has the highest weight, and the weight gradually decreases as it is farther away from the center of the Gaussian kernel.
[0228] For the pixel point (x, y) to be processed, the convolution operation formula of the Gaussian blur process can be expressed as:
[0229]
[0230] Among them, g(x,y) represents the pixel value of the pixel after Gaussian blur, r represents the radius of the convolution kernel, s(x,y) is the pixel value of the pixel before Gaussian blur processing, and f(m,n) refers to the weight value corresponding to the position (m,n) on the convolution kernel.
[0231] That is, align the pixel to be processed with the center of the Gaussian kernel, obtain a neighborhood with the pixel as the center and the same size as the Gaussian kernel, multiply each weight value in the Gaussian kernel by the pixel value of the corresponding neighborhood pixel, and add all the products to obtain a new pixel value, which is used as the pixel value of the pixel to be processed after Gaussian blur. Repeat the above convolution operation for each pixel to be processed in the first mask image, so as to obtain an updated target mask image after Gaussian blur processing.
[0232] In the disclosed embodiment, the hard boundary between the head area and the non-head area in the target mask image is softened by using Gaussian blur technology, so that the boundary pixel value changes more smoothly, avoiding the jagged effect in the image fusion process, making the fused image more natural and smooth, and improving the overall image quality and user visual experience.
[0233] In some embodiments, determining the fusion weight corresponding to each pixel on the second image according to the pixel value of each pixel on the target mask image as described in the aforementioned step S402 can be achieved through pixel value normalization processing, that is, for each pixel on the target mask image, the pixel value of the pixel is normalized; and the result after the normalization processing is used as the fusion weight corresponding to the pixel at the same pixel position on the second image.
[0234] In the case where the pixel value of the head area in the target mask image is set to the maximum grayscale value and the pixel value of the non-head area is set to the minimum grayscale value, each pixel value in the target mask image can be divided by the maximum grayscale value 255 for normalization.
[0235] In the case where the pixel values of the head area are set to the first three-channel pixel values, and the non-head area is set to the second three-channel pixel values, each channel in each pixel value can be divided by 255, and the normalized fusion weight includes three channel values, each channel value can be used as the fusion weight of the same channel on the pixel point when the second image is fused with the pixel point at the same pixel position on the original image. For example, for a pixel point in the pixel value mutation area on the target mask image, assuming that the pixel value after Gaussian blur processing is (128, 128, 128), the normalized result is (0.50, 0.50, 0.50). When the second image is fused with the original image, each channel value in the pixel value of the pixel point is calculated according to the fusion weight of the same channel in the normalized result.
[0236] In some embodiments, for the aforementioned step S403, linearly fusing the second image with the original image according to the fusion weight, see Figure 8 As shown in the flowchart, image fusion can be achieved through the following steps:
[0237] S801, obtaining a second pixel value of each pixel point on the second image, and obtaining a first pixel value of the same pixel position on the original image;
[0238] The fusion of the second image and its corresponding original image refers to the fusion of the second image with the image block on the original image that matches the pixel area of the second image, and the two have the same pixel width and height. The fusion weight is set for each pixel point on the second image. When performing image fusion, it is actually a weighted calculation of the pixel value based on the fusion weight. Then, the first pixel value of each pixel point in the second image and the second pixel value corresponding to the same pixel point on the original image are obtained at the same time, so as to realize pixel-level image fusion.
[0239] S802: According to the fusion weight corresponding to each pixel point on the second image, linearly superimpose the first pixel value and the second pixel value to obtain the digital human image.
[0240] The fusion weight is used to indicate the contribution of the pixel point on the second image to the fused image. If it is expressed as ω, the fusion weight of the pixel point corresponding to the original image can be expressed as (1-ω). Based on this, the first pixel value and the second pixel value are linearly superimposed, that is, the second pixel value is multiplied by the fusion weight ω, and the corresponding second pixel value is multiplied by (1-ω). The sum obtained is the pixel value of the pixel point at the corresponding position on the fused image.
[0241] When the first pixel value and the second pixel value are multiplied by their respective weight values for linear superposition, the weighted calculation process of the first pixel value and the second pixel value can be respectively calculated for each channel of the first pixel value and the second pixel value. Assume that the three-channel pixel values of the pixel point (x, y) on the second image are I R (x,y),I G (x,y),I B (x, y), the three-channel pixel values corresponding to the pixel point (x, y) in the original image are S R (x,y),S g (x,y),S B (x, y), the fusion weight is expressed as ω, then the three-channel pixel values of the pixel points at the corresponding position on the fused image can be expressed as:
[0242] F R (x,y)=ωI R (x,y)+(1-ω)S R (x,y)
[0243] F G (x,y)=ωI G (x,y)+(1-ω)S G (x,y)
[0244] F R (x,y)=ωI B (x,y)+(1-ω)S B (x,y)
[0245] In the embodiment of the present disclosure, a pixel-level fusion weight is used to determine the contribution of each pixel in the second image and the original image. The fusion weight is used to achieve effective fusion of the second image and the original image, and a digital human image is generated that includes dynamic movement of the digital human's head and maintains the realism of the background. The problem of rigid fusion boundaries is solved and smooth transition of fusion boundaries is achieved.
[0246] In some embodiments, when each of the original images to be processed is a multi-frame image of an original video, the method may further include a digital human target video generation process, which may include the steps of: combining the digital human image corresponding to each original image according to the inter-frame order of the multi-frame images in the original video according to the inter-frame order to generate a first video, and synchronizing the pre-prepared driving voice data with the first video, such as accurately aligning the voice data with the video frame according to the time axis to ensure that the digital human's lip shape, expression and movement match the voice content, and generating the digital human target video.
[0247] In order to enable those skilled in the art to better understand the digital human image generation method provided by the present application, the method flow is described below using a scenario in which a full-body image of a digital human looking straight ahead is used as the original image and an image of a digital human with the head raised and smiling is required to be generated.
[0248] In this embodiment, see Fig. 9 As shown in the method flow chart, the digital human image generation method provided by the present application mainly includes an input image processing stage, a digital human head movement driving stage, an image fusion stage, and a digital human image output stage.
[0249] S901, input image processing stage: divided into original image input and image cropping processing. The original image input is used to input the full-body image of the digital human looking straight ahead as the original image; the image cropping processing is used to determine the region of interest in the full-body image, and crop the image of the region of interest from the full-body image as the basic driving image, which mainly includes the head area of the digital human, reducing unnecessary background image information.
[0250] Regarding the region of interest, the hair detection of the open source algorithm can be used to first detect the full-body image of the digital human, mark the hair area and the non-hair area respectively, and detect the maximum and minimum values of the x coordinate in the horizontal direction and the maximum and minimum values of the y coordinate in the vertical direction in the hair area; then, (Δx+Δy) / 2 is used as the center coordinate of the region of interest, and the set multiples of Δx and Δy are taken as the side length of the region of interest. After determining the region of interest, if the length of one side of the region of interest is greater than the pixel width or height of the input full-body image, the side length can be reduced proportionally to the pixel size of the image, and the other side length can be reduced by the same proportion.
[0251] For example, assuming that the bounding box coordinates of the hair area are: x_min=100, x_max=300, y_min=50, y_max=250, and the total pixel size of the full-body image of the digital human is 800*600, the center coordinates of the region of interest can be expressed as:
[0252] Center x coordinate = (x_min + x_max) / 2 = (100 + 300) / 2 = 200
[0253] Center y coordinate = (y_min + y_max) / 2 = (50 + 250) / 2 = 150
[0254] Assuming that 1.1 is used as the magnification factor of the side length, the side length of the region of interest can be expressed as:
[0255] Width = 1.1*(x_max-x_min) = 1.1*(300-100) = 220
[0256] Height=1.31*(y_max-y_min)=1.1*(250-50)=220
[0257] S902, digital human head movement driving stage: used to drive the digital human in the basic driving image output in step S901 to change the head posture and facial expression according to the digital human head posture coefficient and facial expression coefficient corresponding to the input driving voice data, and convert the head state of the digital human in the basic driving image looking straight ahead into the head state of looking up and smiling, so as to obtain a driving matching image;
[0258] S903, image fusion stage: at least includes three steps: target mask map construction, Gaussian blur processing, and image fusion. Among them, the target mask map construction step is used to construct a target mask map based on the hair area and facial key points of the digital person on the driving matching image. The mask map is used to identify the head area and the non-head area. The head area includes the hair area of the digital person on the driving matching image and the facial area where the facial key points are located. The Gaussian blur processing step is used to perform Gaussian blur processing on the pixel points in the pixel value mutation area on the constructed target mask map. The image fusion step is used to determine the fusion weight of each pixel point on the driving matching image according to the pixel value of the target mask map, and perform pixel-level linear fusion of the driving matching image and the whole body image according to the fusion weight.
[0259] S904, a digital human image output stage, is used to output the digital human image after linear fusion processing.
[0260] In the embodiment of the present disclosure, a region of interest including a head area for driving processing is determined from an input full-body image, a corresponding driving matching image including head movement is generated based on the region of interest, and the driving matching image is reintegrated into the input full-body image. This solves the problem of image distortion caused when the input image includes a large number of images other than the head area, and improves the quality of the digital human image as well as the naturalness and realism of the digital human.
[0261] Corresponding to the above-mentioned embodiment of the digital human generation method, see Fig.10 As shown, the present application also provides an embodiment of a digital human generation device, the device comprising:
[0262] An area of interest determination module 1010 is used to determine an area of interest in the original image of the digital human; the area of interest includes a first hair area of the digital human;
[0263] A first image acquisition module 1020 is used to crop the region of interest in the original image to obtain a first image;
[0264] A drive processing module 1030, configured to drive and process the head posture and facial expression of the digital human in the first image according to the head motion coefficient of the digital human in the first image, so as to generate a second image;
[0265] The digital human image generation module 1040 is used to fuse the second image with the original image according to the position information of the first image on the original image, so as to generate a digital human image corresponding to the original image.
[0266] In some embodiments, the region of interest determination module is specifically used to:
[0267] A boundary position information acquisition module, used to determine a first hair region of the digital human in the original image of the digital human, and to acquire position information of boundaries of the first hair region in horizontal and vertical directions;
[0268] a center coordinate determination module, configured to obtain the center coordinates of the first hair region according to the position information of the boundary;
[0269] The region of interest determination module is used to determine the region of interest according to the central coordinates and the region width of the first hair region in the horizontal direction and the vertical direction.
[0270] In some embodiments, the region of interest determination module is specifically used to:
[0271] determining a horizontal side length of the region of interest according to a region width of the first hair region in a horizontal direction;
[0272] determining a vertical side length of the region of interest according to a region width of the first hair region in a vertical direction;
[0273] The region of interest is determined according to the horizontal side length and the vertical side length in combination with the center coordinates.
[0274] In some embodiments, the region of interest determination module is used to determine the region of interest according to the horizontal side length and the vertical side length in combination with the center coordinates, including:
[0275] When the horizontal side length is greater than the width of the original image, or the vertical side length is greater than the height of the original image, adjusting the horizontal side length and the vertical side length according to the size of the original image;
[0276] The region of interest is determined according to the adjusted horizontal side length and vertical side length.
[0277] In some embodiments, the digital human image generation module includes:
[0278] A target mask image construction module is used to construct a target mask image of the second image according to the second hair area and the key points of the face of the digital person on the second image; the target mask image is used to identify the head area and the non-head area;
[0279] A fusion weight determination module, used to determine the fusion weight corresponding to each pixel point on the second image according to the pixel value of each pixel point on the target mask image;
[0280] An image fusion module is used to linearly fuse the second image with the original image according to the fusion weight.
[0281] In some embodiments, before constructing the target mask map, the apparatus further includes:
[0282] A first eye-mouth vector acquisition module, used to acquire a first eye-mouth vector in the first image corresponding to the second image; the first eye-mouth vector is predetermined according to the key point coordinate information of the mouth and eyes of the digital human;
[0283] A second eye-mouth vector acquisition module is used to detect the facial key points of the digital human on the second image, and generate a second eye-mouth vector according to the coordinate information of the mouth and eye key points among the facial key points;
[0284] a vector transformation parameter determination module, used to determine a vector transformation parameter according to the first eye-mouth vector and the second eye-mouth vector;
[0285] A second hair vector determination module, used to determine a second hair vector of the second image according to the first hair vector of the digital human in the first image and the vector transformation parameter; the first hair vector is predetermined according to the coordinate information of the hair top and the hair bottom of the first hair region in the first image;
[0286] The second hair region determining module is used to determine a second hair region of the digital person on the second image according to the second hair vector.
[0287] In some embodiments, the apparatus further comprises a first hair vector pre-determining module, specifically configured to:
[0288] For the first hair region on the first image, in the horizontal direction, respectively obtain the coordinates of the lowest point on the left side and the lowest point on the right side of the hair bottom region, and use the average coordinates thereof as the hair bottom coordinates;
[0289] In the vertical direction, the coordinates of the top of the hair are determined according to the coordinates of each point in the top area of the hair;
[0290] The first hair vector is generated according to the hair bottom coordinates and the hair top coordinates.
[0291] In some embodiments, the target mask image construction module is specifically used to:
[0292] Creating a blank image; wherein the pixels of the blank image correspond one-to-one to the pixels at corresponding positions on the second image;
[0293] Determine a head region and a non-head region on the blank image according to the second hair region and the facial key points on the second image;
[0294] Pixel values are set for the pixel points in the head area and the non-head area respectively to generate the target mask image.
[0295] In some embodiments, after generating the target mask image, the apparatus further comprises:
[0296] Detecting a pixel value mutation region in the target mask image;
[0297] Gaussian blur is applied to each pixel point in the pixel value mutation area for smoothing to obtain an updated target mask image.
[0298] In some embodiments, the fusion weight determination module is specifically used to:
[0299] For each pixel point on the target mask image, normalize the pixel value of the pixel point;
[0300] The normalized result is used as the fusion weight corresponding to the pixel points at the same pixel position on the second image.
[0301] In some embodiments, the image fusion module is specifically used for:
[0302] Obtain a second pixel value of each pixel point on the second image, and obtain a first pixel value of the same pixel position on the original image;
[0303] According to the fusion weight corresponding to each pixel point on the second image, the first pixel value and the second pixel value are linearly superimposed to obtain the digital human image.
[0304] In some embodiments, when the original image of the digital human includes multiple frames of images of an original video, the apparatus further includes:
[0305] A first video generation module, configured to combine the digital human image corresponding to each original image according to the inter-frame sequence of multiple frames of images in the original video according to the inter-frame sequence to generate a first video;
[0306] The audio synchronization module is used to synchronize the input driving voice data with the first video to generate a digital human target video matching the driving voice data.
[0307] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0308] The present application also provides an electronic device. The structural diagram of the electronic device is as follows: Fig.11 As shown, the electronic device 1100 includes at least one processor 1101, a memory 1102 and a bus 1103, and the at least one processor 1101 is electrically connected to the memory 1102; the memory 1102 is configured to store at least one computer-executable instruction, and the processor 1101 is configured to execute the at least one computer-executable instruction, thereby performing any step of a digital human image generation method provided in any embodiment or any optional implementation manner in the present application.
[0309] Furthermore, the processor 1101 may be a Field-Programmable Gate Array (FPGA) or other devices with logic processing capabilities, such as a Microcontroller Unit (MCU) or a Central Process Unit (CPU).
[0310] An embodiment of the present application further provides another readable storage medium storing a computer program, which is used to implement the steps of any digital human image generation method provided in any embodiment or any optional implementation manner of the present application when executed by a processor.
[0311] The readable storage medium provided in the embodiments of the present application includes, but is not limited to, any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory), RAM (Random Access Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card. That is, the readable storage medium includes any medium that can store or transmit information in a readable form by a device (e.g., a computer).
[0312] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for generating a digital human image, characterized in that: The method comprises: Determine an area of interest in the original image of the digital person; the area of interest includes a first hair area of the digital person; Cropping the region of interest in the original image to obtain a first image; According to the head motion coefficient of the digital human in the first image, driving processing is performed on the head posture and facial expression of the digital human in the first image to generate a second image; The second image is fused with the original image according to the position information of the first image on the original image to generate a digital human image corresponding to the original image.
2. The method according to claim 1, characterized in that The step of determining the region of interest in the original image of the digital human comprises: Determine a first hair region of the digital human in the original image of the digital human, and obtain position information of boundaries of the first hair region in horizontal and vertical directions; Obtaining the center coordinates of the first hair area according to the position information of the boundary; The region of interest is determined according to the central coordinates and the region widths of the first hair region in the horizontal direction and the vertical direction.
3. The method according to claim 2, characterized in that The determining the region of interest according to the central coordinates and the region width of the first hair region in the horizontal direction and the vertical direction comprises: determining a horizontal side length of the region of interest according to a region width of the first hair region in a horizontal direction; determining a vertical side length of the region of interest according to a region width of the first hair region in a vertical direction; The region of interest is determined according to the horizontal side length and the vertical side length in combination with the center coordinates.
4. The method according to claim 3, characterized in that The determining the region of interest according to the horizontal side length and the vertical side length in combination with the center coordinates includes: When the horizontal side length is greater than the width of the original image, or the vertical side length is greater than the height of the original image, adjusting the horizontal side length and the vertical side length according to the size of the original image; The region of interest is determined according to the adjusted horizontal side length and vertical side length.
5. The method according to claim 1, characterized in that The fusing the second image with the original image according to the position information of the first image on the original image comprises: constructing a target mask image of the second image according to the second hair area and the key points of the face of the digital person on the second image; the target mask image is used to identify the head area and the non-head area; Determining a fusion weight corresponding to each pixel point on the second image according to a pixel value of each pixel point on the target mask image; The second image is linearly fused with the original image according to the fusion weight.
6. The method according to claim 5, characterized in that Before constructing the target mask map, the method further includes: Acquire a first eye-mouth vector in the first image corresponding to the second image; the first eye-mouth vector is predetermined according to key point coordinate information of the mouth and eyes of the digital human; Detecting facial key points of the digital person on the second image, and generating a second eye-mouth vector according to coordinate information of the mouth and eyes among the facial key points; Determining a vector transformation parameter according to the first eye-mouth vector and the second eye-mouth vector; determining a second hair vector of the second image according to a first hair vector of the digital human in the first image and the vector transformation parameter; the first hair vector is predetermined according to coordinate information of a hair top and a hair bottom of the first hair region in the first image; A second hair region of the digital person on the second image is determined according to the second hair vector.
7. The method according to claim 6, characterized in that The method further comprises the step of predetermining the first hair vector: For the first hair region on the first image, in the horizontal direction, respectively obtain the coordinates of the lowest point on the left side and the lowest point on the right side of the hair bottom region, and use the average coordinates thereof as the hair bottom coordinates; In the vertical direction, the coordinates of the top of the hair are determined according to the coordinates of each point in the top area of the hair; The first hair vector is generated according to the hair bottom coordinates and the hair top coordinates.
8. The method according to claim 5, characterized in that The step of constructing a target mask image of the second image according to the second hair region and the facial key points of the digital person on the second image includes: Creating a blank image; wherein the pixels of the blank image correspond one-to-one to the pixels at corresponding positions on the second image; Determine a head region and a non-head region on the blank image according to the second hair region and the facial key points on the second image; Pixel values are set for the pixel points in the head area and the non-head area respectively to generate the target mask image.
9. The method according to claim 8, characterized in that After generating the target mask image, the method further includes: Detecting a pixel value mutation region in the target mask image; Gaussian blur is applied to each pixel point in the pixel value mutation area for smoothing to obtain an updated target mask image.
10. The method according to claim 5, characterized in that The step of determining the fusion weight corresponding to each pixel point on the second image according to the pixel value of each pixel point on the target mask image includes: For each pixel point on the target mask image, normalize the pixel value of the pixel point; The normalized result is used as the fusion weight corresponding to the pixel points at the same pixel position on the second image.
11. The method according to claim 5, characterized in that The linearly fusing the second image with the original image according to the fusion weight includes: Obtain a second pixel value of each pixel point on the second image, and obtain a first pixel value of the same pixel position on the original image; According to the fusion weight corresponding to each pixel point on the second image, the first pixel value and the second pixel value are linearly superimposed to obtain the digital human image.
12. The method according to claim 1, characterized in that In the case where the original image of the digital human includes multiple frames of images of the original video, the method further comprises the step of generating a target video of the digital human: According to the inter-frame sequence of multiple frames of images in the original video, the digital human image corresponding to each original image is combined according to the inter-frame sequence to generate a first video; The input driving voice data is synchronized with the first video to generate a digital human target video matching the driving voice data.
13. A digital human image generation device, characterized in that: The device comprises: An area of interest determination module, used to determine an area of interest in the original image of the digital human; the area of interest includes a first hair area of the digital human; A first image acquisition module, used for cropping the region of interest in the original image to obtain a first image; A driving processing module, configured to drive and process the head posture and facial expression of the digital human in the first image according to the head motion coefficient of the digital human in the first image, so as to generate a second image; The digital human image generation module is used to fuse the second image with the original image according to the position information of the first image on the original image, so as to generate a digital human image corresponding to the original image.
14. An electronic device, characterized in that: include: Memory, processor; The memory is used to store computer programs; The processor is used to call the computer program to implement the method according to any one of claims 1-12.
15. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.
Citation Information
Cited By
Digital human modeling method and device, equipment, storage medium and program product
CN119295682A
Digital human reconstruction method, apparatus and device, and storage medium
CN119810369A
