Portrait image processing method and device, computer device, readable storage medium and program product
By generating multi-layered masks and performing regional processing with brightness and color temperature compensation in the color space, the problem of local highlight overexposure on the face in traditional techniques is solved, improving the quality of portrait images and the accuracy of face recognition, thus meeting the standards for ID photos.
Patent Information
- Application Number
- CN202611389556.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-08
- Publication Date
- 2026-11-20
AI Technical Summary
Traditional image preprocessing methods struggle to address overexposed highlights in specific areas of the face, resulting in low facial recognition accuracy and difficulty in meeting standardized requirements for ID photos. In particular, when capturing portraits under complex lighting conditions, issues such as localized overexposure and uneven contrast can easily occur.
By generating masks for the portrait area, skin area, hair area, highlight area, and hairline area, the brightness data is processed in different regions using a color space image matrix, including brightness enhancement and color temperature compensation. This ensures that brightness adjustment is decoupled from color information, avoids misjudging skin texture as an overexposed area, and maintains the brightness ratio between skin and hair.
It improves the quality of facial images, meets the standardized requirements of self-service equipment for ID photos and real-name authentication, avoids the defects of images in traditional technology processing, and ensures the accuracy of facial recognition and the consistency of visual effects.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This application relates to the field of image technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for processing human portrait images. Background Technology
[0002] With the widespread adoption of self-service devices in finance, government affairs, and other sectors, facial recognition has become a core means of identity verification. Self-service terminals are typically deployed in open environments such as lobbies and outdoors, where facial image capture faces complex lighting conditions, such as strong light, backlighting, side lighting, shadows, and dynamic lighting changes. These factors can easily lead to problems such as localized overexposure and uneven contrast in the captured facial images.
[0003] To improve the accuracy of face recognition, traditional image preprocessing methods typically employ global or local enhancement techniques such as histogram equalization and adaptive histogram equalization to adjust the overall image.
[0004] However, traditional global enhancement methods such as histogram equalization struggle to specifically address overexposed areas of the face, often damaging skin texture details while darkening highlights. Furthermore, traditional methods lack fine-grained processing of the skin-hair boundary, easily leading to unnatural hairline cuts and unwanted stray hairs. Therefore, even the processed portrait images suffer from these defects, failing to meet the accuracy requirements for facial recognition and the standardization requirements for ID photos. Summary of the Invention
[0005] Therefore, it is necessary to provide a portrait image processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the quality of portrait images and meet the requirements of facial recognition accuracy and ID photo standardization, in order to address the above-mentioned technical problems.
[0006] In a first aspect, this application provides a portrait image processing method applied to a self-service device, the method comprising: Acquire a target portrait image, and based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face; The target portrait image is converted to the target color space to obtain a color space image matrix, and the brightness channel data is extracted from the color space image matrix to obtain the original global brightness data. Based on the original global brightness data, the skin region mask, and the highlight region mask, the updated first brightness data is obtained; Based on the difference between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on the pixels within the hair region mask and the hairline region mask to obtain an optimized color space image matrix. Based on the portrait region mask and the optimized color space image matrix, a standard portrait image is determined.
[0007] In one embodiment, generating a portrait region mask and skin region masks, hair region masks, highlight region masks, and hairline region masks based on the target portrait image includes: Semantic segmentation and key point detection are performed concurrently on the target portrait image to obtain semantic segmentation results and key point detection results, respectively. Based on the semantic segmentation results, a human image region mask is generated to mark the human image region. Based on the key point detection processing results, a skin region mask is generated to mark the skin area of the human face, a hair region mask is generated to mark the hair area, a highlight region mask is generated to mark the highlight area, and a hairline region mask is generated to mark the hairline transition area.
[0008] In one embodiment, obtaining the updated first brightness data based on the original global brightness data, the skin region mask, and the highlight region mask includes: The original global brightness data corresponding to the skin region mask is filtered and extracted to obtain ambient illumination data. The skin area mask and the highlight area mask are superimposed, and the overlapping area is taken as the effective processing area. The updated first brightness data is obtained based on each pixel in the effective processing area, the value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data.
[0009] In one embodiment, obtaining the updated first brightness data based on each pixel in the effective processing area, the value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data includes: For each pixel in the effective processing area, query the value corresponding to that pixel in the ambient illumination data of the skin area mask; Pixels with values greater than a threshold value are identified as pixels to be processed in the skin region mask. For each pixel to be processed, the local brightness data in the original global brightness data corresponding to the pixel to be processed is calculated through a nonlinear soft-truncation mapping curve to obtain new local brightness data. The new local brightness data replaces the local brightness data in the original global brightness data to obtain the updated first brightness data.
[0010] In one embodiment, the step of performing brightness enhancement on pixels within the hair region mask and the hairline region mask based on the difference between the original global brightness data and the first brightness data within the skin region mask to obtain an optimized color space image matrix includes: Within the masked area of the skin region, the first brightness data is subtracted from the original global brightness data pixel by pixel to determine the amount of brightness change; Based on the aforementioned change in brightness, determine the brightness following coefficient; For pixels within the hair region mask area, a first unidirectional brightness enhancement is performed on the local brightness data in the original global brightness data corresponding to the pixel using the brightness following coefficient; for pixels within the hairline region mask area, a second unidirectional brightness enhancement is performed on the local brightness data in the original global brightness data corresponding to the pixel; wherein, the intensity of the second unidirectional brightness enhancement decreases from the skin side to the hair side within the hairline region mask area, resulting in the second brightness data of the brightness channel; The optimized color space image matrix is determined based on the second brightness data.
[0011] In one embodiment, determining the optimized color space image matrix based on the second brightness data includes: The color channel data is extracted from the color space image matrix to obtain the original global color data; Within the skin region mask area, the chromaticity reference value of the skin region mask is determined based on the original global color data; Based on the chromaticity reference value and the standard chromaticity reference value, the color temperature offset of the skin area mask is determined; The color temperature of the original global color data is adjusted based on the color temperature offset to obtain the updated global color data of the color channels; Based on the second brightness data and the global color data, the optimized color space image matrix is determined.
[0012] In one embodiment, determining the standard portrait image based on the portrait region mask and the optimized color space image matrix includes: The optimized color space image matrix is converted back to the original color space to obtain the image to be refined. Edge restoration processing is performed on the portrait area mask to generate a closed portrait mask; Based on the hairline region mask, perform a fusion transition process on the corresponding pixels in the image to be refined to generate a transition image; Based on the closed portrait mask, a preset background color is filled outside the portrait outline of the transition image to obtain a standard portrait image.
[0013] Secondly, this application also provides a facial image processing device for use in self-service equipment, the device comprising: The acquisition module is used to acquire a target portrait image and, based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face. The generation module is used to convert the target portrait image to the target color space to obtain a color space image matrix, and extract the brightness channel data from the color space image matrix to obtain the original global brightness data. The brightness update module is used to obtain the updated first brightness data based on the original global brightness data, the skin area mask, and the highlight area mask; The follow adjustment module is used to perform brightness enhancement on pixels within the range of the hair area mask and the hairline area mask based on the difference between the original global brightness data and the first brightness data within the skin area mask, so as to obtain an optimized color space image matrix. The determination module is used to determine a standard portrait image based on the portrait region mask and the optimized color space image matrix.
[0014] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0015] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0016] The aforementioned portrait image processing method, apparatus, computer equipment, computer-readable storage medium, and computer program product first acquire a target portrait image, and based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face; simultaneously, acquire multi-level spatial location information of the portrait region, skin region, hair region, highlight sensitive region, and hairline transition region, providing precise spatial constraint boundaries for subsequent refined regional processing, and avoiding blind processing across the entire image in subsequent operations. Secondly, the target portrait image is converted to the target color space to obtain a color space image matrix, and the luminance channel data is extracted from the color space image matrix to obtain the original global luminance data. Based on the original global luminance data, skin area mask, and highlight area mask, the updated first luminance data is obtained. By converting the image to a color space with an independent luminance channel, the brightness adjustment and color information are completely decoupled. The brightness adjustment operation will not introduce color shift, and an independent color adjustment dimension is reserved for subsequent color temperature compensation. In addition, the updated luminance can accurately distinguish between the real overexposure caused by ambient light and the reflection of the skin's own texture details, avoiding the misjudgment of facial highlight textures (such as natural oiliness on the cheekbones) as overexposed areas and incorrectly darkening them, thus completely preserving the skin's micro-texture. Secondly, based on the differences between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on pixels within the hair region mask and hairline region mask to obtain an optimized color space image matrix. By performing a unidirectional brightness enhancement on the hair region according to the brightness change in the skin region, the hair brightness changes in the same direction as the skin brightness rather than being processed independently, maintaining the original brightness-dark ratio between the skin and hair and avoiding visual brightness-dark discontinuities caused by adjusting only the skin brightness. Finally, based on the portrait region mask and the optimized color space image matrix, a standard portrait image is determined, improving the image quality of the output standard portrait image and avoiding defects left in images processed by traditional techniques. This ensures that the standard portrait image meets the consistent background requirements of self-service equipment for ID photos and real-name authentication standards. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating a portrait image processing method in one embodiment; Figure 2This is a schematic diagram illustrating the process of generating a portrait region mask and skin region masks, hair region masks, highlight region masks, and hairline region masks based on a target portrait image in one embodiment. Figure 3 This is a schematic diagram of the process for obtaining the updated first brightness data in one embodiment; Figure 4 This is a schematic diagram of the process for obtaining the updated first brightness data in another embodiment; Figure 5 This is a flowchart illustrating the process of obtaining an optimized color space image matrix based on the difference between the original global brightness data and the first brightness data within the skin region mask in one embodiment. Figure 6 This is a flowchart illustrating the step of determining the optimized color space image matrix based on second brightness data in one embodiment. Figure 7 This is a flowchart illustrating the steps for determining a standard human portrait image in one embodiment; Figure 8 This is a structural block diagram of a human image processing device in one embodiment; Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0020] In one embodiment, such as Figure 1 As shown, a portrait image processing method is provided. This embodiment illustrates the application of this method to a self-service device. In this embodiment, the method includes the following steps S102 to S110. Wherein: Step S102: Obtain the target portrait image, and based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face.
[0021] Among them, the portrait region mask is a set of pixels in the target portrait image that belong to the portrait theme. It is used to distinguish the person from the background. The coverage area includes the head area of the human body (including all components of the portrait such as facial skin, hair, and facial features), but does not include the background in the image (such as walls, trees, counters, etc.).
[0022] The skin area mask is a set of pixels within the portrait area that marks the exposed skin of the face. It is the primary area affected by subsequent brightness adjustment operations. Spatially, it covers all exposed skin surrounding the facial features, including the forehead, cheekbones, cheeks, nose, and chin. It excludes: hair, eyebrows, eyes (including eyelids), lips, and ears (if obscured by hair, they are not included).
[0023] The hair region mask is located inside the portrait region, marking the set of pixels belonging to the hair area. It is the primary area for brightness following and color temperature protection. Spatially, it covers the hair area on the top of the head, the back of the head, and the sideburns. This area is located inside the portrait region mask and outside the skin region mask, adjacent to the skin region at the hairline. Hair region = Portrait region − Skin region.
[0024] Highlight area mask is a set of pixels that marks the high-risk areas of the face most prone to overexposure. It is a triangular area (or elliptical / polygonal area) formed by the highest points of the left and right cheekbones and the center of the eyebrows as vertices. It covers the upper central part of the face, including the center of the eyebrows, the upper part of the bridge of the nose, and the protruding parts of the left and right cheekbones. These are the areas of the face where the light is most concentrated and where local overexposure of highlights is most likely to occur.
[0025] The hairline area mask marks the set of pixels at the transition zone between the skin and hair. Spatially, it is a strip-shaped area that extends along the forehead contour line inward to the inside of the forehead, spanning both sides of the hairline and covering part of the forehead skin and part of the hairline edge.
[0026] Optionally, the self-service device captures original human portrait images via a camera. These original images are pixel-formatted in RGB color space. Due to differences in height, position, and other factors, the dimensions of the original images captured by the camera vary. Therefore, the original images are resized to a preset standard size. Then, the resized original format (RGB) is converted to a standard RGB matrix format, where each pixel consists of three channel values (R, G, B), ranging from 0 to 255, resulting in the target human portrait image. Resizing the original human portrait image is optional; it can be omitted.
[0027] Optionally, the self-service device inputs the target portrait image into the machine learning model and receives the portrait region mask, as well as the skin region mask, hair region mask, highlight region mask, and hairline region mask of the portrait face output by the machine learning model.
[0028] Step S104: Convert the target portrait image to the target color space to obtain a color space image matrix, and extract the brightness channel data from the color space image matrix to obtain the original global brightness data.
[0029] The target color space includes the CIELAB color space.
[0030] Optionally, the self-service device converts the pixel format of the target portrait image from the standard RGB color space to the CIEXYZ color space to obtain an XYZ image. The XYZ image is then converted to the CIELAB color space to obtain a color space image matrix, or LAB image matrix, with pixel format in the CIELAB color space. Each pixel in the color space image matrix has (L, a, b) values comprising three channels: L channel (luminance channel): a value range of 0 to 100, representing the brightness of the pixel, with 0 being pure black and 100 being pure white; A channel (red-green channel): a value range of approximately -128 to 127, with positive values leaning towards red and negative values towards green; and B channel (yellow-blue channel): a value range of approximately -128 to 127, with positive values leaning towards yellow and negative values towards blue.
[0031] Furthermore, the self-service device extracts the brightness channel (L channel) data from the LAB image matrix as the raw global brightness data of the LAB image matrix.
[0032] Step S106: Based on the original global brightness data, skin region mask, and highlight region mask, the updated first brightness data is obtained.
[0033] Among them, the first brightness data is the global brightness data. In the first brightness data, the brightness value corresponding to the pixel of the skin area mask is less than that of the corresponding pixel in the original global brightness data.
[0034] Optionally, the self-service device performs nonlinear soft-truncation mapping curve calculation based on the original global brightness data, skin area mask, and highlight area mask to obtain partially updated local brightness data, thereby obtaining the updated first brightness data, avoiding the appearance of dead white areas where the skin is too bright and lacks texture.
[0035] Step S108: Based on the difference between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on the pixels within the hair region mask and the hairline region mask to obtain the optimized color space image matrix.
[0036] Optionally, the self-service device performs brightness enhancement on pixels in other areas, such as the hair area mask and hairline area mask, based on the difference between the original global brightness data and the first brightness data within the skin area mask. For example, if the skin is dark, the hair will also be slightly darker, and if the skin is bright, the hair will also be slightly brighter. The change in brightness is gradual at the hairline, with the brightness on the side closer to the skin being greater than the brightness closer to the hair, thus obtaining an optimized color space image matrix.
[0037] Step S110: Determine the standard portrait image based on the portrait region mask and the optimized color space image matrix.
[0038] Optionally, the self-service device determines the standard portrait image by using a facial image region mask and an optimized color space image matrix. This improves the quality of the standard portrait image, making it suitable for subsequent ID photos or real-name authentication requirements.
[0039] In the above-mentioned portrait image processing method, firstly, the target portrait image is acquired. Based on the target portrait image, a portrait region mask and a mask for the skin region, hair region, highlight region, and hairline region of the face are generated. At the same time, multi-level spatial location information of the portrait region, skin region, hair region, highlight sensitive region, and hairline transition region is acquired, which provides accurate spatial constraint boundaries for subsequent refined regional processing and avoids blind processing of the entire image in subsequent operations. Secondly, the target portrait image is converted to the target color space to obtain a color space image matrix, and the luminance channel data is extracted from the color space image matrix to obtain the original global luminance data. Based on the original global luminance data, skin area mask, and highlight area mask, the updated first luminance data is obtained. By converting the image to a color space with an independent luminance channel, the brightness adjustment and color information are completely decoupled. The brightness adjustment operation will not introduce color shift, and an independent color adjustment dimension is reserved for subsequent color temperature compensation. In addition, the updated luminance can accurately distinguish between the real overexposure caused by ambient light and the reflection of the skin's own texture details, avoiding the misjudgment of facial highlight textures (such as natural oiliness on the cheekbones) as overexposed areas and incorrectly darkening them, thus completely preserving the skin's micro-texture. Secondly, based on the differences between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on pixels within the hair region mask and hairline region mask to obtain an optimized color space image matrix. By performing a unidirectional brightness enhancement on the hair region according to the brightness change in the skin region, the hair brightness changes in the same direction as the skin brightness rather than being processed independently, maintaining the original brightness-dark ratio between the skin and hair and avoiding visual brightness-dark discontinuities caused by adjusting only the skin brightness. Finally, based on the portrait region mask and the optimized color space image matrix, a standard portrait image is determined, improving the image quality of the output standard portrait image and avoiding defects left in images processed by traditional techniques. This ensures that the consistent background requirements of self-service equipment for ID photos or real-name authentication standards are met.
[0040] In one exemplary embodiment, such as Figure 2 As shown, based on the target portrait image, a portrait region mask and a mask for the skin region, hair region, highlight region, and hairline region of the portrait face are generated, including the following steps S202 to S206. Wherein: Step S202: Perform semantic segmentation and key point detection processing concurrently on the target portrait image to obtain the semantic segmentation processing result and the key point detection processing result, respectively.
[0041] Optionally, a semantic segmentation model and a facial landmark detection model are deployed in the self-service device. The semantic segmentation model is called in parallel to perform semantic segmentation processing on the target portrait image, and the facial landmark detection model is called to perform landmark detection processing on the target portrait image, so as to obtain the semantic segmentation processing result and the landmark detection processing result respectively.
[0042] Step S204: Generate a human image region mask that marks the human image region based on the semantic segmentation processing result.
[0043] The semantic segmentation result includes the probability value of each pixel in the target portrait image belonging to the portrait region.
[0044] Optionally, the self-service device binarizes the probability value of each pixel according to a set probability threshold. This includes: pixels with a probability value greater than or equal to the probability threshold are marked with a first value (e.g., 1), indicating they belong to the portrait region; pixels with a probability value less than the probability threshold are marked with a second value (e.g., 0), indicating they belong to the background region. After binarization, a portrait region mask is generated that marks the portrait region.
[0045] Step S206: Based on the key point detection processing results, generate a skin region mask that marks the skin area of the human face, a hair region mask that marks the hair area, a highlight region mask that marks the highlight area, and a hairline region mask that marks the hairline transition area.
[0046] The key point detection and processing results include points 0 to 16 arranged along the outer contour of the face (from the right mandible through the chin to the left mandible), points 17 to 21 arranged along the left eyebrow, points 22 to 26 arranged along the right eyebrow, point 27 located in the center of the eyebrows, points 28 to 30 arranged along the bridge of the nose, points 31 to 35 located at the nasal wings and tip of the nose, points 36 to 41 arranged around the left eye, points 42 to 47 arranged around the right eye, and points 48 to 67 arranged around the mouth.
[0047] Optionally, the self-service device uses a closed polygon formed by connecting facial contour points 0 to 16 sequentially as the boundary of the facial region, and marks the pixels inside the closed polygon as the skin region. Although the facial features (eyebrows, eyes, lips) in the portrait are located inside the closed polygon, in actual operation, they can be finely removed through the skin recognition results of semantic segmentation or further key point subdivision (such as eye contour points, mouth contour points), ultimately retaining the exposed facial skin area and generating a skin region mask.
[0048] The self-service device marks the remaining part of the portrait region mask that does not belong to the skin region mask as the hair region, that is, hair region mask = portrait region mask - skin region mask.
[0049] The self-service device reads the coordinates of point 15 (right cheekbone) and point 16 (left cheekbone), using the line connecting these two points as the base; it reads the coordinates of point 27 (between the eyebrows), using this point as the vertex; the two endpoints of the base and the vertex together form a triangular area, which is marked as the highlight area mask. Optionally, these three points can also be used to determine an elliptical area as the highlight area mask.
[0050] The self-service device reads the coordinate sequence of points 17 to 26 (forehead contour points), connects these points sequentially to form a forehead contour line. Based on this forehead contour line, it extends a preset pixel width (e.g., 10 to 20 pixels) inwards towards the face to form a strip-shaped area, which is marked as the hairline area mask.
[0051] In this embodiment, by performing semantic segmentation and key point detection in parallel, computing resources can be fully utilized, and the overall processing time can be shortened while ensuring the accuracy of regional positioning, thus meeting the real-time requirements of self-service terminals.
[0052] In one exemplary embodiment, such as Figure 3 As shown, based on the original global brightness data, skin region mask, and highlight region mask, the updated first brightness data is obtained, including steps S302 to S306. Wherein: Step S302: Perform filtering and extraction processing on the original global brightness data corresponding to the skin area mask to obtain ambient illumination data.
[0053] Among them, the ambient illuminance data is in matrix form.
[0054] Optionally, before performing the filtering extraction process, the self-service device pre-sets filtering parameters, such as the kernel size and standard deviation of the Gaussian low-pass filter. The kernel size determines the neighborhood range in which each pixel participates in the filtering operation, and the standard deviation controls the cutoff frequency of the filter. The larger the standard deviation, the lower the frequency components retained, and the more texture details are filtered out. The standard deviation and kernel size are adaptively matched.
[0055] Optionally, the self-service device reads a skin region mask, which is a binary matrix. Using the skin region mask as a spatial constraint, the effective range of this filtering process is determined. That is, only the pixel positions marked as valid by the mask are processed, and the pixel positions marked as invalid by the mask (hair, background, facial features, etc.) are not included in this filtering operation.
[0056] Furthermore, the self-service device uses the skin region mask as a boundary constraint to traverse each pixel. For the current pixel, within a neighborhood defined by the kernel size, it calculates the weight coefficients of each pixel in the neighborhood using a Gaussian distribution. The brightness values of all pixels in the neighborhood are then weighted and summed according to their corresponding weights. The result is used as the filtered output value for that pixel location. Since the Gaussian low-pass filter removes high-frequency components (i.e., texture details such as pores, fine lines, and tiny reflective points on the skin surface), the filtered output value represents the macroscopic ambient light intensity of the area where the pixel is located. The filtering results are arranged according to the spatial coordinates of the target portrait image to form an ambient light data matrix. This ambient light data matrix has the same size as the target portrait image and only has valid filtered output values at pixel locations marked by the skin region mask. Pixel locations outside the skin region are set to null or zero values and do not participate in subsequent judgments.
[0057] Instead of using the original brightness value directly as the criterion, the ambient illuminance is extracted within the skin area. This allows overexposure judgment to be based on the overall lighting of the area rather than local texture highlights, avoiding misjudging skin details such as pores and oil as overexposed and incorrectly darkening them, thus fully preserving skin texture.
[0058] Step S304: Overlay the skin area mask and the highlight area mask, and use the overlapping area as the effective processing area.
[0059] Optionally, the self-service device performs a pixel-by-pixel logical AND operation on the two masks (skin region mask and highlight region mask), including: traversing each pixel position in the image and determining the pixel's marker value in the skin region mask and its marker value in the highlight region mask. The pixel is marked as valid only if it is marked as valid in both masks; otherwise, it is marked as invalid. The region marked as valid, i.e., the overlapping region, represents the area containing the set of pixels that simultaneously satisfy the condition of being located within the highlight region and identified as facial skin.
[0060] By overlaying the skin area mask and the highlight area mask and taking their intersection, the brightness adjustment is ensured to only apply to the highlight areas identified as skin. Even if keypoint detection drifts, hair and background areas are excluded, thus preventing erroneous operations.
[0061] Step S306: Based on each pixel in the effective processing area, the corresponding value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data, the updated first brightness data is obtained.
[0062] Optionally, the self-service device iterates through each pixel in the effective processing area, i.e., each pixel marked as effective in both masks, and reads the corresponding value in the ambient illumination data of the generated skin area mask. This value represents the macroscopic ambient light intensity of the skin area where the pixel is located, i.e., the brightness value after removing texture details.
[0063] Furthermore, the self-service device calculates a new local brightness value based on the corresponding value of the pixel in the ambient illumination data of the skin area mask and the original global brightness data through a nonlinear soft-truncation mapping curve. The new local brightness value replaces the corresponding value in the original global brightness data, thereby obtaining the updated global first brightness data. This makes the brightness change of the target portrait image continuous and the layers preserved, without any visible abrupt changes.
[0064] In this embodiment, skin texture preservation, anti-misprocessing of non-skin areas, and smooth transition after darkening are achieved by using ambient illumination data, mask intersection verification, and brightness update.
[0065] In one exemplary embodiment, such as Figure 4 As shown, the updated first brightness data is obtained based on each pixel in the effective processing area, the corresponding value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data, including steps S402 to S408. Wherein: Step S402: For each pixel in the effective processing area, query the corresponding value of the pixel in the ambient illumination data of the skin area mask.
[0066] Step S404: Pixels with values greater than the numerical threshold are identified as pixels to be processed in the skin region mask.
[0067] Optionally, the self-service device iterates through each pixel in the effective processing area, reading the corresponding value from the ambient illumination data of the generated skin area mask. If the value threshold is set to 85, a value greater than the threshold indicates extremely strong ambient light, placing the skin in an overexposure risk zone. A value less than the threshold indicates normal ambient illumination; even if the L value at that point is high (e.g., a very small oily spot), it is not processed, preserving the original skin texture. The self-service device identifies pixels with values greater than the threshold as the pixels to be processed in the skin area mask.
[0068] Step S406: For each pixel to be processed, the local brightness data in the original global brightness data corresponding to the pixel to be processed is calculated through a non-linear soft-truncation mapping curve to obtain new local brightness data.
[0069] Optionally, for each pixel to be processed, the self-service device retrieves the local brightness data of that pixel in the original brightness data, inputs it into the nonlinear soft-truncation mapping curve for calculation, and outputs a compressed new local brightness data (lower than the local brightness data, but retaining texture undulations).
[0070] Step S408: Replace the local brightness data in the original global brightness data with the new local brightness data to obtain the updated first brightness data.
[0071] Optionally, the self-service device only replaces the original brightness values of the pixels to be processed with the newly calculated local brightness data. Pixels within the effective area that are not identified as pixels to be processed, as well as all pixels outside the effective area (including all hair, background, and normal areas on the skin), retain their original brightness values, thus completing the update of the original global brightness data and obtaining the first brightness data.
[0072] In this embodiment, ambient illuminance is used instead of the original brightness as the criterion to avoid accidentally darkening texture details; combined with nonlinear soft truncation to achieve smooth compression, the brightness transition is natural after the highlights are darkened and the skin texture is completely preserved.
[0073] In one exemplary embodiment, such as Figure 5 As shown, based on the difference between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on the pixels within the hair region mask and the hairline region mask to obtain the optimized color space image matrix, including steps S502 to S508. Wherein: Step S502: Within the skin area mask, the first brightness data is subtracted from the original global brightness data pixel by pixel to determine the brightness change.
[0074] Among them, the change in brightness is used to indicate the degree of adjustment of the overall brightness of the skin area. A positive value means that the skin is brightened, and a negative value means that the skin is darkened.
[0075] Optionally, within the skin area mask area, the self-service device calculates the difference between the first brightness data and the original global brightness data pixel by pixel to obtain the brightness difference value of each skin pixel, and then takes the arithmetic mean of all brightness differences to obtain the average brightness change of the skin area, and uses the average brightness change value as the brightness change value.
[0076] Step S504: Determine the brightness following coefficient based on the brightness change.
[0077] The brightness following coefficient refers to the percentage increase in brightness that the hair and hairline areas should receive in the same direction as the skin area after the skin area has been adjusted for brightness. The brightness following coefficient is positively correlated with the amount of brightness change in the skin area. Its value ranges from 30% to 50%.
[0078] Optionally, if the change in brightness is less than or equal to the first value, it indicates a very small brightening effect, and the lower limit of the brightness following coefficient range is used, such as 30%; if the change in brightness is greater than or equal to the second value, it indicates a very large brightening effect, and the upper limit of the brightness following coefficient range is used, such as 50%; if the change in brightness is between the first and second values, the brightness following coefficient value is calculated by linear interpolation. The first value is less than the second value.
[0079] Step S506: For pixels within the mask area of the hair region, perform a first same-direction brightness enhancement on the local brightness data in the original global brightness data corresponding to the pixel using a brightness following coefficient; for pixels within the mask area of the hairline region, perform a second same-direction brightness enhancement on the local brightness data in the original global brightness data corresponding to the pixel to obtain the second brightness data of the brightness channel.
[0080] Among them, the intensity of the second unidirectional brightness enhancement decreases from the skin side to the hair side within the mask area of the hairline region.
[0081] The second brightness data is also the global brightness data.
[0082] Optionally, for pixels within the mask area of the hair region, the self-service device performs a first unidirectional brightness enhancement on the local brightness data in the original global brightness data corresponding to the pixel using a brightness following coefficient.
[0083] The principle behind simultaneous brightness enhancement: While brightening the skin makes it appear whiter and more translucent, if the hair remains dark, a stark contrast occurs at the skin-hair boundary—"very bright skin, very dark hair"—creating an unnatural visual effect, as if two people are spliced together. Enhancing the hair's brightness by 30% to 50% of the skin's brightness maintains the original light-dark ratio between the skin and hair, resulting in a harmonious and unified overall image.
[0084] Optionally, for pixels within the mask area of the hairline region, the brightness of hair pixels closer to the skin is set to the upper limit of the brightness following coefficient, while the brightness of hair pixels farther from the skin is set to the lower limit of the brightness following coefficient, in order to avoid abrupt brightness jumps at the hairline.
[0085] Furthermore, the self-service device increases the brightness of the hair area mask and the hairline area mask to obtain a second brightness data.
[0086] Step S508: Determine the optimized color space image matrix based on the second brightness data.
[0087] Optionally, the self-service device determines the L-channel data of the optimized color space image matrix based on the second brightness data.
[0088] In this embodiment, the hair brightness follows the skin brightness change in the same direction to maintain brightness coordination. The intensity of the hairline area is gradually increased to avoid abrupt brightness changes at the boundary, so that the output image achieves global coordination and uniformity in brightness.
[0089] In one exemplary embodiment, such as Figure 6 As shown, the optimized color space image matrix is determined based on the second brightness data, including steps S602 to S610. Wherein: Step S602: Extract color channel data from the color space image matrix to obtain the original global color data.
[0090] The color channels include the A channel and the B channel.
[0091] Optionally, the self-service device extracts data from two color channels (A channel and B channel) from the LAB image matrix as the raw global color data of the LAB image matrix.
[0092] Step S604: Within the skin region mask area, determine the chromaticity reference value of the skin region mask based on the original global color data.
[0093] Optionally, within the skin region mask area, the self-service device performs statistical analysis on the first and second chroma channel data in the original global color data. This includes: traversing each pixel marked by the skin region mask, reading the value of that pixel in the first and second chroma channels, calculating the arithmetic mean of all skin pixels in the first and second chroma channels respectively, and combining these two averages as the chroma reference value of the skin region mask. This chroma reference value represents the actual chroma distribution of the skin region in the current image.
[0094] Step S606: Determine the color temperature offset of the skin area mask based on the colorimetric reference value and the standard colorimetric reference value.
[0095] Among them, the standard colorimetric reference value represents the colorimetric standard of skin tone under standard lighting conditions.
[0096] Optionally, the self-service device reads a preset standard chromaticity reference value, compares the chromaticity reference value with the standard chromaticity reference value, and calculates the difference between the two in the first chromaticity channel and the second chromaticity channel respectively, to obtain the first chromaticity channel offset and the second chromaticity channel offset. These two offsets are used as the color temperature offset of the skin area mask. A positive color temperature offset indicates that the current skin tone is warm (reddish or yellowish), and a negative value indicates that the current skin tone is cool (blued or greenish).
[0097] Step S608: Adjust the color temperature of the original global color data based on the color temperature offset to obtain the updated global color data of the color channels.
[0098] Optionally, the self-service device performs reverse correction on the first and second chroma channel data in the original global color data based on the color temperature offset. This includes: traversing each pixel globally, subtracting the first chroma channel offset from the original value of the pixel in the first chroma channel by multiplying it by a preset correction intensity coefficient to obtain the updated first chroma channel value for that pixel; and subtracting the second chroma channel offset from the original value of the pixel in the second chroma channel by multiplying it by the preset correction intensity coefficient to obtain the updated second chroma channel value for that pixel. The preset correction intensity coefficient is positively correlated with the brightness adjustment range of the skin area. Within the masked areas of the hair region and hairline region, the correction intensity coefficient is halved to prevent color temperature correction from causing hair color distortion. After traversing all pixels, the updated global data for the first and second chroma channels is obtained.
[0099] Step S610: Determine the optimized color space image matrix based on the second brightness data and global color data.
[0100] The global color data includes A-channel data and B-channel data.
[0101] Optionally, the self-service device determines the optimized color space image matrix based on the L-channel luminance data, A-channel data, and B-channel data.
[0102] In this embodiment, while increasing brightness, color temperature compensation corrects skin tone color cast and halve the correction intensity in the hair area to prevent hair color distortion, ultimately achieving global coordination and unity in brightness and color of the output image.
[0103] In one exemplary embodiment, such as Figure 7 As shown, a standard portrait image is determined based on the portrait region mask and the optimized color space image matrix, including steps S702 to S708. Wherein: Step S702: Convert the optimized color space image matrix to the original color space to obtain the image to be refined.
[0104] The optimized color space image matrix includes luminance channel data and color channel data, and its pixel format is presented in LAB format.
[0105] Optionally, the self-service device can reverse convert the optimized color space image matrix back to the original color space, such as standard RGB, to obtain an image to be refined in standard RGB pixel format. This includes: first converting the optimized color space image matrix to the CIE XYZ color space, and then converting it from the CIE XYZ color space to the sRGB color space. The converted values can also be gamma-corrected and encoded to restore them to standard 8-bit integer pixel values.
[0106] Step S704: Perform edge repair processing on the portrait area mask to generate a closed portrait mask.
[0107] Among them, the closed portrait mask is a mask obtained by performing a morphological closing operation on the portrait region mask.
[0108] Optionally, the self-service device performs morphological closing operations on the portrait area mask, first expanding and then eroding to fill the small holes (such as gaps between hair strands) inside the mask and connect adjacent isolated hair fragment pixels, so that the mask edges are continuous and smooth, generating a closed portrait mask with a complete outline.
[0109] Step S706: Based on the hairline region mask, perform a fusion transition process on the corresponding pixels in the image to be refined to generate a transition image.
[0110] Optionally, the self-service device performs a blending transition process within the corresponding hairline band in the image to be refined, based on a hairline area mask. This includes: calculating gradient weights within a preset feathering width, with weights on the skin side approaching complete preservation of the current processing effect, weights on the hair side approaching a complete transition to the original image effect, and weights in the middle area transitioning smoothly linearly or with an S-shaped curve; and weighting each pixel according to these weights to achieve a smooth transition in brightness and color at the hairline junction, eliminating splicing artifacts and generating a transition image. In this transition image, only the hairline area pixels are re-blended, while the rest remain consistent with the image to be refined.
[0111] It should be noted that steps S704 and S706 can be executed in parallel or sequentially.
[0112] Step S708: Based on the closed portrait mask, fill the outside of the portrait outline of the transition image with a preset background color to obtain a standard portrait image.
[0113] Optionally, the self-service device reads a closed portrait mask and extracts the portrait outline from it. Using this outline as a reference, it extends outwards by a predetermined distance (e.g., five to fifteen pixels) to form a strip-shaped fill area. Within this strip-shaped fill area, corresponding pixels in the transition image are forcibly replaced with a preset background color (e.g., pure white or pure blue). The main portrait pixels inside the portrait outline remain unchanged. After the background filling is complete, a standard portrait image is output.
[0114] In this embodiment, edge repair and blending transition are performed in parallel and are independent of each other. The former repairs the silhouette outline of the portrait, while the latter smooths out the color gap of the hairline. Finally, they merge in the background filling step. While preserving the optimized brightness and color effect of the portrait subject, a standardized portrait with complete outline, natural hairline and pure background is generated, which can directly meet the image quality requirements of self-service equipment for ID photos and real-name authentication standards.
[0115] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0116] Based on the same inventive concept, this application also provides a portrait image processing apparatus for implementing the portrait image processing method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more portrait image processing apparatus embodiments provided below can be found in the limitations of the portrait image processing method described above, and will not be repeated here.
[0117] In one exemplary embodiment, such as Figure 8 As shown, a portrait image processing device is provided, including: an acquisition module 801, a generation module 802, a brightness update module 803, a follow adjustment module 804, and a determination module 80, wherein: The acquisition module 801 is used to acquire the target portrait image and, based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face.
[0118] The generation module 802 is used to convert the target portrait image to the target color space to obtain a color space image matrix, and extract the brightness channel data from the color space image matrix to obtain the original global brightness data.
[0119] The brightness update module 803 is used to obtain the updated first brightness data based on the original global brightness data, skin area mask, and highlight area mask.
[0120] The follow adjustment module 804 is used to perform brightness enhancement on pixels within the hair area mask and hairline area mask based on the difference between the original global brightness data and the first brightness data within the skin area mask, so as to obtain an optimized color space image matrix.
[0121] The determination module 805 is used to determine a standard portrait image based on the portrait region mask and the optimized color space image matrix.
[0122] In an exemplary embodiment, the acquisition module 801 is further configured to concurrently perform semantic segmentation processing and key point detection processing on the target portrait image to obtain semantic segmentation processing results and key point detection processing results, respectively; generate a portrait region mask that marks the portrait region based on the semantic segmentation processing results; and generate a skin region mask that marks the skin region of the portrait face, a hair region mask that marks the hair region, a highlight region mask that marks the highlight region, and a hairline region mask that marks the hairline transition region based on the key point detection processing results.
[0123] In an exemplary embodiment, the brightness update module 803 is further configured to perform filtering and extraction processing on the original global brightness data corresponding to the skin region mask to obtain ambient illumination data; superimpose the skin region mask and the highlight region mask, and take the overlapping area as the effective processing area; and obtain the updated first brightness data based on each pixel in the effective processing area, the value of the pixel in the ambient illumination data of the skin region mask, and the original global brightness data.
[0124] In an exemplary embodiment, the brightness update module 803 is further configured to: query the corresponding value of each pixel in the ambient illumination data of the skin region mask for each pixel in the effective processing area; determine the pixels corresponding to values greater than a threshold value as pixels to be processed in the skin region mask; for each pixel to be processed, calculate the local brightness data in the original global brightness data corresponding to the pixel to be processed using a nonlinear soft-truncation mapping curve to obtain new local brightness data; and replace the local brightness data in the original global brightness data with the new local brightness data to obtain the updated first brightness data.
[0125] In an exemplary embodiment, the following adjustment module 804 is further configured to: within the skin region mask area, subtract the first brightness data from the original global brightness data pixel by pixel to determine the brightness change; determine the brightness following coefficient based on the brightness change; for pixels within the hair region mask area, perform a first same-direction brightness enhancement on the local brightness data in the original global brightness data corresponding to the pixel using the brightness following coefficient; for pixels within the hairline region mask area, perform a second same-direction brightness enhancement on the local brightness data in the original global brightness data corresponding to the pixel; wherein the intensity of the second same-direction brightness enhancement decreases from the skin side to the hair side within the hairline region mask area to obtain the second brightness data of the brightness channel; and determine the optimized color space image matrix based on the second brightness data.
[0126] In an exemplary embodiment, the follow adjustment module 804 is further configured to extract color channel data from the color space image matrix to obtain original global color data; within the skin region mask area, determine the chromaticity reference value of the skin region mask based on the original global color data; determine the color temperature offset of the skin region mask based on the chromaticity reference value and the standard chromaticity reference value; adjust the color temperature of the original global color data based on the color temperature offset to obtain updated global color data of the color channels; and determine the optimized color space image matrix based on the second brightness data and the global color data.
[0127] In an exemplary embodiment, the determining module 805 is further configured to convert the optimized color space image matrix to the original color space to obtain the image to be refined; perform edge repair processing on the portrait region mask to generate a closed portrait mask; perform fusion transition processing on the corresponding pixels in the image to be refined according to the hairline region mask to generate a transition image; and fill the outside of the portrait outline of the transition image with a preset background color according to the closed portrait mask to obtain a standard portrait image.
[0128] Each module in the aforementioned portrait image processing device 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, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0129] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores facial image data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network. When executed by the processor, the computer program implements a facial image processing method.
[0130] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0131] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0132] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0133] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0134] It should be noted that the facial information involved in this application is all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0135] 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, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0136] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0137] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for processing human portrait images, characterized in that, Applied to self-service devices, the method includes: Acquire a target portrait image, and based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face; The target portrait image is converted to the target color space to obtain a color space image matrix, and the brightness channel data is extracted from the color space image matrix to obtain the original global brightness data. Based on the original global brightness data, the skin region mask, and the highlight region mask, the updated first brightness data is obtained; Based on the difference between the original global brightness data and the first brightness data within the skin region mask, brightness enhancement is performed on the pixels within the hair region mask and the hairline region mask to obtain an optimized color space image matrix. Based on the portrait region mask and the optimized color space image matrix, a standard portrait image is determined.
2. The method according to claim 1, characterized in that, The step of generating a portrait region mask and skin region masks, hair region masks, highlight region masks, and hairline region masks based on the target portrait image includes: Semantic segmentation and key point detection are performed concurrently on the target portrait image to obtain semantic segmentation results and key point detection results, respectively. Based on the semantic segmentation results, a human image region mask is generated to mark the human image region. Based on the key point detection processing results, a skin region mask is generated to mark the skin area of the human face, a hair region mask is generated to mark the hair area, a highlight region mask is generated to mark the highlight area, and a hairline region mask is generated to mark the hairline transition area.
3. The method according to claim 1, characterized in that, The updated first brightness data, obtained based on the original global brightness data, the skin region mask, and the highlight region mask, includes: The original global brightness data corresponding to the skin region mask is filtered and extracted to obtain ambient illumination data. The skin area mask and the highlight area mask are superimposed, and the overlapping area is used as the effective processing area. The updated first brightness data is obtained based on each pixel in the effective processing area, the value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data.
4. The method according to claim 3, characterized in that, The step of obtaining the updated first brightness data based on each pixel in the effective processing area, the value of the pixel in the ambient illumination data of the skin area mask, and the original global brightness data includes: For each pixel in the effective processing area, query the value corresponding to that pixel in the ambient illumination data of the skin area mask; Pixels with values greater than a threshold value are identified as pixels to be processed in the skin region mask. For each pixel to be processed, the local brightness data in the original global brightness data corresponding to the pixel to be processed is calculated through a nonlinear soft-truncation mapping curve to obtain new local brightness data. The new local brightness data replaces the local brightness data in the original global brightness data to obtain the updated first brightness data.
5. The method according to claim 1, characterized in that, The step involves performing brightness enhancement on pixels within the hair region mask and the hairline region mask based on the difference between the original global brightness data and the first brightness data within the skin region mask, to obtain an optimized color space image matrix, including: Within the masked area of the skin region, the first brightness data is subtracted from the original global brightness data pixel by pixel to determine the amount of brightness change; Based on the aforementioned change in brightness, determine the brightness following coefficient; For pixels within the hair region mask area, a first unidirectional brightness enhancement is performed on the local brightness data in the original global brightness data corresponding to the pixel using the brightness following coefficient; for pixels within the hairline region mask area, a second unidirectional brightness enhancement is performed on the local brightness data in the original global brightness data corresponding to the pixel; wherein, the intensity of the second unidirectional brightness enhancement decreases from the skin side to the hair side within the hairline region mask area, resulting in the second brightness data of the brightness channel; The optimized color space image matrix is determined based on the second brightness data.
6. The method according to claim 5, characterized in that, Determining the optimized color space image matrix based on the second brightness data includes: The color channel data is extracted from the color space image matrix to obtain the original global color data; Within the skin region mask area, the chromaticity reference value of the skin region mask is determined based on the original global color data; Based on the chromaticity reference value and the standard chromaticity reference value, the color temperature offset of the skin area mask is determined; The color temperature of the original global color data is adjusted based on the color temperature offset to obtain the updated global color data of the color channels; Based on the second brightness data and the global color data, the optimized color space image matrix is determined.
7. The method according to claim 1, characterized in that, The process of determining a standard portrait image based on the portrait region mask and the optimized color space image matrix includes: The optimized color space image matrix is converted back to the original color space to obtain the image to be refined. Edge restoration processing is performed on the portrait area mask to generate a closed portrait mask; Based on the hairline region mask, perform a fusion transition process on the corresponding pixels in the image to be refined to generate a transition image; Based on the closed portrait mask, a preset background color is filled outside the portrait outline of the transition image to obtain a standard portrait image.
8. A human image processing device, characterized in that, The device is used in self-service equipment and includes: The acquisition module is used to acquire a target portrait image and, based on the target portrait image, generate a portrait region mask as well as a skin region mask, hair region mask, highlight region mask, and hairline region mask for the portrait face. The generation module is used to convert the target portrait image to the target color space to obtain a color space image matrix, and extract the brightness channel data from the color space image matrix to obtain the original global brightness data. The brightness update module is used to obtain the updated first brightness data based on the original global brightness data, the skin area mask, and the highlight area mask; The follow adjustment module is used to perform brightness enhancement on pixels within the range of the hair area mask and the hairline area mask based on the difference between the original global brightness data and the first brightness data within the skin area mask, so as to obtain an optimized color space image matrix. The determination module is used to determine a standard portrait image based on the portrait region mask and the optimized color space image matrix.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
