Image processing method and device

By acquiring three-dimensional facial data and tonal zoning information of a portrait image, the electronic device can realistically reproduce the light and shadow characteristics of the raised and recessed areas of the face, solving the problem of inaccurate light and shadow judgment in the existing technology and improving the accuracy of portrait tonal optimization.

CN121982271APending Publication Date: 2026-05-05VIVO MOBILE COMM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-29
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing technologies, electronic devices cannot accurately reflect the true light and shadow characteristics of facial protrusions and depressions when performing portrait tonal processing. This results in inaccurate judgment of highlight and shadow areas, and the image processing effect does not conform to the real lighting rules, leading to poor accuracy.

Method used

By acquiring 3D facial data of a portrait image, tonal zoning images are determined, and image processing is performed based on the region boundary image information. The 3D facial data is used to realistically restore the light and shadow characteristics of the raised or recessed areas of the face, thereby improving the recognition accuracy of highlight and shadow areas.

Benefits of technology

This technology improves the accuracy of electronic devices in portrait tone optimization, solves the problem of distorted light and shadow judgment in traditional methods, and makes the identification of highlight and shadow areas more in line with the laws of physical lighting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121982271A_ABST
    Figure CN121982271A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method and device, and belongs to the technical field of image processing, and the method comprises the steps: obtaining face three-dimensional data corresponding to a portrait in a first portrait image; based on the facial three-dimensional data, determining at least one first shadow tone partition image in the first portrait image; acquiring corresponding region boundary image information based on each first shadow tone partition image; and performing image processing on the first portrait image based on the region boundary image information corresponding to each first shadow tone partition image to obtain a second portrait image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing technology, specifically relating to an image processing method and apparatus. Background Technology

[0002] Currently, with the development of electronic devices, electronic devices are becoming increasingly feature-rich. For example, electronic devices can perform portrait tonal processing on images. Portrait tonal processing refers to the different levels of brightness and color in portrait photography, achieved by controlling factors such as light, background, and clothing.

[0003] In related technologies, portrait tonal processing methods are mostly based on adjusting the overall brightness of an image based on information such as pixel brightness and contrast. For example, tonal adjustment is achieved through global brightness histogram adjustment, which involves stretching or compressing the distribution of the global brightness histogram to improve the brightness and darkness of the image.

[0004] However, the aforementioned methods, which adjust tonal values ​​based on image information, cannot reflect the true light and shadow characteristics of facial features in an image, such as the tip of the nose, brow bone, and recesses like the eye sockets and the base of the nose. This leads to inaccurate identification of highlight and shadow areas, and the image processing effect does not conform to the laws of real lighting. Consequently, the accuracy of portrait tonal optimization by electronic devices is poor. Summary of the Invention

[0005] The purpose of this application is to provide an image processing method and apparatus that can improve the accuracy of portrait tone optimization by electronic devices.

[0006] In a first aspect, embodiments of this application provide an image processing method, which includes: acquiring three-dimensional facial data corresponding to a person in a first portrait image; determining at least one first tonal partition image in the first portrait image based on the three-dimensional facial data; acquiring corresponding region boundary image information based on each first tonal partition image; and performing image processing on the first portrait image based on the region boundary image information corresponding to each first tonal partition image to obtain a second portrait image.

[0007] Secondly, embodiments of this application provide an image processing apparatus, comprising: an acquisition module, a determination module, and a processing module. The acquisition module is configured to acquire three-dimensional facial data corresponding to a person in a first portrait image. The determination module is configured to determine at least one first tonal partition image in the first portrait image based on the three-dimensional facial data acquired by the acquisition module. The acquisition module is further configured to acquire corresponding region boundary image information based on each first tonal partition image determined by the determination module. The processing module is configured to perform image processing on the first portrait image based on the region boundary image information corresponding to each first tonal partition image acquired by the acquisition module, to obtain a second portrait image.

[0008] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0009] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0010] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the method as described in the first aspect.

[0011] In a sixth aspect, embodiments of this application provide a computer program / program product stored in a storage medium, which is executed by at least one processor to implement the method described in the first aspect.

[0012] In this embodiment, by using facial 3D data, the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image can be realistically reproduced, making the identification of highlight and shadow areas more consistent with the laws of physical lighting and solving the problem of distorted light and shadow judgment in traditional methods. This improves the accuracy of portrait tone optimization by electronic devices. Attached Figure Description

[0013] Figure 1 This is one of the flowcharts of an image processing method provided in the embodiments of this application;

[0014] Figure 2 This is a second flowchart of an image processing method provided in an embodiment of this application;

[0015] Figure 3 This is the third flowchart of an image processing method provided in the embodiments of this application;

[0016] Figure 4 This is the fourth flowchart of an image processing method provided in the embodiments of this application;

[0017] Figure 5 This is the fifth flowchart of an image processing method provided in the embodiments of this application;

[0018] Figure 6 This is the sixth flowchart of an image processing method provided in the embodiments of this application;

[0019] Figure 7This is the seventh flowchart of an image processing method provided in the embodiments of this application;

[0020] Figure 8 This is a schematic diagram of the structure of an image processing device provided in an embodiment of this application;

[0021] Figure 9 This is one of the hardware structure diagrams of an electronic device provided in the embodiments of this application;

[0022] Figure 10 This is a second schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0023] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0024] The terms "first," "second," etc., used in this application's specification are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects. For example, a first object can be one or more, where "more" means at least two. Furthermore, in the specification, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0025] The terms "at least one" and "at least one of" in this application's specification refer to any one, any two, or a combination of two or more of the included objects. For example, "at least one of a, b, and c" can mean "a", "b", "c", "a and b", "a and c", "b and c", and "a, b, and c", where a, b, and c can be single or multiple, and multiple means at least two. Similarly, "at least two" means two or more, and its meaning is similar to "at least one". The identifiers in this application are text, symbols, images, etc., used to indicate information, and can use controls or other containers as carriers for displaying information, including but not limited to text identifiers, symbol identifiers, and image identifiers.

[0026] The terminology used in the implementation section of this application is only for explaining specific embodiments of this application and is not intended to limit this application. The terminology involved in the embodiments of this application is explained below.

[0027] The image processing method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0028] The image processing method provided in this application embodiment can be applied to scenes with human portrait tonal values.

[0029] Scenario 1, taking portrait photography post-processing optimization as an example, performs portrait toning on a portrait image with uneven facial lighting, such as one side of the face being too dark or the shadow on the nose being too heavy.

[0030] For example, the electronic device extracts the two-dimensional coordinates of 50 key feature points such as eyebrows, eyes, and nose through a facial key point detection algorithm, constructs a three-dimensional facial mesh model, and obtains refined three-dimensional data including vertex depth and curvature after optimization, wherein the vertex depth of the nose tip is 120mm and the curvature of the eye socket area is -5.2.

[0031] Illumination feature acquisition: The electronic device identifies the tip of the nose and brow bone as highlight areas and the eye socket and the bottom of the nose as shadow areas based on the 3D model. The angle between the normal vector of the highlight vertex and the illumination direction is calculated to be 30°. The illumination intensity is quantized to be 0.8 (relative value) by combining the pixel brightness value. The grayscale attenuation gradient of the shadow area is 0.3 / pixel.

[0032] Personalized parameter generation: Electronic devices analyze skin tone as a warm tone using a convolutional neural network, such as Lab space a=15, b=20, and high cheekbones, and generate a personalized parameter set with a brightness baseline value of 180 for the cheek area, a contrast threshold of 40, and a saturation adjustment coefficient of 0.9 for the shadow area under the nose.

[0033] Boundary and pixel optimization: The brightness variation curve of the shadow boundary of the nose base is extracted. When the slope exceeds the threshold, cubic spline interpolation is used for smoothing to generate a pixel-level adjustment mapping table. The local contrast of the cheek area is calculated to be 0.2, and an enhancement weight of 1.2 is assigned. Finally, the optimized image with balanced light and shadow and natural boundaries is obtained through sharpening.

[0034] Based on the scenarios described above in the embodiments of this application, the image processing method provided in this application, through facial 3D data, realistically restores the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image, making the identification of highlight and shadow areas more consistent with the laws of physical lighting, and solving the problem of distorted light and shadow judgment in traditional methods. This improves the accuracy of portrait tone optimization by electronic devices.

[0035] The image processing method provided in this application is executed by an image processing device, which can be an electronic device, or a functional module or entity within an electronic device. This application does not limit the specific implementation of this method. The following will use an electronic device as an example to illustrate the image processing method provided in this application.

[0036] This application provides an image processing method. Figure 1 A flowchart illustrating an image processing method provided in an embodiment of this application is shown. Figure 1 As shown, the image processing method provided in this application embodiment may include the following steps 201 to 204.

[0037] Step 201: The electronic device acquires the three-dimensional facial data corresponding to the portrait in the first portrait image.

[0038] It is understood that the aforementioned first portrait image can be an image containing a human figure.

[0039] Optionally, in this embodiment of the application, the first portrait image may be a portrait image stored in a photo album application in the electronic device; or, it may be a portrait image downloaded by the electronic device through a third-party application; or, it may be a portrait image received by the electronic device through an instant messaging application.

[0040] Optionally, in this embodiment of the application, the above-mentioned three-dimensional facial data may include three-dimensional facial feature information and three-dimensional facial coordinates.

[0041] For example, the aforementioned three-dimensional facial feature information may include at least one of the following: eyebrow feature information, eye feature information, and nose feature information, etc. The specific details can be determined according to actual usage requirements, and this application embodiment does not impose any limitations.

[0042] For example, the aforementioned facial three-dimensional coordinates may include at least one of the following: the three-dimensional coordinates of eyebrows, eyes, and nose. The specific coordinates can be determined according to actual usage requirements, and this application embodiment does not impose any limitations.

[0043] It should be noted that the specific implementation process of step 201 above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0044] Step 202: The electronic device determines at least one first tonal partition image in the first portrait image based on the three-dimensional facial data.

[0045] In this embodiment of the application, the electronic device can determine at least one region to be divided from a first portrait image using facial three-dimensional data, thereby using at least one region to be divided as at least one first tonal partition image.

[0046] It should be noted that the implementation process of step 202 above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0047] Step 203: The electronic device acquires the corresponding region boundary image information based on each first tone partition image.

[0048] Optionally, in the embodiments of this application, the above-mentioned image information includes at least one of the following: brightness reference value, contrast threshold, and saturation adjustment coefficient.

[0049] It should be noted that the implementation process of step 203 above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0050] Step 204: The electronic device performs image processing on the first portrait image based on the region boundary image information corresponding to each first tonal partition image to obtain the second portrait image.

[0051] In this embodiment of the application, the electronic device can perform brightness adjustment processing on the first portrait image through the region boundary image information corresponding to each first tone partition image to obtain the second portrait image.

[0052] In the image processing method provided in this application embodiment, an electronic device can acquire three-dimensional facial data corresponding to the portrait in a first portrait image; then, based on the three-dimensional facial data, determine at least one first tonal partition image in the first portrait image; next, based on each first tonal partition image, acquire corresponding region boundary image information; finally, based on the region boundary image information corresponding to each first tonal partition image, perform image processing on the first portrait image to obtain a second portrait image. In this solution, by using three-dimensional facial data, the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image are realistically restored, making the identification of highlight and shadow areas more consistent with the laws of physical lighting, and solving the problem of distortion in light and shadow judgment using traditional methods. Thus, the accuracy of portrait tonal optimization by the electronic device is improved.

[0053] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 2 As shown, step 201 can be implemented through steps 201a to 201c as described below.

[0054] Step 201a: The electronic device performs facial key point detection on the first portrait image to obtain key point information of at least one facial key point.

[0055] In this embodiment of the application, the information of each key point in the above-mentioned at least one facial key point includes facial key point feature information and facial key point coordinate information.

[0056] Optionally, in this embodiment, the facial key point feature information may include at least one of the following: eyebrow feature information, eye feature information, and nose feature information, etc. The specific details can be determined according to actual usage requirements, and this embodiment does not impose any limitations.

[0057] It should be noted that the coordinate information of the facial key points mentioned above is the two-dimensional coordinate information of the facial key points.

[0058] Optionally, in this embodiment of the application, the electronic device can input the first portrait image into the first model, so as to perform facial key point detection on the first portrait image through the first model and output key point information of at least one facial key point.

[0059] For example, the first model mentioned above can be any of the following: a neural network model or an artificial intelligence (AI) model.

[0060] It should be noted that the specific process by which the electronic device obtains key point information of at least one facial key point through the first model can be found in the description in the relevant technology, and will not be repeated here to avoid repetition.

[0061] Step 201b: The electronic device constructs a face model based on the key point information of each facial key point to obtain a three-dimensional face model.

[0062] In this embodiment, the electronic device can map the coordinate information of facial key points into three-dimensional coordinate points, and combine the topological connection relationship between bones and muscles in facial anatomy to determine the positional association of adjacent key points in three-dimensional space, thereby obtaining a three-dimensional face model.

[0063] For example, the process of an electronic device constructing a 3D facial mesh model based on facial key point data requires a 2D coordinate system as the basic spatial reference. By mapping the 2D coordinates of each key point to a 3D coordinate system, and combining the topological connections between bones and muscles in facial anatomy, the positional relationships of adjacent key points in 3D space are determined. Vertices in the model correspond to the 3D coordinates of key facial features, while edges are used to connect adjacent vertices, forming a polygonal mesh structure that fits the facial contour, thereby accurately reflecting the three-dimensional shape of the face.

[0064] Step 201c: The electronic device performs facial geometric feature extraction processing on the 3D face model to obtain 3D facial data.

[0065] Optionally, in this embodiment of the application, the above-mentioned three-dimensional facial data further includes curvature and depth information.

[0066] For example, an electronic device can use the first model described above to extract facial geometric features from a three-dimensional face model to obtain three-dimensional facial data.

[0067] Optionally, in this embodiment of the application, the electronic device can also optimize facial geometric features through deep learning algorithms to obtain facial three-dimensional data.

[0068] For example, an electronic device can train a deep learning model, such as a convolutional neural network, on a large amount of "high-quality 3D face scan data." Coarse geometric features extracted by the model, such as curvature maps and depth maps, are fed into this network. The network learns to map the coarse input to a smoother, more accurate, and more realistic output. It can "imagine" the shape that occluded parts should have and smooth out unreasonable abrupt changes.

[0069] In this embodiment, the depth and curvature information of the facial 3D mesh model are used to realistically restore the light and shadow characteristics of the protruding or concave areas of the face, making the identification of highlight and shadow areas more in line with the laws of physical lighting, solving the problem of light and shadow judgment distortion in traditional methods, and making light and shadow perception more accurate.

[0070] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 3 As shown, step 202 can be implemented through steps 202a and 202b below.

[0071] Step 202a: The electronic device acquires the illumination direction feature information and illumination intensity feature information in the first portrait image based on the facial three-dimensional data.

[0072] In this embodiment of the application, the electronic device determines the highlight area and shadow area in the first portrait image through facial three-dimensional data, thereby determining the illumination direction feature information based on the highlight area and shadow area, and then determining the illumination intensity feature information through the illumination direction feature information.

[0073] It should be noted that the specific implementation process of step 202a above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0074] Step 202b: The electronic device determines at least one first tonal partition image based on illumination direction feature information and illumination intensity feature information.

[0075] In this embodiment of the application, the electronic device can perform region segmentation on the first portrait image using illumination direction feature information and illumination intensity feature information to obtain at least one first tone partition image.

[0076] It should be noted that the specific implementation process of step 202b above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0077] In this embodiment, the electronic device can make the identification of highlight and shadow areas more consistent with the laws of physical lighting by using the light direction feature information and light intensity feature information, thus solving the problem of light and shadow judgment distortion in traditional methods and making light and shadow perception more accurate.

[0078] Optionally, in this embodiment of the application, the above-mentioned three-dimensional facial data includes: facial geometric attribute information, facial geometric association information, and facial topological structure information.

[0079] For example, combined Figure 3 ,like Figure 4 As shown, step 202a can be implemented through steps 202a1 to 202a3 as described below.

[0080] Step 202a1: The electronic device determines the highlight area and shadow area in the first portrait image based on facial geometric attribute information, facial geometric correlation information and facial topological structure information.

[0081] In this embodiment, the above-mentioned highlight area is an image area in the first portrait image whose brightness value is greater than or equal to a first preset brightness threshold, and the above-mentioned shadow area is an image area in the first portrait image whose brightness value is less than a second preset brightness threshold.

[0082] Optionally, in this embodiment, the first preset brightness threshold can be user-defined or preset by the electronic device. The specific threshold can be determined based on actual usage needs, and this embodiment does not impose any limitations.

[0083] Optionally, in this embodiment, the second preset brightness threshold can be user-defined or preset by the electronic device. The specific threshold can be determined based on actual usage needs, and this embodiment does not impose any limitations.

[0084] Optionally, in the embodiments of this application, the above-mentioned facial geometric attribute information may include at least one of the following: head pose information of facial spatial orientation, facial shape information, facial key point location information of simplified geometric features of the face, etc.

[0085] Optionally, in the embodiments of this application, the above-mentioned facial geometric association information may include at least one of the following: relative position information and connection relationship information of facial organs, distribution and functional information of facial muscles, composition information of facial bones, and facial geometric generalization information.

[0086] For example, the relative position information and connection information of the facial organs mentioned above can be: the eyes are usually located on both sides of the nose, and the mouth is located below the nose. This relative positional relationship will not change due to the rotation of the face or changes in facial expressions.

[0087] For example, the distribution and functional information of the facial muscles mentioned above can be: facial muscles can be divided into two types: circular muscles and radial muscles. They have the function of closing or opening pores and pulsating facial skin to display various expressions such as joy, anger, sorrow, and happiness.

[0088] For example, the above-mentioned facial bone structure information can be: the facial bones are composed of two main categories: the skull of the brain and the facial bones of the face. The facial bones are composed of cheek bones, nasal bones, maxilla, mandible, and teeth.

[0089] For example, the above-mentioned facial geometry summary information can be as follows: the head can be viewed as a cube or an ellipsoid, with the ellipse determining the concepts of uprightness and roundness, and the cube determining the several faces of the head. The frontal bone, zygomatic bone, and mandible are three bony points of the head, determining the transition from the frontal to the lateral aspects of the head.

[0090] It should be noted that the specific process by which the electronic device determines the highlight and shadow areas in the first portrait image through facial geometric attribute information, facial geometric correlation information, and facial topological structure information can be found in the description in the relevant technology. To avoid repetition, it will not be repeated here.

[0091] Step 202a2: The electronic device determines the illumination direction feature information based on the spatial distribution information of the highlight area and shadow area in the first portrait image.

[0092] In this embodiment of the application, the electronic device can identify the spatial distribution of highlights and shadows and determine the direction of light projection based on three-dimensional structural attributes, geometric relationships and topological information, thereby obtaining the characteristic information of the light direction.

[0093] Step 202a3: The electronic device integrates and processes the data of the first angle between the vertex normal vector of the highlight area and the illumination direction, the average brightness value corresponding to the highlight area, and the grayscale attenuation gradient value corresponding to the shadow area to obtain illumination intensity feature information.

[0094] In this embodiment, the electronic device can calculate the angle between the vertex normal vector of the highlight region and the illumination direction through a three-dimensional facial model, quantify the illumination intensity by combining the region pixel brightness value, and supplement the illumination diffusion characteristics by the shadow grayscale attenuation gradient to obtain intensity information.

[0095] For example, when an electronic device calculates the angle between the vertex normal vector of a highlight region and the illumination direction, it first needs to calculate the normal vector of each highlight vertex based on the vertex coordinates of the 3D model. This vector is perpendicular to the local surface where the vertex is located, reflecting the orientation of the surface. After calculating the angle between the two using the vector dot product formula, the relationship between the angle and brightness is quantified into a light intensity value by combining it with the average brightness value of the pixels in the region. At the same time, the gray value attenuation law from the boundary to the interior of the shadow region is analyzed to obtain the gray value attenuation gradient, thereby supplementing the diffusion range and intensity attenuation characteristics of the illumination during the propagation process. Finally, these are integrated to form complete intensity information, providing a quantitative basis for illumination parameters for subsequent tonal zoning.

[0096] In this embodiment, the electronic device can make the identification of highlight and shadow areas more consistent with the laws of physical lighting by using the light direction feature information and light intensity feature information, thus solving the problem of light and shadow judgment distortion in traditional methods and making light and shadow perception more accurate.

[0097] Optionally, in the embodiments of this application, step 202b can be implemented by steps 202b1 to 202b5.

[0098] Step 202b1: The electronic device performs region clustering on the first portrait image based on the illumination direction feature information and illumination intensity feature information to obtain at least one tonal region.

[0099] In this embodiment of the application, the electronic device can perform region clustering on regions where the illumination direction feature information and illumination intensity feature information are consistent, so as to obtain at least one tonal region.

[0100] Step 202b2: The electronic device extracts boundary features from the image in each tonal region to obtain the boundary image feature information corresponding to each first tonal region.

[0101] Optionally, in this embodiment of the application, the electronic device can use a clustering algorithm to automatically divide the first portrait image into several regions with continuous light and shadow characteristics, i.e. at least one preliminary tonal region, based on multi-dimensional features such as light intensity, geometric position, and curvature. Then, the partition boundary features of the preliminary tonal region are extracted to obtain a set of boundary features.

[0102] For example, an electronic device can identify all pixels located at the boundaries of different regions by comparing their pixel values ​​with those of their neighbors pixel by pixel, and then use a boundary tracking algorithm to connect these points into a continuous contour line. Based on the contour line, a set of boundary features is then obtained.

[0103] Step 202b3: The electronic device performs texture analysis and lighting processing on each boundary feature information to obtain the lighting distribution data corresponding to each boundary feature information.

[0104] In this embodiment of the application, the electronic device can perform texture analysis on the boundary feature set through a preset convolutional neural network model to generate texture distribution features. Then, it can calculate the light and shadow optimization coefficients according to the texture distribution features to optimize the regional light and shadow, thereby obtaining the light and shadow distribution data corresponding to each boundary feature information.

[0105] For example, when an electronic device calculates the lighting optimization coefficient based on texture distribution characteristics, it is necessary to first clarify the texture attributes of each partition, including quantitative indicators such as texture density, direction, and complexity. Taking each partition as a unit, the key parameters in the texture distribution characteristics, such as texture entropy value and gradient magnitude, are compared with the preset lighting optimization benchmark value. The lighting optimization coefficient corresponding to each partition is calculated using the following formula (1). This coefficient reflects the magnitude and direction of lighting adjustment within the partition. Subsequently, the coefficient is applied to the lighting data adjustment of the corresponding partition, and the brightness gain of the highlight area and the degree of preservation of dark details in the shadow area are optimized in a targeted manner. Finally, the optimized lighting distribution data of each partition with lighting parameters adapted to its texture characteristics is obtained.

[0106] For example, the above formula (1) can be specifically:

[0107] (1)

[0108] Where K is the lighting optimization coefficient. For target brightness, This represents the average brightness value of the current tonal area. The texture sensitivity weight is obtained based on the texture entropy value H. α is the brightness adjustment factor, ranging from 0.8 to 1.2, and β is the edge protection factor, ranging from 1.5 to 2.5. This is the absolute value of the regional brightness gradient, used to suppress edge blurring caused by over-optimization.

[0109] Step 202b4: The electronic device performs color correction on the light and shadow distribution data to obtain a color distribution map.

[0110] In this embodiment of the application, the electronic device can perform color correction on light and shadow distribution data using a preset color correction algorithm to obtain a color distribution map.

[0111] It should be noted that the specific process by which electronic devices obtain color distribution maps can be found in the descriptions in relevant technologies, and will not be repeated here to avoid repetition.

[0112] Step 202b5: The electronic device performs region segmentation on the first portrait image based on the color distribution map to obtain at least one first tonal partition image.

[0113] In this embodiment, the electronic device can construct a three-dimensional mesh model through facial key points and accurately identify the distribution of highlights and shadows by combining geometric features such as vertex depth and curvature, thus overcoming the limitations of traditional two-dimensional image light and shadow judgment.

[0114] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 5 As shown, step 203 can be implemented through steps 203a to 203c as described below.

[0115] Step 203a: The electronic device performs feature extraction processing on each first tone zone image to obtain skin color feature information and bone feature information corresponding to each first tone zone image.

[0116] In this embodiment of the application, the electronic device can extract skin color features and bone features from the images in each first tone partition image through a preset convolutional neural network model, so as to obtain skin color feature information and bone feature information corresponding to each first tone partition image.

[0117] Step 203b: The electronic device performs quantitative analysis on the skin color feature information and bone feature information corresponding to each first tone partition image, and generates personalized tone parameters corresponding to each first tone partition image.

[0118] In this embodiment of the application, the personalized tone parameters include a brightness reference value, a contrast threshold, and a saturation adjustment coefficient.

[0119] In this embodiment, the electronic device uses a fully connected layer of a convolutional neural network model to perform quantitative analysis on the extracted structural feature data and outputs a personalized tone parameter set containing the brightness reference value, contrast threshold, and saturation adjustment coefficient of each zone.

[0120] Step 203c: The electronic device performs gradient fusion smoothing on the brightness values ​​of the boundary pixels of each first tone partition image based on the personalized tone parameters corresponding to each first tone partition image, so as to obtain the region boundary information corresponding to each tone partition image.

[0121] In this embodiment of the application, the above-mentioned region boundary information includes the gradient decay coefficient and the fusion radius threshold.

[0122] It should be noted that the fusion radius threshold is a distance value, usually in pixels. It defines how large the "range of influence" extends to both sides, such as the highlight area and the shadow area, when performing boundary smoothing, centered on the boundary pixel.

[0123] In this embodiment of the application, the electronic device can perform a weighted average calculation on the highlight-shadow boundary pixels of the tonal partition using the boundary transition parameters in the personalized tonal parameter set to generate region boundary information.

[0124] For example, an electronic device can define a range of neighboring pixels for calculation, centered on the boundary pixel, based on a fusion radius threshold. Pixels on the highlight side within this range are assigned a weight that decreases with increasing distance, while pixels on the shadow side are assigned a weight that increases with increasing distance. The weight decay is controlled by a gradient decay coefficient. A weighted average is then calculated on the brightness values ​​of all pixels within the neighborhood according to their corresponding weights, replacing the brightness values ​​of the original boundary pixels. This transforms the brightness changes between the highlight and shadow regions from abrupt changes to a continuous, gradual transition, ultimately forming smooth boundary information without obvious discontinuities.

[0125] In this embodiment, the electronic device utilizes a convolutional neural network model to analyze skin color and skeletal structure features, outputting personalized parameters such as brightness baseline values ​​and contrast thresholds adapted to different regions, achieving targeted adjustments for tone optimization. Furthermore, based on the gradient decay coefficient and fusion radius threshold, a weighted average calculation is performed on the highlight-shadow boundary pixels to generate smooth transition boundary data without abrupt changes, resolving the issue of harsh boundaries. In other words, the electronic device combines skin color and skeletal structure features analyzed by the convolutional neural network to generate a personalized tone parameter set adapted to different facial shapes, achieving "personalized optimization" for each individual and avoiding the insufficient adaptability problem caused by fixed templates. Moreover, this application, based on the weighted average calculation of the gradient decay coefficient and fusion radius threshold, ensures a continuous and gradual change in brightness at the highlight-shadow boundary while preserving details, thus resolving the issue of boundary discontinuities.

[0126] Optionally, in the embodiments of this application, combined with Figure 1 ,like Figure 6 As shown, step 204 can be implemented through steps 204a and 204b below.

[0127] Step 204a: The electronic device performs curve fitting processing based on the regional boundary image information corresponding to each first tone partition image to obtain the brightness variation curve.

[0128] It should be noted that the specific process of curve fitting for electronic devices can be found in the descriptions in relevant technologies, and will not be repeated here to avoid repetition.

[0129] Step 204b: The electronic device performs brightness adjustment processing on the first portrait image based on the brightness variation curve to obtain the second portrait image.

[0130] In this embodiment of the application, the electronic device can determine the brightness value that needs to be adjusted for each pixel in the first portrait image by using the brightness change curve, and thus adjust the brightness value of each pixel in the first portrait image by adjusting the brightness value.

[0131] It should be noted that the specific implementation of step 204b above can be found in the following embodiments, and will not be repeated here to avoid repetition.

[0132] In this embodiment, facial 3D data is used to realistically reproduce the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image, making the identification of highlight and shadow areas more consistent with the laws of physical lighting and solving the problem of distorted light and shadow judgment in traditional methods. This improves the accuracy of portrait tone optimization by electronic devices.

[0133] Optionally, in the embodiments of this application, combined with Figure 6 ,like Figure 7 As shown, step 204b can be implemented through steps 204b1 and 204b2 as described below.

[0134] Step 204b1: When the slope of the brightness variation curve is greater than or equal to a preset slope threshold, the electronic device performs cubic spline interpolation on the brightness variation curve to obtain the interpolated brightness variation curve.

[0135] In this embodiment of the application, the electronic device can smooth the brightness variation curve by cubic spline interpolation to obtain the interpolated brightness variation curve.

[0136] Step 204b2: The electronic device performs brightness adjustment processing on the first portrait image based on the interpolated brightness variation curve to obtain the second portrait image.

[0137] In this embodiment of the application, the electronic device can generate a pixel-level adjustment mapping table through the interpolated brightness variation curve.

[0138] For example, an electronic device can input the brightness value of each pixel in the first portrait image into the interpolated brightness variation curve to obtain the target brightness value corresponding to each pixel, and then adjust the brightness value of each pixel in the first portrait image through the target brightness value corresponding to each pixel to obtain the second portrait image.

[0139] In this embodiment, the electronic device obtains the interpolated brightness variation curve through curve fitting and interpolation adjustment, and adjusts the brightness value of the first portrait image through the interpolated brightness variation curve, thereby improving the accuracy of the electronic device in adjusting the brightness value of the first portrait image.

[0140] Optionally, in the embodiments of this application, step 204b2 can be specifically implemented through steps 301 to 303 as described below.

[0141] Step 301: The electronic device performs brightness adjustment processing on the first portrait image based on the interpolated brightness change curve to obtain the adjusted first portrait image.

[0142] In this embodiment of the application, the electronic device can update the pixel brightness values ​​of the first portrait image by adjusting the pixel-level mapping table to obtain a tone-optimized image.

[0143] Step 302: The electronic device performs brightness enhancement processing on the adjusted first portrait image to obtain the processed first portrait image.

[0144] In this embodiment, the electronic device can extract the brightness distribution features of the tone-optimized image and calculate the local contrast according to the preset area to generate an enhancement weight matrix.

[0145] For example, when an electronic device extracts the brightness distribution features of a tone-optimized image, it needs to statistically analyze the brightness value of each pixel in the image and calculate the global brightness mean, variance, and frequency distribution of brightness values. The image is divided into multiple local regions according to a preset grid size. A local contrast calculation formula is applied to each region to obtain its contrast value. Based on the deviation between the region's contrast value and a preset contrast benchmark value, the enhancement weight for each region is determined. Regions with contrast values ​​lower than the benchmark value are assigned a weight greater than 1 to enhance contrast, while regions with contrast values ​​higher than the benchmark value are assigned a weight less than 1 to suppress excessive contrast. The weight values ​​range from 0.5 to 1.5, ultimately forming an enhancement weight matrix that corresponds one-to-one with the image pixel positions.

[0146] For example, the local contrast mentioned above is calculated using the following formula (2).

[0147] (2)

[0148] in, R represents local contrast, and R represents the local region. Let N be the set of pixel brightness within a local area, and N be the number of pixels in the area. The average brightness of the area. , The standard deviation of brightness, It is a very small constant.

[0149] Then, the electronic device can perform point-by-point calculations on the enhancement weight matrix and the pixel brightness values ​​of the tone-optimized image to obtain a contrast-optimized image through secondary adjustments.

[0150] Step 303: The electronic device performs edge sharpening processing on the processed portrait image to obtain a second portrait image.

[0151] In this embodiment, the electronic device can extract edge sharpening parameters from the contrast-optimized image, and use the Laplacian operator in combination with these parameters for sharpening processing to obtain a second portrait image.

[0152] In this embodiment, the electronic device achieves a complete tonal optimization chain from 3D structure to final image through multi-step collaborative optimization, including curve fitting and interpolation adjustment, local contrast enhancement, and edge sharpening. This forms a complete technical closed loop from 3D structure extraction to pixel-level optimization, with clear data flow at each step: 3D structure → illumination features → tonal zoning → boundary optimization → pixel adjustment. Compared to the fragmented optimization of existing technologies, this approach is more systematic and comprehensive.

[0153] It should be noted that the above-described method embodiments, or the various possible implementations of the method embodiments, can be executed individually, or, provided there are no contradictions, they can be combined with each other. The specific implementation can be determined according to actual usage requirements, and this application embodiment does not impose any restrictions on this.

[0154] It should be noted that the image processing method provided in this application embodiment can be executed by an image processing device. This application embodiment uses an image processing device executing the image processing method as an example to illustrate the image processing device provided in this application embodiment.

[0155] Figure 8 A schematic diagram of a possible structure of the image processing apparatus involved in an embodiment of this application is shown. For example... Figure 8 As shown, the image processing device 70 may include: an acquisition module 71, a determination module 72, and a processing module 73.

[0156] The acquisition module 71 is used to acquire the three-dimensional facial data corresponding to the portrait in the first portrait image. The determination module 72 is used to determine at least one first tonal partition image in the first portrait image based on the three-dimensional facial data acquired by the acquisition module. The acquisition module 71 is also used to acquire the corresponding region boundary image information based on the image information of each first tonal partition image determined by the determination module. The processing module 73 is used to perform image processing on the first portrait image based on the region boundary image information corresponding to each first tonal partition image acquired by the acquisition module to obtain a second portrait image.

[0157] In one possible implementation, the processing module 73 is specifically used to perform facial key point detection on the first portrait image to obtain key point information of at least one facial key point, each key point information including facial key point feature information and facial key point coordinate information; and to construct a face model based on the key point information of each facial key point to obtain a three-dimensional face model; and to perform facial geometric feature extraction processing on the three-dimensional face model to obtain three-dimensional facial data.

[0158] In one possible implementation, the acquisition module 71 is specifically used to acquire illumination direction feature information and illumination intensity feature information in the first portrait image based on facial 3D data. The determination module 72 is specifically used to determine at least one first tonal partition image based on the illumination direction feature information and illumination intensity feature information.

[0159] In one possible implementation, the aforementioned three-dimensional facial data includes: facial geometric attribute information, facial geometric association information, and facial topological structure information. The determining module 72 is specifically used to determine the highlight region and shadow region in the first portrait image based on the facial geometric attribute information, facial geometric association information, and facial topological structure information. The highlight region is an image region in the first portrait image with a brightness value greater than or equal to a first preset brightness threshold, and the shadow region is an image region in the first portrait image with a brightness value less than a second preset brightness threshold. Based on the spatial distribution information of the highlight region and shadow region in the first portrait image, it determines the illumination direction feature information. The processing module 73 is specifically used to perform data integration processing on the first angle between the vertex normal vector of the highlight region and the illumination direction, the average brightness value corresponding to the highlight region, and the grayscale attenuation gradient value corresponding to the shadow region to obtain illumination intensity feature information.

[0160] In one possible implementation, the aforementioned processing module 73 is specifically used to perform region clustering on the first portrait image based on illumination direction feature information and illumination intensity feature information to obtain at least one tonal region; extract boundary features from the image in each tonal region to obtain boundary image feature information corresponding to each tonal region; perform texture analysis and light and shadow processing on each boundary feature information to obtain light and shadow distribution data corresponding to each boundary feature information; perform color correction on the light and shadow distribution data to obtain a color distribution map; and perform region segmentation on the first portrait image based on the color distribution map to obtain at least one first tonal partition image.

[0161] In one possible implementation, the aforementioned processing module 73 is specifically used to perform feature extraction processing on each first tone partition image to obtain skin color feature information and bone feature information corresponding to each first tone partition image; and to perform quantitative analysis on the skin color feature information and bone feature information corresponding to each first tone partition image to generate personalized tone parameters corresponding to each first tone partition image; the personalized tone parameters include a brightness reference value, a contrast threshold, and a saturation adjustment coefficient; and based on the personalized tone parameters corresponding to each first tone partition image, to perform gradient fusion smoothing processing on the brightness values ​​of the boundary pixels of each first tone partition image to obtain the region boundary information corresponding to each first tone partition image.

[0162] In one possible implementation, the aforementioned processing module 73 is specifically used to perform curve fitting processing based on the regional boundary image information corresponding to each first tonal partition image to obtain a brightness variation curve; and to perform brightness adjustment processing on the first portrait image based on the brightness variation curve to obtain a second portrait image.

[0163] In one possible implementation, the processing module 73 is specifically used to perform cubic spline interpolation on the brightness variation curve when the slope of the brightness variation curve is greater than or equal to a preset slope threshold, to obtain the interpolated brightness variation curve; and based on the interpolated brightness variation curve, to perform brightness adjustment processing on the first portrait image to obtain the second portrait image.

[0164] In one possible implementation, the aforementioned processing module 73 is specifically used to perform brightness adjustment processing on the first portrait image based on the interpolated brightness variation curve to obtain the adjusted first portrait image; and to perform brightness enhancement processing on the adjusted first portrait image to obtain the processed first portrait image; and to perform edge sharpening processing on the processed portrait image to obtain the second portrait image.

[0165] In the image processing apparatus provided in this application embodiment, the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image are realistically restored using facial 3D data. This makes the identification of highlight and shadow areas more consistent with the laws of physical lighting, solving the problem of distortion in light and shadow judgment in traditional methods. Thus, the accuracy of the image processing apparatus in optimizing portrait tonal values ​​is improved.

[0166] The image processing device in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television set (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the device.

[0167] The image processing device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.

[0168] The image processing apparatus provided in this application embodiment can implement the various processes implemented in the above method embodiments, and will not be described again here to avoid repetition.

[0169] Optionally, such as Figure 9 As shown, this application embodiment also provides an electronic device 90, including a processor 91 and a memory 92. The memory 92 stores a program or instructions that can run on the processor 91. When the program or instructions are executed by the processor 91, they implement the various steps of the above-described image processing method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0170] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.

[0171] Figure 10 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of this application.

[0172] The electronic device 100 includes, but is not limited to, components such as: radio frequency unit 101, network module 102, audio output unit 103, input unit 104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, and processor 110.

[0173] Those skilled in the art will understand that the electronic device 100 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 110 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 10 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.

[0174] The processor 110 is configured to acquire three-dimensional facial data corresponding to the portrait in the first portrait image; and based on the three-dimensional facial data, determine at least one first tone partition image in the first portrait image; and based on each first tone partition image, acquire corresponding region boundary image information; and based on the region boundary image information corresponding to each first tone partition image, perform image processing on the first portrait image to obtain a second portrait image.

[0175] Optionally, in this embodiment of the application, the processor 110 is specifically used to perform facial key point detection on the first portrait image to obtain key point information of at least one facial key point, each key point information including facial key point feature information and facial key point coordinate information; based on the key point information of each facial key point, to construct a face model to obtain a three-dimensional face model; and to perform facial geometric feature extraction processing on the three-dimensional face model to obtain three-dimensional facial data.

[0176] Optionally, in this embodiment of the application, the processor 110 is specifically used to obtain illumination direction feature information and illumination intensity feature information in the first portrait image based on facial three-dimensional data; and to determine at least one first tonal partition image based on the illumination direction feature information and illumination intensity feature information.

[0177] Optionally, in this embodiment, the aforementioned three-dimensional facial data includes: facial geometric attribute information, facial geometric association information, and facial topological structure information; the aforementioned processor 110 is specifically used to determine the highlight region and shadow region in the first portrait image based on the facial geometric attribute information, facial geometric association information, and facial topological structure information, wherein the highlight region is an image region in the first portrait image whose brightness value is greater than or equal to a first preset brightness threshold, and the shadow region is an image region in the first portrait image whose brightness value is less than a second preset brightness threshold; determine the illumination direction feature information based on the spatial distribution information of the highlight region and the shadow region in the first portrait image; and perform data integration processing on the first angle between the vertex normal vector of the highlight region and the illumination direction, the average brightness value corresponding to the highlight region, and the grayscale attenuation gradient value corresponding to the shadow region to obtain the illumination intensity feature information.

[0178] Optionally, in this embodiment of the application, the processor 110 is specifically configured to: perform region clustering on the first portrait image based on illumination direction feature information and illumination intensity feature information to obtain at least one tonal region; extract boundary features from the image in each tonal region to obtain boundary image feature information corresponding to each tonal region; perform texture analysis and light and shadow processing on each boundary feature information to obtain light and shadow distribution data corresponding to each boundary feature information; perform color correction on the light and shadow distribution data to obtain a color distribution map; and perform region segmentation on the first portrait image based on the color distribution map to obtain at least one first tonal partition image.

[0179] Optionally, in this embodiment, the processor 110 is specifically configured to perform feature extraction processing on each first tone partition image to obtain skin color feature information and bone feature information corresponding to each first tone partition image; perform quantitative analysis on the skin color feature information and bone feature information corresponding to each first tone partition image to generate personalized tone parameters corresponding to each first tone partition image; the personalized tone parameters include a brightness reference value, a contrast threshold, and a saturation adjustment coefficient; and perform gradient fusion smoothing processing on the brightness values ​​of the boundary pixels of each first tone partition image based on the personalized tone parameters corresponding to each first tone partition image to obtain the region boundary information corresponding to each first tone partition image.

[0180] Optionally, in this embodiment of the application, the processor 110 is specifically used to perform curve fitting processing based on the regional boundary image information corresponding to each first tone partition image to obtain a brightness variation curve; and to perform brightness adjustment processing on the first portrait image based on the brightness variation curve to obtain a second portrait image.

[0181] Optionally, in this embodiment of the application, the processor 110 is specifically used to perform cubic spline interpolation on the brightness variation curve when the slope of the brightness variation curve is greater than or equal to a preset slope threshold, to obtain the interpolated brightness variation curve; and to perform brightness adjustment processing on the first portrait image based on the interpolated brightness variation curve to obtain the second portrait image.

[0182] Optionally, in this embodiment of the application, the processor 110 is specifically used to perform brightness adjustment processing on the first portrait image based on the interpolated brightness variation curve to obtain the adjusted first portrait image; perform brightness enhancement processing on the adjusted first portrait image to obtain the processed first portrait image; and perform edge sharpening processing on the processed portrait image to obtain the second portrait image.

[0183] In the electronic device provided in this application embodiment, the light and shadow characteristics of the raised or recessed areas of the face in the first portrait image are realistically reproduced using three-dimensional facial data. This makes the identification of highlight and shadow areas more consistent with the laws of physical lighting, solving the problem of distortion in light and shadow judgment in traditional methods. Thus, the accuracy of the electronic device in optimizing portrait tonal values ​​is improved.

[0184] The electronic device provided in this application embodiment can implement the various processes implemented in the above method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0185] For details on the beneficial effects of the various implementation methods in this embodiment, please refer to the beneficial effects of the corresponding implementation methods in the above method embodiments. To avoid repetition, these will not be repeated here.

[0186] It should be understood that, in this embodiment, the input unit 104 may include a graphics processing unit (GPU) 1041 and a microphone 1042. The GPU 1041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 106 may include a display panel 1061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 107 includes at least one of a touch panel 1071 and other input devices 1072. The touch panel 1071 is also called a touch screen. The touch panel 1071 may include a touch detection device and a touch controller. Other input devices 1072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.

[0187] The memory 109 can be used to store software programs and various data. The memory 109 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 109 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DRRAM). The memory 109 in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.

[0188] Processor 110 may include one or more processing units; optionally, processor 110 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 110.

[0189] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0190] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0191] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above method embodiments and achieve the same technical effect. To avoid repetition, it will not be described again here.

[0192] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0193] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the above method embodiments and achieve the same technical effects. To avoid repetition, it will not be described again here.

[0194] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0195] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0196] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. An image processing method, characterized in that, The method includes: Obtain the 3D facial data corresponding to the portrait in the first portrait image; Based on the facial 3D data, at least one first tonal partition image is determined in the first portrait image; Based on each of the first tonal partition images, obtain the corresponding region boundary image information; Based on the region boundary image information corresponding to each of the first tonal partition images, the first portrait image is processed to obtain the second portrait image.

2. The method according to claim 1, characterized in that, The step of obtaining the facial 3D data corresponding to the portrait in the first portrait image includes: Facial key point detection is performed on the first portrait image to obtain key point information of at least one facial key point. Each key point information includes facial key point feature information and facial key point coordinate information. Based on the key point information of each facial key point, a face model is constructed to obtain a three-dimensional face model; The facial geometric features of the three-dimensional face model are extracted to obtain the three-dimensional facial data.

3. The method according to claim 1, characterized in that, The step of determining at least one first tonal partition image in the first portrait image based on the facial 3D data includes: Based on the facial 3D data, the illumination direction feature information and illumination intensity feature information in the first portrait image are obtained; Based on the illumination direction feature information and illumination intensity feature information, the at least one first tone zone image is determined.

4. The method according to claim 3, characterized in that, The facial 3D data includes: facial geometric attribute information, facial geometric association information, and facial topological structure information; The step of obtaining illumination direction feature information and illumination intensity feature information in the first portrait image based on the facial 3D data includes: Based on the facial geometric attribute information, facial geometric association information, and facial topological structure information, highlight areas and shadow areas in the first portrait image are determined. The highlight areas are image areas in the first portrait image with brightness values ​​greater than or equal to a first preset brightness threshold, and the shadow areas are image areas in the first portrait image with brightness values ​​less than a second preset brightness threshold. Based on the spatial distribution information of the highlight area and the shadow area in the first portrait image, the illumination direction feature information is determined; The illumination intensity feature information is obtained by integrating the data of the first angle between the vertex normal vector of the highlight region and the illumination direction, the average brightness value corresponding to the highlight region, and the grayscale attenuation gradient value corresponding to the shadow region.

5. The method according to claim 3, characterized in that, Determining the at least one first tonal partition image based on the illumination direction feature information and illumination intensity feature information includes: Based on the illumination direction feature information and illumination intensity feature information, the first portrait image is clustered to obtain at least one tonal region. Boundary features are extracted from the image in each tonal region to obtain the boundary image feature information corresponding to each tonal region; Texture analysis and lighting processing are performed on each boundary feature to obtain the lighting distribution data corresponding to each boundary feature. Color correction is performed on the light and shadow distribution data to obtain a color distribution map; Based on the color distribution map, the first portrait image is segmented into regions to obtain at least one first tone partition image.

6. The method according to claim 1, characterized in that, The step of obtaining the corresponding region boundary image information based on each of the first tonal partition images includes: Feature extraction processing is performed on each of the first tonal partition images to obtain skin color feature information and bone feature information corresponding to each of the first tonal partition images; The skin color feature information and bone feature information corresponding to each of the first tonal partition images are quantitatively analyzed to generate personalized tonal parameters for each of the first tonal partition images; the personalized tonal parameters include a brightness reference value, a contrast threshold, and a saturation adjustment coefficient. Based on the personalized tonal parameters corresponding to each of the first tonal partition images, gradient fusion smoothing is performed on the brightness values ​​of the boundary pixels of each of the first tonal partition images to obtain the region boundary information corresponding to each of the first tonal partition images.

7. The method according to claim 1, characterized in that, The step of processing the first portrait image based on the region boundary image information corresponding to each of the first tonal zoning images to obtain the second portrait image includes: Based on the region boundary image information corresponding to each of the first tonal partition images, curve fitting is performed to obtain the brightness variation curve. Based on the brightness variation curve, the brightness of the first portrait image is adjusted to obtain the second portrait image.

8. The method according to claim 7, characterized in that, The step of adjusting the brightness of the first portrait image based on the brightness variation curve to obtain the second portrait image includes: If the slope of the brightness variation curve is greater than or equal to a preset slope threshold, cubic spline interpolation is performed on the brightness variation curve to obtain the interpolated brightness variation curve. Based on the interpolated brightness variation curve, the brightness of the first portrait image is adjusted to obtain the second portrait image.

9. The method according to claim 8, characterized in that, The process of adjusting the brightness of the first portrait image based on the interpolated brightness variation curve to obtain the second portrait image includes: Based on the interpolated brightness variation curve, the brightness of the first portrait image is adjusted to obtain the adjusted first portrait image. The first portrait image is then subjected to brightness enhancement processing based on the adjusted first portrait image to obtain the processed first portrait image; The processed first portrait image is then subjected to edge sharpening processing to obtain the second portrait image.

10. An image processing apparatus, characterized in that, The image processing device includes: an acquisition module, a determination module, and a processing module; The acquisition module is used to acquire the three-dimensional facial data corresponding to the portrait in the first portrait image; The determining module is used to determine at least one first tone partition image in the first portrait image based on the facial three-dimensional data acquired by the acquiring module. The acquisition module is further configured to acquire corresponding region boundary image information based on each of the first tonal partition images determined by the determining module; The processing module is used to perform image processing on the first portrait image based on the region boundary image information corresponding to each of the first tonal partition images acquired by the acquisition module, to obtain a second portrait image.