Face image processing method, device and equipment for three-dimensional face reconstruction and medium
By employing spatial transformation, bias correction, and a face segmentation model, the problem of inconsistent face image quality in existing technologies has been solved, achieving high-precision 3D face reconstruction and ensuring the realism and consistency at the geometric and texture levels.
Patent Information
- Application Number
- CN202611404926.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-10
- Publication Date
- 2026-11-27
AI Technical Summary
When processing face images of varying quality, existing technologies handle image enhancement and face segmentation tasks independently. This results in traditional enhancement algorithms having limited ability to restore non-high-definition images, excessive noise amplification, and reduced face segmentation accuracy, which in turn affects the geometric integrity and surface smoothness of 3D reconstruction.
By employing spatial transformation and bias removal processing, the face segmentation model is used to accurately locate the skin and facial features, filter out non-facial interference factors, and optimize mask integrity through hole filling and pose normalization, providing high-purity and high-precision input data.
It effectively eliminates uneven lighting and color distortion, ensures comprehensive analysis and target focus, reduces noise and pose differences, provides high-precision and robust input data for subsequent 3D reconstruction, and improves the fidelity of 3D face reconstruction.
Smart Images

Figure CN123181724A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of three-dimensional reconstruction technology, and in particular to a method, apparatus, device and medium for three-dimensional face reconstruction face image processing. Background Technology
[0002] 3D face reconstruction has application value in fields such as augmented reality, intelligent monitoring, medical plastic surgery and human-computer interaction. However, there are still many challenges in the preprocessing of face images from diverse sources with varying quality in real-world application scenarios.
[0003] Currently, most face image processing methods typically treat image enhancement and face segmentation as independent tasks. However, this approach has several drawbacks. First, traditional enhancement algorithms have limited ability to restore non-high-definition images and are prone to over-amplifying noise. Second, face segmentation accuracy is significantly affected by image quality. Problems such as blurred edges and uneven lighting in low-quality images often lead to inaccurate segmentation boundaries, which in turn affect the geometric integrity and surface smoothness of subsequent 3D reconstruction.
[0004] Therefore, how to comprehensively analyze facial images and remove interference to improve the fidelity of 3D face reconstruction has become an urgent problem to be solved. Summary of the Invention
[0005] This invention provides a face image processing method, apparatus, computer equipment, and medium for three-dimensional face reconstruction, in order to solve the technical problem of comprehensively analyzing face images and removing interference, thereby improving the fidelity of three-dimensional face reconstruction.
[0006] Firstly, a face image processing method for 3D face reconstruction is provided, including: When a target face is detected, image information of the target face is acquired, and spatial transformation is performed on the image information to obtain a color information image containing at least one color channel; For each color channel, the pixel data corresponding to the color channel in the color information image is extracted, and the color information image is subjected to deviation correction processing based on the pixel data to obtain a processed image; The processed image is input into a preset face segmentation model for analysis to obtain the face part label for each pixel in the processed image; According to the preset target location, the face location labels are filtered to obtain filter labels. All the pixels in the processed image are traversed to obtain the pixel set corresponding to the filter label. Hole filling processing is performed on the pixel set to obtain the mask image. A preset target alignment position is obtained. Based on the target alignment position, the position transformation information of the mask image is determined. Based on the transformation information, the position of the mask image is adjusted to obtain an adjusted image. The adjusted image is used to perform three-dimensional face reconstruction.
[0007] Secondly, according to an embodiment of this application, a face image processing apparatus for three-dimensional face reconstruction includes: A spatial transformation module is used to acquire image information of the target face when a target face is detected, and to perform spatial transformation on the image information to obtain a color information image containing at least one color channel. The deviation correction module is used to extract the pixel data corresponding to the color channel in the color information image for each color channel, and perform deviation correction processing on the color information image based on the pixel data to obtain a processed image; The part analysis module is used to input the processed image into a preset face segmentation model for analysis, and obtain the face part label of each pixel in the processed image; The label filtering module is used to filter the face region labels according to the preset target region to obtain the filtered labels, traverse all the pixels of the processed image to obtain the pixel set corresponding to the filtered label, and perform hole filling processing on the pixel set to obtain the mask image. The position adjustment module is used to obtain a preset target alignment position, determine the position transformation information of the mask image based on the target alignment position, and adjust the position of the mask image according to the transformation information to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
[0008] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described face image processing method for three-dimensional face reconstruction.
[0009] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the face image processing method for three-dimensional face reconstruction described above.
[0010] The beneficial effects of this application embodiment compared with the prior art are as follows: When a target face is detected, image information of the target face is acquired, spatial transformation is performed on the image information to obtain a color information image containing at least one color channel, pixel data of the corresponding color channel in the color information image is extracted for each color channel, and bias correction processing is performed on the color information image based on the pixel data to obtain a processed image. The processed image is input into a preset face segmentation model for analysis to obtain a face part label for each pixel in the processed image. The face part labels are filtered according to the preset target part to obtain filtered labels. All pixels in the processed image are traversed to obtain a set of pixels corresponding to the filtered labels. Hole filling processing is performed on the pixel set to obtain a mask image, a preset target alignment position is obtained, and the position transformation information of the mask image is determined according to the target alignment position. The position of the mask image is adjusted according to the transformation information to obtain an adjusted image, which is used to perform three-dimensional face reconstruction. First, through spatial transformation and bias correction processing, uneven illumination and color distortion are effectively eliminated, and the input data is standardized. Secondly, a pixel-level face segmentation model was used to accurately locate key areas such as skin and facial features, while filtering out non-facial interference factors (such as hair and accessories), ensuring comprehensive analysis and focused targeting. Subsequently, hole-filling optimized mask integrity, and finally, spatial adjustments were made using preset alignment positions to normalize facial pose. This entire process significantly reduced noise and pose variations, providing high-purity, high-precision input data for subsequent reconstruction algorithms, resulting in more realistic and consistent modeling results at both the geometric and textural levels. Attached Figure Description
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of an application environment for a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application; Figure 2 This is a schematic flowchart of a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application; Figure 3 This is a schematic flowchart of a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application; Figure 4 This is a schematic flowchart of a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application; Figure 5This is a schematic flowchart of a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a face image processing device for three-dimensional face reconstruction provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention; Figure 8 This is another structural schematic diagram of a computer device according to one embodiment of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] The first embodiment of this application provides a face image processing method for three-dimensional face reconstruction, which can be applied to, for example... Figure 1 In this application environment, the client and server interact through a communication connection. Users can take selfies or upload facial images on the client, while the server receives the facial image data sent by the client and automatically calls and executes the facial image processing method for 3D facial reconstruction defined in this technical solution.
[0015] See Figure 2 This is a flowchart illustrating a face image processing method for 3D face reconstruction according to an embodiment of this application. The face image processing method for 3D face reconstruction can be applied to... Figure 1 The server-side component.
[0016] like Figure 2 As shown, the face image processing method for 3D face reconstruction may include the following steps: Step S201: When a target face is detected, image information of the target face is acquired, and spatial transformation is performed on the image information to obtain a color information image containing at least one color channel.
[0017] Step S202: For each color channel, extract the pixel data corresponding to the color channel in the color information image, and perform deviation correction processing on the color information image based on the pixel data to obtain a processed image.
[0018] Optionally, the step S202 of extracting pixel data corresponding to the color channel in the color information image may include the following steps: Extract the pixel values corresponding to the color channels from the color information image; The average value of the pixels is calculated by performing an average value calculation on the pixel values. The standard deviation of the pixel values is calculated to obtain the pixel standard deviation value; The pixel mean and the pixel standard deviation are used as pixel data.
[0019] The system receives raw scene images captured by devices such as cameras and image sensors. To accurately separate the target face from the scene image, this embodiment employs an efficient face detection algorithm from the field of computer vision. Specifically, the YuNet face detection module integrated in the OpenCV computer vision library is used to scan and recognize the raw image. If the YuNet module does not detect any target region matching facial features in the image, the current image is deemed invalid, and the entire preprocessing process terminates. This ensures that subsequent processing is only performed on valid face data, avoiding unnecessary consumption of computational resources. If the YuNet module successfully detects at least one face, the algorithm locates the facial bounding box of that face. Subsequently, according to preset size specifications (e.g., 224×224 pixels or 128×128 pixels), a rectangular region containing the complete face is cropped from the raw image, and this region is scaled to a uniform N×N pixel size to obtain the initial RGB color space face image, denoted as F0.
[0020] To perform color analysis that better aligns with human visual characteristics and facilitates subsequent processing, the image needs to be converted to a more suitable color space. Therefore, the RGB face image F0 is converted from the RGB color space to the YUV color space. This conversion separates the image's color information into a luminance component (Y channel) and two chrominance components (U channel and V channel), resulting in a color information image. This image contains the independent color channel information that will be processed in subsequent steps.
[0021] The purpose of step S202 is to eliminate image color deviation caused by external factors such as shooting lighting and equipment color difference, to standardize the color distribution of face images, and to provide input with lighting invariance or color normalization for 3D reconstruction.
[0022] Specifically, for the color information image obtained in step S201, independent bias correction processing is performed on its Y, U, and V channels respectively. Taking one color channel T (T can be Y, U, or V) as an example, the processing steps are as follows: read the values of all pixels in channel T of the color information image to form the pixel value set of that channel. Calculate the arithmetic mean of the pixel value set of channel T to obtain the pixel mean μ(T) that represents the overall brightness or color level of that channel.
[0023] The standard deviation of the pixel value set in channel T is calculated to obtain the pixel standard deviation δ(T), which characterizes the dispersion or contrast of the pixel values in that channel. The calculated pixel mean μ(T) and pixel standard deviation δ(T) are used as key statistics (i.e., pixel data) and substituted into a preset normalization transformation formula to perform calculations on each pixel value of the original channel T. A preferred embodiment of the transformation formula is as follows: Here, ω is an adjustable hyperparameter. The formula first uses the mean μ(T) and the standard deviation scaled by the hyperparameter ω. The channel data is first scaled and normalized, and then the original standard deviation δ(T) and mean μ(T) are used to scale and shift the data back to approximately the original order of magnitude. By setting the value of ω (e.g., ω=1.0 for standard normalization, or ω>1.0 to reduce the normalization strength), the strength of the debiasing can be flexibly controlled, achieving a balance between eliminating extreme biases and retaining necessary individual characteristics.
[0024] After performing the above transformations on the Y, U, and V channels respectively, the resulting new channels Y', U', and V' are combined to form a YUV image after deviation correction, which is denoted as the processed image.
[0025] Through the above steps S201 and S202, an automated and standardized processing flow from the original scene image to the standardized face image is realized, which effectively improves the quality and consistency of the input data, thereby helping to improve the accuracy and robustness of 3D face reconstruction.
[0026] Optionally, step S202, which involves performing a deviation correction process on the color information image based on the pixel data to obtain a processed image, may include the following steps: Based on the image information, determine an image matrix containing all pixels of the image with the color information; The difference matrix is obtained by calculating the difference between the image matrix and the pixel mean. Obtain preset hyperparameters, scale the pixel standard deviation according to the hyperparameters to obtain a scaling difference, and calculate the ratio between the difference matrix and the scaling difference to obtain a ratio matrix; The scaling matrix is obtained by multiplying the ratio matrix and the pixel standard deviation. The processed image is obtained by summing the scaling matrix and the pixel mean.
[0027] First, based on the color information image, all pixel values corresponding to color channel T are extracted. Since the image itself can be considered a two-dimensional matrix, where each element represents the intensity value of a pixel in that channel, the pixel data of channel T is constructed into an image matrix Mat_T of size M×N (consistent with the image resolution). This matrix Mat_T is the basic data unit for all subsequent linear operations. Next, using the pixel mean μ(T) of the channel pre-calculated in step S202, the scalar mean μ(T) is subtracted from each element in the image matrix Mat_T. This operation is represented in matrix operations as Diff_Mat = Mat_T-μ(T), where Diff_Mat is the calculated difference matrix. This step shifts the data center of the entire channel to zero, removing the overall brightness or color tone deviation of the channel.
[0028] In this process, a preset hyperparameter ω is introduced to adjust the normalization intensity. This hyperparameter ω can be preset by the system developer based on a large amount of experimental data, or it can be adjusted by the user as a configurable item. The pixel standard deviation δ(T) of the channel calculated in step S202 is multiplied by the hyperparameter ω to obtain a scaled standard deviation, i.e., the scaled difference Scaled_Std = δ(T) × ω.
[0029] Next, each element in the difference matrix Diff_Mat obtained in the previous step is divided by the scaling difference Scaled_Std. This operation is represented in matrix operations as Ratio_Mat = Diff_Mat / Scaled_Std.
[0030] Here, Ratio_Mat is the calculated ratio matrix. This step essentially performs variance scaling on the data after data centralization, with the scaling strength controlled by ω (standard score standardization when ω=1). To eliminate bias while preserving the relative distribution scale of the original data to some extent, the obtained ratio matrix Ratio_Mat is multiplied by the original pixel standard deviation δ(T). This operation is represented in matrix operations as Scaled_Mat = Ratio_Mat×δ(T), where Scaled_Mat is the scaling matrix. After this step, the data is rescaled to a scale that is related to the variance of the original data but has had the influence of the mean removed.
[0031] Finally, the scaling matrix Scaled_Mat is added to the original pixel mean μ(T) to shift the center of the data back to near the original mean.
[0032] This operation is represented in matrix operations as Mat_T'=Scaled_Mat +μ(T), where Mat_T' is the new image matrix of channel T after complete bias correction, representing all pixel values of that channel after processing.
[0033] For the Y, U, and V channels of the color information image, steps S2021 to S2025 are performed independently and in parallel to obtain three processed channel matrices Mat_Y', Mat_U', and Mat_V'. These three channel matrices are then recombine according to the YUV color space format to obtain the final processed image.
[0034] Step S203: Input the processed image into a preset face segmentation model for analysis to obtain the face part label for each pixel in the processed image.
[0035] Step S204: Based on the preset target location, filter the face location tags to obtain filter tags, traverse all the pixels of the processed image to obtain the pixel set corresponding to the filter tags, and perform hole filling processing on the pixel set to obtain a mask image.
[0036] Optionally, step S204, which involves filtering the facial region tags based on preset target regions to obtain filtered tags, may include the following steps: Obtain a preset binary indicator function. If the face part label matches the target part, the input of the binary indicator function is a preset matching value. Based on all the specified matching values, the facial region labels are filtered to obtain filtered labels.
[0037] The processed image is then input into a pre-trained face semantic segmentation model for analysis. This face semantic segmentation model is based on a deep convolutional neural network and has been trained on a large dataset containing detailed facial region annotations.
[0038] The function of this facial semantic segmentation model is to predict and output a specific semantic category label L(x) for each pixel x in the input image (where x∈Ω, Ω represents the entire image domain). In a preferred embodiment, the set of values for the semantic category label L(x) is {1, 2, 3, …, 19}, corresponding to 19 different semantic parts of the face, such as 1-background, 2-skin, 3-left eyebrow, 4-right eyebrow, 5-left eye, 6-right eye, 7-nose, 8-upper lip, 9-lower lip, 10-teeth, etc. Thus, the image is transformed into a label map with precise semantic information.
[0039] Step S204 aims to extract specific target parts preset by the user or system from the above segmentation results. First, a preset binary indicator function M_i(x) is obtained. This function is defined as a logical judgment function for any semantic category i (i ∈ {1,2,…,19}) if and only if L(x) = i, M_i(x) = 1. Otherwise, M_i(x) = 0.
[0040] The output value 1 is defined as a preset conformity value. Based on the preset target region, the facial region labels are filtered to obtain filtered labels. Specifically, the preset target region is a set of one or more semantic categories, denoted as C⊆{1, 2, 3, …, 19}. For example, if the target region is all skin areas, then C={2}; if the target region is the complete facial features region, then C ={3, 4, 5, 6, 7, 8, 9, 10}. For each pixel x in the image, it is determined whether its label L(x) belongs to the target region set C.
[0041] If L(x)∈C, then the label of that pixel is considered to match the target region. In this case, the corresponding binary indicator function outputs a match value of 1. All pixels with an output of 1 form the set of filtering labels L(x). From an image perspective, this is equivalent to generating a preliminary binary logical mask M_C(x) for the target region set C, defined as M_C(x) = ⋁_{i∈C} M_i(x). Here, the symbol ⋁ represents a logical OR operation. This means that M_C(x) = 1 if and only if the label L(x) of pixel x belongs to any category in set C.
[0042] Traverse all pixels in the processed image and collect all pixels that satisfy M_C(x) = 1 (i.e. have a filter label) to form a corresponding pixel set. This pixel set is represented in the image space as all pixel positions with a value of 1 in the initial binary mask M_C(x).
[0043] Since the initial segmentation result may produce small holes in the target area due to occlusion, lighting, or model errors (i.e., pixels with a value of 0 are surrounded by pixels with a value of 1), morphological hole-filling is performed on the binary mask M_C(x) represented by the set of pixels. Hole-filling is a classic image morphological operation whose purpose is to fill all the holes inside the binary region, thereby obtaining a continuous and complete region. After this step, the optimized mask image M_C(x) is obtained.
[0044] After obtaining a high-quality mask image M_C(x), it is combined with the original processed image (or any image I from which the target region needs to be extracted) using a logical AND operation to generate a new image I' containing only the target region. The operation is represented as I' = M_C'(x) ⋀I, where ⋀ represents a pixel-by-pixel logical AND (i.e., multiplication). For YUV images, this operation needs to be performed separately on the Y, U, and V channels.
[0045] This specific implementation achieves the ability to extract arbitrary preset regions (such as complete skin areas or specific combinations of facial features) from complex facial images with high precision and robustness. The method employs binary indicator functions and set logic for filtering, making it rigorous and easy to implement programmatically. Hole-filling effectively improves the visual integrity of the mask and the stability of subsequent processing. This technical solution provides a preprocessing foundation for applications such as region-based 3D face reconstruction, local feature enhancement, and virtual makeup try-on.
[0046] Step S205: Obtain a preset target alignment position; determine the position transformation information of the mask image based on the target alignment position; adjust the position of the mask image based on the transformation information to obtain an adjusted image; the adjusted image is used to perform three-dimensional face reconstruction.
[0047] The purpose of step S205 is to uniformly align the face mask image extracted under any pose and position to a standard coordinate system through a preset geometric transformation, thereby removing background and non-rigid areas (such as hair, ears, neck, etc.) that are irrelevant to the 3D facial shape reconstruction and ensuring the consistency of the input.
[0048] A preset target alignment position is obtained, which is represented by a standardized square image coordinate system (target image T), with the same size as the input image, defined as N×N pixels. Within this coordinate system, three key target reference points are preset to define a rectangular region for cropping and alignment: T1 = (0, 0) (top left corner of the target image), T2 = (0, N-1) (bottom left corner of the target image), and T3 = (N-1, 0) (top right corner of the target image). These three points define a rectangular frame in the target image, with the top left corner as the origin, covering the entire image. The purpose of presetting this target position is to fix and map all core facial regions (especially the region centered on the nose) to this standard region, thereby achieving geometric normalization.
[0049] Based on the target alignment position (i.e. the target reference point set), and combined with the corresponding facial feature points in the currently input mask image (denoted as source image S), the position transformation information is determined, which is specifically represented by an affine transformation matrix M.
[0050] Specifically, to determine the source image reference center point C, an empirical face reference center point C is defined in the input N×N mask image S. In a preferred embodiment, this point approximately corresponds to the tip of the nose, and its coordinates are defined as C = (N / 2, N / 2 + 0.1 * N). Here, Cx and Cy represent its horizontal and vertical coordinates, respectively.
[0051] Centered on point C, construct three feature points in the source image S, which correspond one-to-one with the target reference point: S1 = (Cx - N / 2, Cy - N / 2) (expected to correspond to the upper left boundary point of the face region), S2 = (Cx - N / 2, Cy + N / 2) (expected to correspond to the lower left boundary point of the face region), and S3 = (Cx + N / 2, Cy - N / 2) (expected to correspond to the upper right boundary point of the face region). These three points correspond to T1, T2, and T3 respectively.
[0052] To solve for the affine transformation matrix, we can use three pairs of points (S1, T1), (S2, T2), and (S3, T3) to calculate a 6-parameter affine transformation matrix M by using the least squares method or by directly solving the system of linear equations.
[0053] This matrix can be represented as M = |abc| |def |; where (a, b, d, e) determines the rotation, scaling, and shearing transformations, and (c, f) determines the translation transformation. This matrix M represents the desired position transformation information.
[0054] Based on the transformation information (i.e., the affine transformation matrix M), the position of the mask image S is adjusted. For any pixel in the source mask image S, whose coordinates are (x, y) (using homogeneous coordinates (x, y, 1) for calculation), an affine transformation is applied to obtain its corresponding position (x', y') in the target image. The mapping relationship is: x' = a * x + b * y + c; y' = d * x + e * y + f.
[0055] The transformed coordinates are resampled using an image interpolation algorithm (such as bilinear interpolation) to generate a new N×N image, which is the adjusted image T. This process ensures that the value of each pixel in the target image is calculated from the value at the corresponding position in the source image.
[0056] To further conform to the input specifications of the 3D reconstruction model, the adjusted image T is subjected to pixel value normalization processing, T' = T / 255.0, which normalizes the pixel value range from [0, 255] to the interval [0, 1]. The resulting normalized adjusted image T' is then directly used as input for subsequent 3D face reconstruction algorithms.
[0057] In this application, spatial transformation and bias correction effectively eliminate uneven lighting and color distortion, standardizing the input data. Secondly, a pixel-level face segmentation model is used to accurately locate key areas such as skin and facial features, while filtering out non-facial interference factors (such as hair and accessories), ensuring comprehensive analysis and focused targeting. Subsequently, hole-filling optimizes mask integrity, and finally, spatial adjustments are made using preset alignment positions to normalize facial pose. This entire process significantly reduces noise and pose variations, providing high-purity, high-precision input data for subsequent reconstruction algorithms, resulting in more realistic and consistent modeling results at both the geometric and textural levels.
[0058] See Figure 3 This is a flowchart illustrating a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application. Figure 3 As shown, in step S204 above, traversing all the pixels of the processed image to obtain the pixel set corresponding to the filtering label, and performing hole-filling processing on the pixel set to obtain the mask image, may include the following steps: Step S301: Traverse all the pixels of the processed image to obtain all the target pixels whose input to the binary indicator function is a preset conforming value; Step S302: The target pixels are used as the pixel set of the filtering label. The processed image is merged according to the pixel set to obtain a mask image.
[0059] Each pixel (i, j) in the processed image is assigned a classification label value L(i, j), which indicates the category of the facial component to which the pixel belongs. Preset filter labels define one or more target label values as preset matching values. In a preferred embodiment, to generate a mask that focuses on the core facial region and excludes hair and background, the preset matching values typically include label values corresponding to the facial skin region.
[0060] Define a binary indicator function I(i, j) to determine whether the label of each pixel meets the requirements. If L(i, j) ∈ {preset set of matching values}, I(i, j) = 1; otherwise, I(i, j) = 0. Iterate through all N×N pixels of the processed image, and define all pixels (i, j) that satisfy I(i, j) = 1 as target pixels. All target pixels form a set, denoted as P_target. This set P_target is the set of pixels corresponding to the filtering label (e.g., facial skin).
[0061] Based on the pixel set P_target obtained in the previous step, create an initial binary image (or initial mask M_init) of the same size (N × N) as the original image. The creation rule is: if (i, j) ∈ P_target, then M_init(i, j) = 1; otherwise, M_init(i, j) = 0. In this case, the regions with a value of 1 in M_init precisely correspond to the selected target label regions (such as facial skin), but these regions may contain holes due to glasses, shadows, or segmentation errors, and the region boundaries may also have small discontinuities.
[0062] To obtain a continuous and complete facial region mask, the initial mask M_init undergoes morphological hole-filling. One implementation involves first performing a morphological closing operation on M_init. Closing is a process of dilation followed by erosion, using a structuring element of appropriate size (such as a 3×3 or 5×5 rectangular or circular kernel). This operation can bridge small cracks and narrow gaps, smoothing the boundaries of the target region. It connects adjacent small regions, making the mask region more coherent. Then, a specific hole-filling algorithm is applied. That is, an image inverse of M_init is created, M_inv = 1 - M_init. Starting from the outer points of the M_init region boundaries as markers, M_inv is morphologically reconstructed (e.g., through conditional dilation) until stable. This process fills all internal background regions (holes with values of 0) surrounded by regions with a value of 1 (the initial target region) without affecting the real background outside the image. The filled region is then inverted or merged with M_init to obtain the hole-filled image. After the above merging and hole-filling processes, the final binary image is the mask image M_mask. In M_mask, areas with a value of 1 (or white) represent the smoothed and filled, complete and continuous target facial area (mainly the skin area). Areas with a value of 0 (or black) represent non-target areas, including the background, hair, eyes, and inside the mouth.
[0063] In this embodiment, by precisely selecting specific semantic tags (such as facial skin) and performing hole-filling processing, a structurally complete and internally continuous binary mask is generated from the complex pixel-level segmentation results. This mask accurately delineates the core facial region used for 3D reconstruction, largely eliminating interference from non-face rigid components such as hair, background, and clothing, as well as internal holes. This step is closely integrated with subsequent geometric alignment, jointly ensuring that the input to the 3D reconstruction model is a clean, standard, and feature-rich facial region image, laying a crucial data foundation for the accuracy and robustness of subsequent reconstruction.
[0064] See Figure 4 This is a flowchart illustrating a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application. Figure 4 As shown, step S205, which involves determining the position transformation information of the mask image based on the target alignment position, may include the following steps: Step S401: Obtain the preset reference coordinate points of the mask image, and obtain the reference position representation of the target alignment position in the mask image based on the reference coordinate points; Step S402: Determine the position transformation information of the mask image based on the reference position characterization and the target alignment position.
[0065] First, in the N×N mask image (denoted as source image I_src), one or more key reference coordinate points are preset. These points are typically defined based on prior knowledge of the facial structure. In a preferred embodiment, a facial reference center point C is preset as the core reference coordinate point. This point is not obtained through complex feature point detection, but is defined by a formula based on the image size and typical facial proportions to ensure processing consistency and efficiency. For example, C = (C_x, C_y) = (N / 2, N / 2 + offset) Where N is the image side length, and offset is a preset small offset (e.g., 0.1*N) used to place point C slightly below the image center to more closely approximate the common position of the tip of a human nose in an image. Based on the reference coordinate point C, a reference position representation corresponding to the target alignment position in the mask image is obtained. This reference position representation is specifically manifested as the coordinates of the four corner points of a source rectangular region defined with point C as the center. This source rectangular region and the preset target alignment rectangular region (T1, T2, T3, T4 in the target image T) form a spatial correspondence.
[0066] Suppose the target alignment position defines a square region with side length W_t (usually W_t = N), and its top-left corner is located at (0,0). Then the four corner points of the reference position representation in the source image (i.e., the corresponding source rectangle) can be calculated as S1 = (C_x - W_t / 2, C_y - W_t / 2) (corresponding to the target point T1 (0,0)). S2 = (C_x - W_t / 2, C_y + W_t / 2) (corresponding to target point T2 (0, W_t-1)), S3 = (C_x + W_t / 2, C_y - W_t / 2) (corresponding to target point T3 (W_t-1, 0)), S4 = (C_x + W_t / 2, C_y + W_t / 2) (corresponding to target point T4 (W_t-1, W_t-1)). The set {S1, S2, S3} (or {S1, S2, S3, S4}) is the reference position representation. It represents the range and orientation of the facial region in the source mask image I_src that is expected to be aligned with the target standard region.
[0067] A one-to-one mapping relationship is established between the reference position representation point set (e.g., {S1, S2, S3}) in the source image and the preset target alignment position point set (e.g., {T1, T2, T3}). Based on the reference position representation and the target alignment position, the position transformation information of the mask image is determined. In this embodiment, the position transformation information is preferably an affine transformation matrix M.
[0068] Using the established three pairs of corresponding points (S1, T1), (S2, T2), and (S3, T3), the six parameters a, b, c, d, e, and f of the affine transformation matrix M can be calculated by solving a system of linear equations (e.g., using the least squares method to enhance numerical stability). The calculated affine transformation matrix M is the positional transformation information. This matrix encapsulates all the rotation, scaling, translation, and shearing parameters required to accurately map the reference region (the facial region centered at point C) in the source mask image to the target standard square region.
[0069] In this embodiment, through steps S401 and S402, an efficient, stable method for calculating geometric alignment parameters that does not rely on complex external feature point detection is provided. A deterministic correspondence is established between a preset formulaic reference coordinate point (such as the center point near the tip of the nose) and a derived reference position representation (source rectangle) and a preset target alignment position (standard rectangle), and the affine transformation is solved accordingly. This improves the robustness and processing speed of the entire preprocessing workflow, ensuring that regardless of the pose or expression of the input face, its core facial region can be extracted with consistent geometric standards, providing highly normalized input for subsequent 3D reconstruction.
[0070] See Figure 5 This is a flowchart illustrating a face image processing method for three-dimensional face reconstruction provided in an embodiment of this application. Figure 5 As shown, step S205 involves adjusting the position of the mask image based on the transformation information to obtain an adjusted image. This adjusted image is used to perform 3D face reconstruction and may include the following steps: Step S501: Extract the translation data and rotation data from the transformation information.
[0071] Step S502: Based on the translation data and the rotation data, the coordinate points of the mask image are adjusted to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
[0072] After determining the position transformation information (such as the affine transformation matrix M), this transformation needs to be applied to the mask image to obtain a geometrically normalized adjusted image. The position transformation information calculated in the previous step. In a typical implementation, this information is a 3x3 affine transformation matrix M, where the matrix parameters mainly control the image's rotation, scaling, shearing, and translation transformations. The translation component is directly read from matrix M.
[0073] The rotation angle is resolved from a submatrix of matrix M. Specifically, the rotation component can be isolated by performing singular value decomposition or QR decomposition on the submatrix. More directly, in a preferred embodiment, when the transformation is primarily rigid or similar (involving only rotation, scaling, and translation), the rotation angle can be calculated using inverse trigonometric functions.
[0074] This step parses the complex positional transformation information into a set of more intuitive, easier-to-understand, and controllable translation and rotation data. Based on this translation and rotation data, the coordinates of the mask image are adjusted. Specifically, for each pixel coordinate in the mask image, it is adjusted to a new coordinate in the target coordinate system. This process can be represented as first applying rotation (and scaling), then applying translation, or, more generally and efficiently, directly using the previously obtained affine transformation matrix M for a one-time coordinate transformation calculation. Since the target coordinates may not be integers after the coordinate transformation, pixel value resampling is required to generate a new image. Nearest neighbor interpolation is preferred to accurately preserve the region shape. After the above coordinate transformation and image resampling, a new image with the same size as the target alignment position (e.g., a standard square image) is obtained; this is the adjusted image. In this image, the core region of the face (defined by the mask) has been properly centered, aligned, and scaled to a uniform size, completely removing the pose and positional differences from the original image.
[0075] In this embodiment, the adjusted image is used to perform 3D face reconstruction. This image serves as direct input to a subsequent 3D reconstruction model (such as a deep learning-based 3D face reconstruction network). Because its geometric properties have been highly normalized, the model can focus more on learning intrinsic features such as facial identity and expression, rather than adapting to external pose changes, thereby significantly improving the accuracy, consistency, and stability of the 3D face reconstruction results.
[0076] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0077] In one embodiment, a face image processing apparatus for three-dimensional face reconstruction is provided, which corresponds one-to-one with the face image processing method for three-dimensional face reconstruction described in the above embodiments. For example... Figure 6 As shown, the face image processing device for 3D face reconstruction includes a spatial transformation module 61, a deviation correction module 62, a part analysis module 63, a label filtering module 64, and a position adjustment module 65. Detailed descriptions of each functional module are as follows: The spatial transformation module 61 is used to acquire image information of the target face when a target face is detected, and to perform spatial transformation on the image information to obtain a color information image containing at least one color channel. The deviation correction module 62 is used to extract the pixel data corresponding to the color channel in the color information image for each color channel, and perform deviation correction processing on the color information image based on the pixel data to obtain a processed image; The part analysis module 63 is used to input the processed image into a preset face segmentation model for analysis, and obtain the face part label of each pixel in the processed image; The label filtering module 64 is used to filter the face part labels according to the preset target part to obtain the filtered labels, traverse all the pixels of the processed image to obtain the pixel set corresponding to the filtered labels, and perform hole filling processing on the pixel set to obtain the mask image. The position adjustment module 65 is used to obtain a preset target alignment position, determine the position transformation information of the mask image based on the target alignment position, and adjust the position of the mask image based on the transformation information to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
[0078] Optionally, the deviation correction module 62 includes: A pixel extraction unit is used to extract the pixel values corresponding to the color channels in the color information image; The mean value calculation unit is used to calculate the mean value of the pixel values to obtain the pixel mean value; The standard deviation calculation unit is used to calculate the standard deviation of the pixel value to obtain the pixel standard deviation value; The data determination unit is used to use the pixel mean and the pixel standard deviation as pixel data.
[0079] Optionally, the deviation correction module 62 includes: An image matrix determination unit is used to determine an image matrix containing all pixels of the color information image based on the image information. The difference matrix determination unit is used to calculate the difference between the image matrix and the pixel mean to obtain the difference matrix. The ratio calculation unit is used to obtain preset hyperparameters, scale the pixel standard deviation according to the hyperparameters to obtain a scaling difference, and calculate the ratio between the difference matrix and the scaling difference to obtain a ratio matrix. The scaling matrix determination unit is used to perform a product calculation on the ratio matrix and the pixel standard deviation to obtain the scaling matrix; The sum calculation unit is used to calculate the sum of the scaling matrix and the pixel mean to obtain the processed image.
[0080] Optionally, the tag filtering module 64 includes: The conformity value determination unit is used to obtain a preset binary indicator function. If the face part label conforms to the target part, the input of the binary indicator function is the preset conformity value. The label filtering unit is used to filter the facial region labels based on all the matching values to obtain filtered labels.
[0081] Optionally, the tag filtering module 64 includes: The target pixel point determination unit is used to traverse all the pixels of the processed image to obtain all target pixels whose input to the binary indicator function is a preset conforming value; An image merging unit is used to use the target pixels as the pixel set of the filtering label, and to merge the processed image according to the pixel set to obtain a mask image.
[0082] Optionally, the position adjustment module 65 includes: The position characterization unit is used to obtain a preset reference coordinate point of the mask image, and obtain the reference position characterization of the target alignment position in the mask image based on the reference coordinate point. The transformation information determination unit is used to determine the position transformation information of the mask image based on the reference position characterization and the target alignment position.
[0083] Optionally, the position adjustment module 65 includes: The data extraction unit is used to extract translation and rotation data from the transformation information; An image transformation unit is used to adjust the position of the coordinate points of the mask image according to the translation data and the rotation data to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
[0084] This invention provides a facial image processing device for 3D face reconstruction. Through spatial transformation and bias correction, it effectively eliminates uneven lighting and color distortion, standardizing the input data. Secondly, it uses a pixel-level face segmentation model to accurately locate key areas such as skin and facial features, while filtering out non-facial interference factors (such as hair and accessories), ensuring comprehensive analysis and target focus. Subsequently, hole-filling optimizes mask integrity, and finally, spatial adjustment is performed through preset alignment positions to normalize the facial pose. This entire process significantly reduces noise and pose differences, providing high-purity, high-precision input data for subsequent reconstruction algorithms, thereby achieving more realistic and consistent modeling results at both the geometric and textural levels.
[0085] Specific limitations regarding the face image processing device used for 3D face reconstruction can be found in the limitations of the face image processing method used for 3D face reconstruction described above, and will not be repeated here. Each module in the aforementioned face image processing device for 3D face reconstruction can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0086] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a server-side face image processing method for 3D face reconstruction.
[0087] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements client-side functions or steps of a face image processing method for 3D face reconstruction. In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps: When a target face is detected, image information of the target face is acquired, and spatial transformation is performed on the image information to obtain a color information image containing at least one color channel; For each color channel, the pixel data corresponding to the color channel in the color information image is extracted, and the color information image is subjected to deviation correction processing based on the pixel data to obtain a processed image; The processed image is input into a preset face segmentation model for analysis to obtain the face part label for each pixel in the processed image; According to the preset target location, the face location labels are filtered to obtain filter labels. All the pixels in the processed image are traversed to obtain the pixel set corresponding to the filter label. Hole filling processing is performed on the pixel set to obtain the mask image. A preset target alignment position is obtained. Based on the target alignment position, the position transformation information of the mask image is determined. Based on the transformation information, the position of the mask image is adjusted to obtain an adjusted image. The adjusted image is used to perform three-dimensional face reconstruction.
[0088] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor: When a target face is detected, image information of the target face is acquired, and spatial transformation is performed on the image information to obtain a color information image containing at least one color channel; For each color channel, the pixel data corresponding to the color channel in the color information image is extracted, and the color information image is subjected to deviation correction processing based on the pixel data to obtain a processed image; The processed image is input into a preset face segmentation model for analysis to obtain the face part label for each pixel in the processed image; According to the preset target location, the face location labels are filtered to obtain filter labels. All the pixels in the processed image are traversed to obtain the pixel set corresponding to the filter label. Hole filling processing is performed on the pixel set to obtain the mask image. A preset target alignment position is obtained. Based on the target alignment position, the position transformation information of the mask image is determined. Based on the transformation information, the position of the mask image is adjusted to obtain an adjusted image. The adjusted image is used to perform three-dimensional face reconstruction.
[0089] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0090] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0091] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0092] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.
[0093] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
Claims
1. A face image processing method for three-dimensional face reconstruction, characterized in that, include: When a target face is detected, image information of the target face is acquired, and spatial transformation is performed on the image information to obtain a color information image containing at least one color channel; For each color channel, the pixel data corresponding to the color channel in the color information image is extracted, and the color information image is subjected to deviation correction processing based on the pixel data to obtain a processed image; The processed image is input into a preset face segmentation model for analysis to obtain the face part label for each pixel in the processed image; According to the preset target location, the face location labels are filtered to obtain filter labels. All the pixels in the processed image are traversed to obtain the pixel set corresponding to the filter label. Hole filling processing is performed on the pixel set to obtain the mask image. A preset target alignment position is obtained. Based on the target alignment position, the position transformation information of the mask image is determined. Based on the transformation information, the position of the mask image is adjusted to obtain an adjusted image. The adjusted image is used to perform three-dimensional face reconstruction.
2. The face image processing method for three-dimensional face reconstruction according to claim 1, characterized in that, The step of extracting pixel data corresponding to the color channel from the color information image includes: Extract the pixel values corresponding to the color channels from the color information image; The average value of the pixels is calculated by performing an average value calculation on the pixel values. The standard deviation of the pixel values is calculated to obtain the pixel standard deviation value; The pixel mean and the pixel standard deviation are used as pixel data.
3. The face image processing method for three-dimensional face reconstruction according to claim 2, characterized in that, The step of performing deviation correction processing on the color information image based on the pixel data to obtain a processed image includes: Based on the image information, determine an image matrix containing all pixels of the image with the color information; The difference matrix is obtained by calculating the difference between the image matrix and the pixel mean. Obtain preset hyperparameters, scale the pixel standard deviation according to the hyperparameters to obtain a scaling difference, and calculate the ratio between the difference matrix and the scaling difference to obtain a ratio matrix; The scaling matrix is obtained by multiplying the ratio matrix and the pixel standard deviation. The processed image is obtained by summing the scaling matrix and the pixel mean.
4. The face image processing method for three-dimensional face reconstruction according to claim 1, characterized in that, The step of filtering facial region tags based on preset target regions to obtain filtered tags includes: Obtain a preset binary indicator function. If the face part label matches the target part, the input of the binary indicator function is a preset matching value. Based on all the specified matching values, the facial region labels are filtered to obtain filtered labels.
5. The face image processing method for three-dimensional face reconstruction according to claim 4, characterized in that, The process involves traversing all pixels of the processed image to obtain a pixel set corresponding to the filtering label, and then performing hole-filling processing on the pixel set to obtain a mask image, including: Traverse all the pixels of the processed image to obtain all target pixels whose input to the binary indicator function is a preset conforming value; The target pixels are used as the pixel set of the filtering label. The processed image is then merged based on the pixel set to obtain a mask image.
6. The face image processing method for three-dimensional face reconstruction according to claim 1, characterized in that, Determining the position transformation information of the mask image based on the target alignment position includes: Obtain a preset reference coordinate point of the mask image, and based on the reference coordinate point, obtain the reference position representation of the target alignment position in the mask image; Based on the reference position characterization and the target alignment position, the position transformation information of the mask image is determined.
7. The face image processing method for three-dimensional face reconstruction according to claim 1, characterized in that, The step of adjusting the position of the mask image according to the transformation information to obtain an adjusted image, the adjusted image being used to perform 3D face reconstruction, includes: Extract the translation and rotation data from the transformation information; Based on the translation data and the rotation data, the coordinate points of the mask image are adjusted to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
8. A face image processing device for three-dimensional face reconstruction, characterized in that, include: A spatial transformation module is used to acquire image information of the target face when a target face is detected, and to perform spatial transformation on the image information to obtain a color information image containing at least one color channel. The deviation correction module is used to extract the pixel data corresponding to the color channel in the color information image for each color channel, and perform deviation correction processing on the color information image based on the pixel data to obtain a processed image; The part analysis module is used to input the processed image into a preset face segmentation model for analysis, and obtain the face part label of each pixel in the processed image; The label filtering module is used to filter the face region labels according to the preset target region to obtain the filtered labels, traverse all the pixels of the processed image to obtain the pixel set corresponding to the filtered label, and perform hole filling processing on the pixel set to obtain the mask image. The position adjustment module is used to obtain a preset target alignment position, determine the position transformation information of the mask image based on the target alignment position, and adjust the position of the mask image according to the transformation information to obtain an adjusted image, which is used to perform three-dimensional face reconstruction.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the face image processing method for three-dimensional face reconstruction as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the face image processing method for three-dimensional face reconstruction as described in any one of claims 1 to 7.
