Image processing method and device, equipment and storage medium

By determining the target area and rendering color in image processing technology, calculating the color gradation adjustment parameters, adjusting the image brightness and mixing pixel values, the problem of unnatural hair dyeing effect in the prior art is solved, and a more natural dyeing effect is achieved.

CN119067837APending Publication Date: 2024-12-03BEIJING SWEET SUGARSOFT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410915639.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

When existing image processing technology dyes the hair in the image, the dyeing effect presented by the existing image processing technology is unnatural and cannot effectively simulate the effect after real hair dyeing.

Method used

A more natural dyeing effect is achieved by determining the target area and color to be rendered by the image to be processed, calculating the color level adjustment parameters, adjusting the image brightness, and combining the rendered color to mix pixel values.

Benefits of technology

The effect of dyeing the image hair is more natural, the brightness is adjusted reasonably, and the color performance is closer to the real hair dye effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119067837A_ABST
    Figure CN119067837A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an image processing method and device, equipment and a storage medium, and the method comprises the steps: determining a to-be-processed image and a target region of the to-be-processed image, and enabling the target region to indicate the position of a to-be-processed object in the to-be-processed image; obtaining a to-be-rendered color, and determining a color gradation adjustment parameter of the to-be-processed object based on the to-be-rendered color and the pixel values of the pixel points in the target area; the color gradation adjustment parameter is used for adjusting the brightness of a to-be-processed image; determining a rendering pixel value of each pixel point of the to-be-processed image based on the color gradation adjustment parameter and the to-be-rendered color; and based on the rendering pixel value of each pixel point of the to-be-processed image, rendering the to-be-processed object to obtain a target effect image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to, but is not limited to, the field of image processing technology, and in particular to an image processing method, apparatus, device, and storage medium program product. Background Art

[0002] With the development of computer vision technology, some beauty image processing apps provide the function of changing the color and even texture of a person's hair through image processing. In related image processing technologies, the color and texture of an image are modified through textures and filters. However, the hair dyeing effect presented by textures and filters is not natural compared to the effect presented after real hair dyeing. Summary of the invention

[0003] In view of this, the embodiments of the present disclosure at least provide an image processing method, apparatus, device, storage medium and program product.

[0004] The technical solution of the embodiment of the present disclosure is implemented as follows:

[0005] On the one hand, an embodiment of the present disclosure provides an image processing method, which includes: determining an image to be processed and a target area of ​​the image to be processed, wherein the target area indicates a position of an object to be processed in the image to be processed; obtaining a color to be rendered, and determining a color scale adjustment parameter of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area; the color scale adjustment parameter is used to adjust the brightness of the image to be processed; determining a rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered; and rendering the object to be processed based on the rendering pixel value of each pixel of the image to be processed to obtain a target effect image.

[0006] In some embodiments, determining the color scale adjustment parameters of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area includes: determining the average grayscale value of the object to be processed based on the pixel values ​​of the pixels in the target area; determining the color scale adjustment parameters based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0007] In the above embodiment, based on the pixel values ​​of the pixels in the target area, the average grayscale value of the object to be processed is determined, and the grayscale value of the color to be rendered is determined. According to the magnitude relationship between the grayscale value of the color to be rendered and the average grayscale value of the object to be processed, the color scale adjustment parameter corresponding to the color to be rendered is determined. In this way, the brightness of the image to be processed can be adjusted accordingly for different colors to be rendered, so that different colors to be rendered correspond to different rendering pixel values.

[0008] In some embodiments, determining the color scale adjustment parameter based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered includes: when the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered, determining the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0009] In some embodiments, the color scale adjustment parameter is determined based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, including: when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than a preset difference, using the preset adjustment parameter as the color scale adjustment parameter.

[0010] In the above embodiment, since the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than the preset difference, the color scale adjustment parameter is set to a fixed preset adjustment parameter, which can simplify the calculation process, improve the rendering efficiency, and meet the need for adjusting the brightness of the image to be processed.

[0011] In some embodiments, the color scale adjustment parameter is determined based on the size of the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, including: when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is less than or equal to a preset difference, a first intermediate value is determined based on the absolute value of the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered; the first intermediate value is negatively correlated with the square of the absolute value and positively correlated with the absolute value; the first intermediate value is increased based on a preset first increase parameter, and the increased first intermediate value is interval-restricted based on a preset first parameter interval to obtain the color scale adjustment parameter.

[0012] In the above embodiment, based on the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, the corresponding first intermediate value is first determined, and then the first intermediate value is increased and the range is limited, so that the obtained color scale adjustment parameter is more reasonable, and then the brightness of the image to be processed adjusted according to the color scale adjustment parameter is closer to the brightness of the color to be rendered.

[0013] In some embodiments, the color scale adjustment parameter is determined based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, including: when the average grayscale value of the object to be processed is less than the grayscale value of the color to be rendered, a second intermediate value is determined based on the absolute value of the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered; the second intermediate value is positively correlated with the square of the absolute value and is positively correlated with the absolute value; the second intermediate value is negated, the negated second intermediate value is increased based on a preset second increase parameter, and the increased second intermediate value is interval-limited based on a preset second parameter interval to obtain the color scale adjustment parameter.

[0014] In the above embodiment, based on the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, the corresponding second intermediate value is first determined, and then the second intermediate value is negated, increased and range-limited, so that the obtained color scale adjustment parameter is more reasonable, and the brightness of the image to be processed after brightening adjustment according to the color scale adjustment parameter is closer to the brightness of the color to be rendered.

[0015] In some embodiments, determining the rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered includes: adjusting the brightness of each pixel of the image to be processed based on the color scale adjustment parameter to obtain the first pixel value of each pixel of the image to be processed; mixing the first pixel value of each pixel of the image to be processed with the pixel value of the color to be rendered to obtain the rendering pixel value of each pixel of the image to be processed.

[0016] In the above embodiment, since the brightness of each pixel of the image to be processed is adjusted corresponding to the color scale adjustment parameter based on the acquired color scale adjustment parameter, the first pixel value of each pixel of the image to be processed after the brightness adjustment can be obtained; and the first pixel value of the pixel is mixed with the pixel value of the color to be rendered, the rendered pixel value related to the brightness of the pixel can be obtained.

[0017] In some embodiments, the brightness of each pixel of the image to be processed is adjusted based on the color scale adjustment parameter to obtain the first pixel value of each pixel of the image to be processed, including: for each pixel of the image to be processed, based on the color scale adjustment parameter, the original pixel value of the pixel is numerically adjusted to obtain the first pixel value of the pixel; the numerical adjustment method is positively or negatively correlated with the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0018] In the above embodiment, based on the acquired color scale adjustment parameters, with respect to the brightness of different colors to be rendered, the brightness of the image to be processed that includes a brighter object to be processed is dimmed, and the brightness of the image to be processed that includes a darker object to be processed is brightened, so that no matter whether the brightness of the object to be processed is brighter or darker, the brightness difference between the image to be processed and the color to be rendered can be reduced.

[0019] In some embodiments, the first pixel value of each pixel of the image to be processed and the pixel value of the color to be rendered are first mixed to obtain the rendered pixel value of each pixel of the image to be processed, including: for each pixel of the image to be processed, based on the brightness of the first pixel value of each pixel of the image to be processed and the hue and saturation of the color to be rendered, determining the rendered pixel value of each pixel of the image to be processed.

[0020] In the above embodiment, due to the mixed processing based on the first pixel value of the pixel point of the image to be processed and the hue and saturation of the color to be rendered, the rendered pixel value of the obtained pixel point can retain the brightness of the pixel point corresponding to the image to be processed and have the hue and saturation of the color to be rendered. The rendered pixel value is used to render the object to be processed, so that different parts of the object to be processed after rendering can maintain the original brightness and have the hue and saturation of the color to be rendered, so that different parts of the object to be processed in the obtained target effect image show different brightness, and the brightness of the colors between different parts is related to the original brightness of the object to be processed, thereby making the color of the object to be processed after rendering more natural.

[0021] In some embodiments, the object to be processed is rendered based on the rendered pixel value of each pixel of the image to be processed to obtain a target effect image, including: determining a mixing weight of the rendered pixel value for each pixel of the image to be processed; and determining a target pixel value for each pixel of the image to be processed based on the rendered pixel value of each pixel of the image to be processed, the mixing weight of the rendered pixel value and the original pixel value of each pixel of the object to be processed.

[0022] In the above embodiment, since the rendered pixel value and the original pixel value of each pixel point of the image to be processed are weightedly summed according to the mixing weight of the rendered pixel value, the target pixel value of the pixel point of the image to be processed can be obtained, thereby obtaining the target effect image after rendering the object to be processed.

[0023] In some embodiments, determining the blending weight of the rendered pixel value includes: obtaining a mask image of the image to be processed; determining the blending weight of the rendered pixel value based on a preset transparency parameter and a blending parameter of the mask image of the image to be processed; the blending parameter is related to the pixel value of each pixel point of the mask image.

[0024] In the above embodiment, since the blending parameters are determined based on the pixel values ​​of the mask image of the image to be processed, the area for rendering the image to be processed can be determined; at the same time, since the preset transparency parameters are set, the rendered object to be processed can present different rendering effects according to different preset transparency parameters.

[0025] On the other hand, an embodiment of the present disclosure provides an image processing device, the device comprising: an acquisition module, used to acquire an image to be processed and a target area of ​​the image to be processed, the target area indicating the position of the object to be processed in the image to be processed; an adjustment parameter determination module, used to acquire a color to be rendered, and determine the color scale adjustment parameters of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area; the color scale adjustment parameters are used to adjust the brightness of the image to be processed; a rendering pixel value determination module, used to determine the rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameters and the color to be rendered; a rendering module, based on the rendering pixel value of each pixel of the image to be processed, renders the object to be processed to obtain a target effect image. On another aspect, an embodiment of the present disclosure provides a computer device, comprising a memory and a processor, the memory storing a computer program that can be run on the processor, and the processor implements some or all of the steps in the above method when executing the program.

[0026] On the other hand, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements part or all of the steps in the above method when executed by a processor.

[0027] On the other hand, an embodiment of the present disclosure provides a computer program, including computer-readable codes. When the computer-readable codes are executed in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0028] On the other hand, an embodiment of the present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, it implements some or all of the steps in the above method.

[0029] In the embodiment of the present disclosure, by acquiring the target area of ​​the image to be processed, the pixel points of the object to be processed in the image to be processed can be accurately determined, thereby providing an accurate reference for determining the color scale adjustment parameters of the subsequent image to be processed; at the same time, based on the pixel values ​​of different colors to be rendered and the pixel points of the object to be processed, the color scale adjustment parameters corresponding to the color to be rendered are determined, the brightness of the image to be processed can be adjusted, and then the pixel values ​​of the pixel points of the image to be processed after the brightness adjustment are mixed with the pixel values ​​of the color to be rendered, so as to obtain the rendering pixel values, and the object to be processed is rendered using the rendering pixel values, and the brightness of the color of different parts of the object to be processed in the obtained target effect image is different, and the brightness of each part is related to the brightness before rendering; and in the process of rendering the object to be processed, different mixing weights can be set for the pixel points of different areas of the image to be processed, so that after the rendering pixel values ​​are mixed with the pixel values ​​of the image to be processed, more different rendering effects can be presented.

[0030] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.

[0032] Figure 1 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0033] Figure 2 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0034] Figure 3 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0035] Figure 4 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0036] Figure 5 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0037] Figure 6 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0038] Figure 7 A schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure;

[0039] Figure 8 A schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure;

[0040] Fig. 9 A hardware entity schematic diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0041] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.

[0042] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. The terms "first / second / third" are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first / second / third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.

[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the present disclosure and are not intended to limit the present disclosure.

[0044] The present disclosure provides an image processing method, which can be executed by a processor of a computer device, wherein the computer device may refer to an electronic device with data processing capability, such as a server, a laptop, a tablet computer, a desktop computer, a smart TV, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable gaming device), etc.

[0045] Figure 1 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 1 As shown, the method includes the following steps S101 to S104, combining Figure 1 The steps shown are explained.

[0046] S101: Determine an image to be processed and a target area of ​​the image to be processed, wherein the target area indicates a position of an object to be processed in the image to be processed.

[0047] In some embodiments, the image to be processed may be an image captured in real time, or may be an image stored in a storage device and called. The image to be processed includes an object to be processed that needs to be rendered, and the object to be processed is, for example, the hair of a person in the image to be processed. Accordingly, the rendering process may be dyeing the hair in the image to be processed.

[0048] In some embodiments, during processing of an image to be processed, it is necessary to determine a target area of ​​the image to be processed, where the target area is the area occupied by the object to be processed included in the image to be processed, that is, the area where all pixels of the object to be processed in the image to be processed are located.

[0049] Exemplarily, the image to be processed may be segmented to determine the target area, for example, a semantic segmentation method may be used to segment out the hair area in the image of the person to be processed. In some embodiments, the image segmentation result may be further binarized to obtain a mask image of the object to be processed in the image to be processed. That is, the object to be processed and the background in the image to be processed are segmented based on a trained segmentation model, and then the pixel points corresponding to the object to be processed are set to a first value, and the pixel points corresponding to the background are set to a second value, so that the mask image corresponding to the image to be processed can be obtained. The area where the pixel points whose pixel values ​​are set to the first value in the mask image are located can represent the target area of ​​the image to be processed.

[0050] In this embodiment, an image segmentation model can be used to perform image segmentation on the image to be processed. Accordingly, any one of the machine learning models based on neural networks such as U-shaped structure network (Unet), residual network (ResNet), region proposal network (RPN) and deep learning target detection network (Faster Region Convolutional Neural Networks, Faster R CNN) can be used to perform image segmentation on the image to be processed, and the disclosed embodiment does not limit this; then the image to be processed after image segmentation is binarized. Accordingly, the pixel value of the pixel point corresponding to the object to be processed is set to 255, and the pixel value of the pixel point corresponding to the background is set to 0, so as to obtain a mask image in which the area where the object to be processed is located is white and the background is black. The white area in the mask image can represent the target area of ​​the image to be processed.

[0051] S102, obtaining a color to be rendered, and determining a color scale adjustment parameter of the object to be processed based on the color to be rendered and pixel values ​​of pixels in the target area; the color scale adjustment parameter is used to adjust the brightness of the image to be processed.

[0052] In some embodiments, the color to be rendered is a color used to render the object to be processed included in the image to be processed, and the color to be rendered may be a color in RGB format. For example, in the case of dyeing the hair of the object to be processed, a color in RGB format may be obtained as the color to be rendered. In actual scenarios, the method of the embodiment of the present application may be applied to application software with a local image rendering function, such as a beauty application software (Application, APP), and the color to be rendered may be a color selected by a user in the application software.

[0053] In some embodiments, during the process of rendering the object to be processed, the brightness of the image to be processed may be adjusted first, that is, the brightness of each pixel of the image to be processed may be adjusted. During the process of adjusting the brightness of the image to be processed, it is necessary to determine the parameters for adjusting the brightness of each pixel, that is, the color scale adjustment parameters. The color scale adjustment parameters are related to the grayscale value of the selected color to be rendered and the average grayscale value of the object to be processed, that is, the color scale adjustment parameters are determined based on the grayscale value of the color to be rendered and the average grayscale value of the object to be processed, and the average grayscale value of the object to be processed is determined based on the grayscale values ​​of all pixels in the target area of ​​the image to be processed.

[0054] S103: Determine a rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered.

[0055] In some embodiments, in the process of determining the rendering pixel value for rendering each pixel of the image to be processed, the brightness of the image to be processed is first adjusted based on the color scale adjustment parameter, that is, the brightness of each pixel of the image to be processed is adjusted so that each pixel of the image to be processed obtains a pixel value after the brightness is adjusted.

[0056] In some embodiments, after adjusting the brightness of the image to be processed, the pixel value after brightness adjustment obtained for each pixel point of the image to be processed can be mixed with the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel point of the image to be processed.

[0057] In other embodiments, the brightness of the object to be processed in the image to be processed may be adjusted first based on the color scale adjustment parameter. That is, the brightness of each pixel of the object to be processed in the image to be processed is adjusted so that each pixel of the object to be processed obtains a pixel value after the brightness is adjusted. Then, the pixel value after the brightness adjustment obtained for each pixel of the object to be processed is mixed with the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel of the object to be processed.

[0058] S104: Render the object to be processed based on the rendering pixel value of each pixel point of the image to be processed to obtain a target effect image.

[0059] In some embodiments, in the process of rendering the object to be processed in the image to be processed, the image to be processed is rendered based on the acquired rendering pixel value. Among them, for different areas in the image to be processed, different mixing weights can be set for the areas to be rendered, so as to obtain different rendering effects for the area. That is, for different pixels in the image to be processed, different mixing weight values ​​can be set in the process of rendering the corresponding rendering pixel values, and the pixel values ​​of the pixels in the image to be processed and the colors to be rendered are mixed using the mixing weight values, so as to obtain the objects to be processed after rendering with different rendering effects, that is, to obtain different target effect images.

[0060] In the embodiment of the present disclosure, by acquiring the target area of ​​the image to be processed, the pixel points of the object to be processed in the image to be processed can be accurately determined, thereby providing an accurate reference for determining the color scale adjustment parameters of the subsequent image to be processed; at the same time, based on the pixel values ​​of different colors to be rendered and the pixel points of the object to be processed, the color scale adjustment parameters corresponding to the color to be rendered are determined, the brightness of the image to be processed can be adjusted, and then the pixel values ​​of the pixel points of the image to be processed after the brightness adjustment are mixed with the pixel values ​​of the color to be rendered, so as to obtain the rendering pixel values, and the object to be processed is rendered using the rendering pixel values, and the brightness of the color of different parts of the object to be processed in the obtained target effect image is different, and the brightness of each part is related to the brightness before rendering; and in the process of rendering the object to be processed, different mixing weights can be set for the pixel points of different areas of the image to be processed, so that after the rendering pixel values ​​are mixed with the pixel values ​​of the image to be processed, more different rendering effects can be presented.

[0061] Figure 2 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 1 , Figure 1 S102 in can be updated to S201 to S202, which will be combined Figure 2 The steps shown are explained.

[0062] S201. Determine an average grayscale value of the object to be processed based on pixel values ​​of pixels in the target area.

[0063] In some embodiments, for each pixel in the target area, that is, for each pixel of the object to be processed, the RGB color value of the pixel is converted into a gray value to obtain the gray value of the pixel, and then the average gray value of the object to be processed is determined according to the gray value of each pixel of the object to be processed and the total number of pixels of the object to be processed. According to the gray value of each pixel of the object to be processed, the average of the maximum gray value and the minimum gray value can be used as the average gray value of the object to be processed. The median of the gray values ​​of all pixels of the object to be processed can also be used as the average gray value of the object to be processed.

[0064] In some embodiments, for each pixel point of the object to be processed, mean filtering, median filtering or Wiener filtering can be used to remove noise points in the pixel points of the object to be processed; then the RGB color value of the pixel point is converted into a grayscale value, so as to obtain the average grayscale value of the object to be processed in the same way as the above embodiment.

[0065] S202: Determine the color scale adjustment parameter based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0066] In some embodiments, the color to be rendered is a color in RGB format. Similarly, the RGB color value of the color to be rendered is converted into a grayscale value to obtain the grayscale value of the color to be rendered. In the process of rendering the object to be processed, the grayscale value of the color to be rendered depends on the selected color to be rendered. The grayscale value of the color to be rendered may be greater than the average grayscale value of the object to be processed, or may be less than the average grayscale value of the object to be processed; that is, the brightness of the color to be rendered may be brighter or darker than the average brightness of the object to be processed. In the process of adjusting the brightness of the image to be processed, the color scale adjustment parameter can be determined according to the size relationship between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, so as to adjust the brightness of the image to be processed based on the color scale adjustment parameter.

[0067] In some embodiments, the color scale adjustment parameter corresponding to the color to be rendered can be determined based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered. The obtained color scale adjustment parameter is related to the difference in brightness between the object to be processed and the color to be rendered, so that the brightness of the image to be processed can be adjusted accordingly based on the color scale adjustment parameter.

[0068] In the disclosed embodiment, based on the pixel values ​​of the pixels in the target area, the average grayscale value of the object to be processed is determined, and the grayscale value of the color to be rendered is determined. According to the magnitude relationship between the grayscale value of the color to be rendered and the average grayscale value of the object to be processed, the color scale adjustment parameter corresponding to the color to be rendered is determined. In this way, the brightness of the image to be processed can be adjusted accordingly for the different colors to be rendered, so that the brightness after rendering is within an appropriate range and the rendering effect is more natural.

[0069] Figure 3 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 2 , Figure 2 S202 in can be updated to Figure 3 The S301 in Figure 3 The steps shown are explained.

[0070] S301 . When the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered, determine the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0071] In some embodiments, for the same object to be processed, different colors to be rendered can be selected for rendering, and the grayscale values ​​of the selected different colors to be rendered may be greater than the average grayscale value of the object to be processed, or may be less than the average grayscale value of the object to be processed. In the case where the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered, the color scale adjustment parameter is determined in different ways according to the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, so that the brightness of the image to be processed can be adjusted to different degrees.

[0072] In some embodiments, the above-mentioned determination of the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered can be implemented through S3011.

[0073] S3011. When the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than a preset difference, use a preset adjustment parameter as the color scale adjustment parameter.

[0074] In some embodiments, when the difference between the average gray value of the object to be processed and the gray values ​​of multiple different colors to be rendered is large, that is, the object to be processed is brighter than the brightness of multiple different colors to be rendered, the brightness of the image to be processed can be adjusted to the same degree for the multiple different colors to be rendered. Therefore, a preset difference can be set, and when the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is greater than the preset difference, the color scale adjustment parameter is set to a fixed value, that is, set to the preset adjustment parameter, so that the brightness of the image to be processed is adjusted based on the preset adjustment parameter, thereby reducing the brightness difference between the image to be processed and the color to be rendered.

[0075] In the embodiment of the present disclosure, since the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than the preset difference, the color scale adjustment parameter is set to a fixed preset adjustment parameter, which can simplify the calculation process, improve rendering efficiency, and meet the need for adjusting the brightness degree of the image to be processed.

[0076] In some embodiments, the color scale adjustment parameter can be determined based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered through S3012 to S3013.

[0077] S3012. When the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is less than or equal to a preset difference, determine a first intermediate value based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered; the first intermediate value is negatively correlated with the square of the absolute value and positively correlated with the absolute value.

[0078] In some embodiments, when the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is small, that is, the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is less than or equal to the preset difference, it is necessary to adjust the brightness of the image to be processed accordingly according to the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered. In order to reduce the brightness difference between the image to be processed and the color to be rendered, when the brightness difference between the image to be processed and the color to be rendered is large, it is necessary to adjust the brightness of the image to be processed to a greater degree; when the brightness difference between the image to be processed and the color to be rendered is small, the brightness of the image to be processed can be adjusted to a smaller degree. Therefore, according to the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, a first intermediate value that increases with the increase of the absolute value and decreases with the increase of the square of the absolute value can be obtained.

[0079] In some embodiments, the first intermediate value can be determined based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered by formula (1), which is expressed as:

[0080] y=-184.6×x 2 +182.7×x formula (1);

[0081] Wherein, x represents the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, and y represents the first intermediate value.

[0082] S3013: Increase the first intermediate value based on a preset first increase parameter, and perform interval restriction processing on the increased first intermediate value based on a preset first parameter interval to obtain the color scale adjustment parameter.

[0083] In some embodiments, in order to adjust the brightness of the image to be processed that is brighter than the brightness of the color to be rendered to be darker, after obtaining the first intermediate value, the first intermediate value can be increased by a certain amplitude, that is, a preset first increase parameter is added to the first intermediate value. For different colors to be rendered, the first intermediate value after the increase can also be subjected to interval restriction processing. When the first intermediate value after the increase exceeds the preset first parameter interval, the first intermediate value exceeding the preset first parameter interval will not be used as the color scale adjustment parameter, but the color scale adjustment parameter will be set to the boundary value (maximum value or minimum value) of the first parameter interval. When the first intermediate value after the increase does not exceed the preset first parameter interval, the first intermediate value after the increase is used as the color scale adjustment parameter, thereby obtaining the color scale adjustment parameter corresponding to the color to be rendered for adjusting the brightness of the image to be processed.

[0084] In the disclosed embodiment, based on the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, the corresponding first intermediate value is first determined, and then the first intermediate value is increased and the interval is limited, so that the obtained color scale adjustment parameter is more reasonable, and the brightness of the image to be processed adjusted according to the color scale adjustment parameter is closer to the brightness of the color to be rendered.

[0085] Figure 4 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 2 , Figure 2 The S202 in can also be updated to Figure 4 S401 to S402 in the Figure 4 The steps shown are explained.

[0086] S401. When the average gray value of the object to be processed is less than the gray value of the color to be rendered, determine a second intermediate value based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered; the second intermediate value is positively correlated with the square of the absolute value and is positively correlated with the absolute value.

[0087] In some embodiments, when the average gray value of the object to be processed is smaller than the gray value of the color to be rendered, that is, the brightness of the color to be rendered is brighter than the brightness of the object to be processed, the brightness of the image to be processed can be brightened, thereby reducing the brightness difference between the color to be rendered and the image to be processed. Therefore, in the process of adjusting the brightness of the image to be processed, the brightness of the image to be processed can be adjusted to be brighter according to the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered. When the average gray value of the object to be processed is less than the gray value of the color to be rendered, the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is a negative value, that is, the absolute value of the negative difference is taken for calculation. When the brightness difference between the image to be processed and the color to be rendered is large, the brightness of the image to be processed needs to be adjusted to a greater extent, and when the brightness difference between the image to be processed and the color to be rendered is small, the brightness of the image to be processed can be adjusted to a smaller extent. Therefore, a second intermediate value that increases with the increase of the absolute value and increases with the increase of the square of the absolute value can be obtained based on the absolute value.

[0088] In some embodiments, the second intermediate value can be determined based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered by formula (2), which is expressed as:

[0089] y=139.63×x 2 +182.7×x formula (2);

[0090] Wherein, x represents the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, and y represents the first intermediate value.

[0091] S402, negate the second intermediate value, increase the negated second intermediate value based on a preset second increase parameter, and perform interval restriction processing on the increased second intermediate value based on a preset second parameter interval to obtain the color scale adjustment parameter.

[0092] In some embodiments, in order to brighten the brightness of the image to be processed that is darker than the brightness of the color to be rendered, after obtaining the second intermediate value, it is necessary to negate the second intermediate value, that is, to take the second intermediate value as its corresponding negative value, and then increase it by a certain amplitude, that is, to accelerate the second increase parameter of the negated second intermediate value. For different colors to be rendered, it is also necessary to perform interval restriction processing on the second intermediate value after negation and increase. In the case where the second intermediate value after negation and increase exceeds the preset second parameter range, the second intermediate value exceeding the preset second parameter range will not be used as the color scale adjustment parameter, but the color scale adjustment parameter will be set to the boundary value (maximum value or minimum value) of the second parameter range. In the case where the increased second intermediate value does not exceed the preset first parameter range, the increased second intermediate value is used as the color scale adjustment parameter, thereby obtaining the color scale adjustment parameter corresponding to the color to be rendered for brightening the brightness of the image to be processed.

[0093] In the disclosed embodiment, based on the specific numerical value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered, the corresponding second intermediate value is first determined, and then the second intermediate value is negated, increased and range-limited, so that the obtained color scale adjustment parameter is more reasonable, and the brightness of the image to be processed after brightening adjustment according to the color scale adjustment parameter is closer to the brightness of the color to be rendered.

[0094] Figure 5 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 1 , Figure 1 S103 in can be updated to Figure 5 S501 to S502 in the Figure 5 The steps shown are explained.

[0095] S501 . Based on the color scale adjustment parameter, adjust the brightness of each pixel of the image to be processed to obtain a first pixel value of each pixel of the image to be processed.

[0096] In some embodiments, for each pixel of the image to be processed, the pixel value of the pixel of the image to be processed can be adjusted based on the color scale adjustment parameters obtained in the above embodiments. Accordingly, when the brightness of the object to be processed is brighter than the brightness of the color to be rendered, the pixel value of the pixel of the image to be processed can be reduced based on the color scale adjustment parameters corresponding to the color to be rendered; when the brightness of the object to be processed is darker than the brightness of the color to be rendered, the pixel value of the pixel of the image to be processed can be increased based on the color scale adjustment parameters corresponding to the color to be rendered; thereby adjusting the brightness of the image to be processed and obtaining the pixel value of each pixel of the image to be processed after the brightness is adjusted, that is, the first pixel value.

[0097] In the disclosed embodiment, since the brightness of each pixel of the image to be processed is adjusted corresponding to the color scale adjustment parameter based on the acquired color scale adjustment parameter, the first pixel value of each pixel of the image to be processed after the brightness adjustment can be obtained.

[0098] In some embodiments, the brightness of each pixel of the image to be processed can be adjusted based on the color scale adjustment parameter to obtain the first pixel value of each pixel of the image to be processed through S5011.

[0099] S5011. For each pixel of the image to be processed, based on the color scale adjustment parameter, numerically adjust the original pixel value of the pixel to obtain the first pixel value of the pixel; the numerical adjustment method is positively or negatively correlated with the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0100] In some embodiments, when the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered, that is, when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is a positive number, the brightness of the image to be processed needs to be adjusted to be darker to reduce the brightness difference between the object to be processed and the color to be rendered. For each pixel of the image to be processed, the original pixel value of the pixel of the image to be processed can be adjusted based on the color scale adjustment parameter, that is, the value of each color channel of the pixel is adjusted to be smaller, thereby achieving the purpose of dimming the brightness of the image to be processed and obtaining the first pixel value of the pixel.

[0101] In some embodiments, when the average grayscale value of the object to be processed is less than the grayscale value of the color to be rendered, that is, when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is a negative number, the brightness of the image to be processed needs to be adjusted to be brighter to reduce the brightness difference between the object to be processed and the color to be rendered. Similarly, for each pixel of the image to be processed, the value of each color channel of the pixel can be adjusted based on the color scale adjustment parameter, and the value of each color channel of the pixel is adjusted to be larger, thereby achieving the purpose of brightening the brightness of the image to be processed and obtaining the first pixel value of the pixel.

[0102] In the embodiment of the present disclosure, based on the acquired color scale adjustment parameters, with respect to the brightness of different colors to be rendered, the brightness of the image to be processed that includes a brighter object to be processed is dimmed, and the brightness of the image to be processed that includes a darker object to be processed is brightened, so that regardless of whether the brightness of the object to be processed is brighter or darker, the brightness difference between the image to be processed and the color to be rendered can be reduced.

[0103] S502 : Mixing the first pixel value of each pixel of the image to be processed with the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel of the image to be processed.

[0104] In some embodiments, the first pixel value of the pixel point of the image to be processed after the brightness adjustment is mixed with the pixel value of the color to be rendered. Different mixing processing methods can be selected according to different required rendering effects to obtain different rendering pixel values ​​for each pixel point of the image to be processed.

[0105] In some embodiments, S5021 may be used to implement mixing processing of the first pixel value of each pixel point of the image to be processed and the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel point of the image to be processed.

[0106] S5021. For each pixel of the image to be processed, determine the rendering pixel value of each pixel of the image to be processed based on the brightness of the first pixel value of each pixel of the image to be processed and the hue and saturation of the color to be rendered.

[0107] In some embodiments, for each pixel of the image to be processed, in the process of mixing the first pixel value of the pixel of the image to be processed with the pixel value of the color to be rendered, the mixing process can be mainly based on the brightness of the first pixel value, the hue and saturation of the color to be rendered, so that the rendered pixel value of the obtained pixel can retain the brightness of the first pixel value, that is, retain the grayscale of the image to be processed; and have the hue of the color to be rendered, that is, have the color appearance of the color to be rendered, such as red, purple or yellow; and also have the saturation of the color to be rendered, that is, maintain the same vividness as the color to be rendered.

[0108] In the disclosed embodiment, due to the mixed processing based on the first pixel value of the pixel point of the image to be processed and the hue and saturation of the color to be rendered, the rendered pixel value of the obtained pixel point can retain the brightness of the pixel point corresponding to the image to be processed, and also have the hue and saturation of the color to be rendered. The rendered pixel value is used to render the object to be processed, so that different parts of the object to be processed after rendering can maintain the original brightness and have the hue and saturation of the color to be rendered, so that different parts of the object to be processed in the obtained target effect image present different brightness, and the brightness of the colors between different parts is related to the original brightness of the object to be processed, thereby making the color of the object to be processed after rendering more natural.

[0109] Figure 6 The following is a schematic diagram of an implementation flow of an image processing method provided by an embodiment of the present disclosure, and the method can be executed by a processor of a computer device. Figure 1 , Figure 1 S104 in can be updated to Figure 6 S601 to S602 in the Figure 6 The steps shown are explained.

[0110] S601 : For each pixel point of the image to be processed, determine a mixing weight of the rendered pixel value.

[0111] In some embodiments, in the process of rendering the image to be processed using the obtained rendering pixel value of each pixel in the image to be processed, different blending weights can be set for the rendering pixel values ​​of different pixels in the image to be processed, so that different parts of the obtained target effect image can present different rendering effects. For example, the greater the blending weight of the rendering pixel value of a pixel point, the closer the color presented by the pixel point is to the color of the rendering pixel value pair; the smaller the blending weight of the rendering pixel value of a pixel point, the closer the color presented by the pixel point is to the original color of the pixel point.

[0112] In some embodiments, the above-mentioned determination of the blending weight of the rendered pixel value may be implemented through S6011 to S6012.

[0113] S6011. Obtain a mask image of the image to be processed.

[0114] In some embodiments, the mixed weight of the rendered pixel value can be obtained by obtaining the mask image of the image to be processed. Exemplarily, the mask image of the image to be processed can be obtained by performing image segmentation and binarization on the image to be processed. That is, the object to be processed and the background in the image to be processed are segmented based on the trained segmentation model, and then the pixel points corresponding to the object to be processed are set to the first value, and the pixel points corresponding to the background are set to the second value, so that the mask image corresponding to the image to be processed can be obtained. The area where the pixel points whose pixel values ​​are set to the first value in the mask image are located can represent the position of the object to be processed in the image to be processed.

[0115] In this embodiment, an image segmentation model can be used to perform image segmentation on the image to be processed. For example, any one of the machine learning models based on neural networks such as U-shaped structure network (Unet), residual network (ResNet), region proposal network (RPN) and deep learning target detection network (Faster Region Convolutional Neural Networks, Faster R CNN) can be used to perform image segmentation on the image to be processed, and the disclosed embodiment is not limited to this; then the image to be processed after image segmentation is binarized. For example, the pixel value of the pixel point corresponding to the object to be processed is set to 255, and the pixel value of the pixel point corresponding to the background is set to 0, so as to obtain a mask image in which the area where the object to be processed is located is white and the background is black. The white area in the mask image can represent the area where the object to be processed is located in the image to be processed.

[0116] S6012: Determine a blending weight of the rendered pixel value based on a preset transparency parameter and a blending parameter of the mask image of the image to be processed; the blending parameter is related to a pixel value of each pixel of the mask image.

[0117] In some embodiments, different blending weights set for the rendering pixel values ​​of different pixels in the image to be processed can be determined by a preset transparency parameter and a blending parameter of the mask image of the image to be processed. The blending parameter is used to determine the area to be rendered in the image to be processed, that is, when the background area of ​​the image to be processed is not rendered, the blending parameter of the rendering pixel value of the pixel point in the background area of ​​the image to be processed can be set to 0, so that the background of the image to be processed is not rendered; and the blending parameter of the rendering pixel value of the pixel point of the object to be processed in the image to be processed is set to 1, so that the object to be processed is rendered using the rendering pixel value. The value of the blending parameter is 0 or 1, and can be determined according to the pixel value of the pixel point of the mask image, and the blending parameter corresponding to the pixel point with a pixel value of 0 in the mask image is set to 0, and the blending parameter corresponding to the pixel point with a pixel value of 255 in the mask image is set to 1.

[0118] The preset transparency parameter is used to adjust the transparency of the color corresponding to the rendering pixel value, that is, in the process of using the color corresponding to the rendering pixel value to render the object to be processed, the transparency of the color corresponding to the rendering pixel value can be adjusted. The rendering pixel value can be completely rendered to the pixel point corresponding to the object to be processed, at which time, the preset transparency parameter of the rendering pixel value is 1; it can also be selected to render half of the rendering pixel value to the pixel point corresponding to the object to be processed, at which time, the preset transparency parameter of the rendering pixel value is 0.5. Therefore, the product of the mixing parameter and the preset transparency parameter is used as the mixing weight of the pixel point, which can determine the area to be rendered for the image to be processed, and can also determine the transparency of the color corresponding to the rendering pixel value.

[0119] In the disclosed embodiment, since the blending parameters are determined based on the pixel values ​​of the mask image of the image to be processed, the area for rendering the image to be processed can be determined; at the same time, since the preset transparency parameters are set, the rendered object to be processed can present different rendering effects according to different preset transparency parameters.

[0120] S602: Determine a target pixel value for each pixel of the image to be processed based on a rendered pixel value for each pixel of the image to be processed, a mixing weight of the rendered pixel values, and an original pixel value for each pixel of the object to be processed.

[0121] In some embodiments, after determining the mixing weight of the rendered pixel value of the pixel point, the rendered pixel value and the original pixel value of the pixel point of the image to be processed can be mixed in a weighted summation manner to obtain a target pixel value of the pixel point. The weight of the rendered pixel value of the pixel point is the mixing weight, and the weight of the original pixel value of the pixel point is 1 minus the mixing weight. Based on the obtained target pixel value of each pixel point of the image to be processed, the image to be processed is updated to obtain a target effect image.

[0122] In the embodiment of the present disclosure, by performing weighted summation on the rendered pixel value and the original pixel value of each pixel point of the image to be processed according to the mixing weight of the rendered pixel value, the target pixel value of the pixel point of the image to be processed can be obtained, thereby obtaining the target effect image after rendering the object to be processed.

[0123] The following describes the application of the image processing method provided by the embodiment of the present disclosure in an actual scenario, taking the scenario of dyeing the hair of a person in the acquired image to be processed as an example.

[0124] See also Figure 7 , which is a schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present disclosure.

[0125] like Figure 7 As shown, in the embodiment of the present disclosure, the image processing method includes the following steps:

[0126] S701, performing segmentation processing on the image to be processed to obtain a hair segmentation result.

[0127] In some embodiments, after obtaining an image to be processed that needs to be dyed, the hair included in the image to be processed needs to be identified first, and then the image to be processed is segmented and binarized to obtain a hair segmentation result. That is, a mask image including the area where the hair to be dyed is located is obtained, and the hair area in the mask image can be used to represent the area of ​​the hair included in the image to be processed in the image to be processed.

[0128] S702: Determine the average grayscale value of the hair color of the hair to be dyed according to the hair segmentation result.

[0129] In some embodiments, based on the hair segmentation result, all pixel points corresponding to the hair included in the image to be processed can be determined, that is, all pixel points included in the area corresponding to the hair area in the mask image in the image to be processed can be used as pixel points of the hair to be dyed.

[0130] First, the color value of each pixel of the hair to be dyed is converted into a gray value, and then the average gray value (mean_gray) of the hair color to be dyed is determined according to the gray value of each pixel of the hair to be dyed. The color value of each pixel of the hair to be dyed can be converted into a gray value by formula (3):

[0131] gray=0.11×b+0.59×g+0.3×r Formula (3);

[0132] Among them, gray represents the gray value of the pixel, b represents the value of the blue channel, g represents the value of the green channel, and r represents the value of the red channel.

[0133] S703 , obtaining the gray value of the target color, and determining the midtone of the original hair color based on the gray value of the target color and the average gray value of the hair color.

[0134] In some embodiments, in the process of dyeing the hair included in the image to be processed, the hair color needs to be adjusted first. The adjustment of the hair color level can be achieved based on the midtone of the original hair color. The midtone of the original hair color can be determined in the following way:

[0135] a. After selecting the target color (target_color) for dyeing, the gray value (target_gray) of the target color can be determined. The gray value of the target color can also be obtained by conversion using formula (3).

[0136] b. Determine the absolute value of the difference between the average gray value of the hair color and the gray value of the target color. The calculation formula of the absolute value is expressed as formula (2):

[0137] x=abs(mean_gray-target_gray) formula (4);

[0138] Among them, x represents the absolute value of the difference between the average gray value of hair color and the gray value of target color, mean_gray represents the average gray value of hair color, and target_gray represents the gray value of target color.

[0139] c. Determine the midtone value of the primary color:

[0140] i. When the average gray value of the hair color (mean_gray) is greater than the target color gray value (target_gray), do the following:

[0141] When diff>0.5, the midpoint value is 95.0;

[0142] Wherein, diff represents the difference between the average gray value of the hair color and the gray value of the target color.

[0143] When diff≤0.5, the midtone value is determined by formula (5) and formula (6):

[0144] y=-184.6×x 2 +182.7×x formula (5);

[0145] Wherein, x represents the absolute value of the difference between the average gray value of the hair color and the gray value of the target color, and y represents the intermediate parameter after the numerical range of x is adjusted.

[0146] midtone=clamp(50.0+y, 0.0, 100.0) formula (6);

[0147] Among them, y represents the intermediate parameter after adjusting the absolute value range of the difference between the average gray value of the hair color and the gray value of the target color, and midtone represents the midtone.

[0148] ii. When the average gray value of the hair color is less than the gray value of the target color, the value of the midtone is determined by formula (7) and formula (8):

[0149] y=139.63×x 2 +182.7×x formula (7);

[0150] Wherein, x represents the absolute value of the difference between the average gray value of the hair color and the gray value of the target color, and y represents the intermediate parameter after the numerical range of x is adjusted.

[0151] midtone=clamp(50.0-y, 0.0, 100.0) formula (8);

[0152] Among them, y represents the intermediate parameter after adjusting the absolute value range of the difference between the average gray value of the hair color and the gray value of the target color, and midtone represents the midtone.

[0153] Map the midtone range from [0, 100] to [9.99, 0.01]. The specific mapping calculation method is as follows:

[0154] i. When the midtone is less than 50, the value of the mapped midtone is determined by formula (9):

[0155] midtone=1.0+9×((50.0-midtone) / 50.0) formula (9);

[0156] ii. When the midtone is greater than or equal to 50, the value of the mapped midtone is determined by formula (10):

[0157] midtone=1.0-(midtone-50.0) / 50.0 formula (10);

[0158] iii. The midtone values ​​determined by formula (7) and formula (8) are further processed by formula (11) to limit the range, and the midtone of the primary color is obtained:

[0159] midtone=clamp(midtone, 0.01, 9.99) formula (11);

[0160] S704. Based on the midtone of the original hair color, adjust the brightness and darkness of the original hair color of the hair to be dyed.

[0161] In some embodiments, the brightness of the primary hair color of the hair to be dyed is adjusted, that is, the brightness of each pixel of the hair to be dyed in the processed image is adjusted, the purpose is to darken the bright primary hair color and brighten the dark primary hair color. The brightness of the primary hair color is determined by comparing it with the brightness of the target color, that is, when the average gray value of the hair color is greater than the gray value of the target color, the primary hair color is brighter than the brightness of the target color; when the average gray value of the hair color is smaller than the gray value of the target color, the primary hair color is darker than the brightness of the target color. The brightness of the primary hair color can be adjusted by formula (12), formula (13) and formula (14):

[0162] src_color.r=pow(src_color.r, 1.0 / midtone) formula (12);

[0163] src_color.g=pow(src_color.g, 1.0 / midtone) formula (13);

[0164] src_color.b=pow(src_color.b, 1.0 / midtone) formula (14);

[0165] Among them, src_color.r represents the value of the red channel of the pixel point of the hair to be dyed, src_color.g represents the value of the green channel of the pixel point of the hair to be dyed, and src_color.b represents the value of the blue channel of the pixel point of the hair to be dyed.

[0166] After adjusting the brightness of the original hair color, the first pixel value of each pixel of the hair to be dyed is obtained.

[0167] S705 . Based on the original color after brightness adjustment, perform a first mixing process on the original color after brightness adjustment and the target color.

[0168] In some embodiments, the color blending mode in Photoshop is used to blend the original hair color after adjusting the brightness with the target color, that is, the first pixel value of each pixel of the hair to be dyed and the pixel value of the target color are blended by formula (15) to obtain the second pixel value of each pixel of the hair to be dyed. The second pixel value retains the grayscale of the original hair color and has the hue and saturation of the target color.

[0169] result1_color=color(src_color, target_color) formula (15);

[0170] Among them, src_color represents the pixel value of the original color after adjusting the brightness, target_color represents the pixel value of the target color, and result1_color represents the second pixel value of the pixel point.

[0171] S706: Based on the original color after the first mixing process, perform transparency mixing process on the original color after the first mixing process and the original color.

[0172] In some embodiments, the original hair color after the first mixing process is subjected to a transparency mixing process with the original hair color, that is, the second pixel value of each pixel point of the hair to be dyed and the original pixel value of each pixel point of the hair to be dyed are weightedly summed by formula (16) to obtain the pixel value of the pixel point of the hair to be dyed after the transparency mixing process, thereby obtaining the final hair color after dyeing.

[0173] result2_color=mix(src_color.r, result1_color, mask×strength) formula (16);

[0174] Among them, mask represents transparency (corresponding to the mixing parameter in the above embodiment), and its value is 0 or 1, strength represents the transparency adjustment parameter (corresponding to the preset transparency parameter in the above embodiment), and result2_color is the pixel value of the pixel point of the hair to be dyed after the transparency mixing process.

[0175] In the disclosed embodiment, the midtone of the original hair color is determined based on the grayscale value of the target color and the average grayscale value of the hair color, and then the original hair color is adjusted for brightness based on the midtone; and the hair color after the color scale adjustment based on the midtone is subjected to a first mixing process with the target color, so that the original hair color after the first mixing process retains the grayscale of the original hair color and has the hue and saturation of the target color; at the same time, the original hair color after the first mixing process is subjected to a transparency mixing process with the original hair color, so that different areas of the obtained dyed hair can maintain the brightness of the original hair color, thereby making the dyed hair color closer to the real hair dyeing effect and making the color effect of the dyed hair color more natural.

[0176] Based on the foregoing embodiments, the embodiments of the present disclosure provide an image processing device, which includes the units included and the modules included in the units, which can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.

[0177] Figure 8 A schematic diagram of the structure of an image processing device provided by an embodiment of the present disclosure is shown in FIG. Figure 8 As shown, the image processing device 800 includes: an acquisition module 801, an adjustment parameter determination module 802, a rendering pixel value determination module 803 and a rendering module 804, wherein:

[0178] The acquisition module 801 is used to acquire an image to be processed and a target area of ​​the image to be processed, wherein the target area indicates a position of an object to be processed in the image to be processed.

[0179] The adjustment parameter determination module 802 is used to obtain the color to be rendered, and determine the color scale adjustment parameters of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area; the color scale adjustment parameters are used to adjust the brightness of the image to be processed.

[0180] The rendering pixel value determination module 803 is used to determine the rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered.

[0181] The rendering module 804 renders the object to be processed based on the rendering pixel value of each pixel point of the image to be processed to obtain a target effect image.

[0182] In some embodiments, the adjustment parameter determination module 802 is also used to determine the average grayscale value of the object to be processed based on the pixel values ​​of the pixel points in the target area; and determine the color scale adjustment parameter based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0183] In some embodiments, the adjustment parameter determination module 802 is also used to determine the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered when the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered.

[0184] In some embodiments, the adjustment parameter determination module 802 is further configured to use a preset adjustment parameter as the color scale adjustment parameter when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than a preset difference.

[0185] In some embodiments, the adjustment parameter determination module 802 is also used to determine a first intermediate value based on the absolute value of the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, when the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is less than or equal to a preset difference; the first intermediate value is negatively correlated with the square of the absolute value and positively correlated with the absolute value; the first intermediate value is increased based on a preset first increase parameter, and the increased first intermediate value is interval-restricted based on a preset first parameter interval to obtain the color scale adjustment parameter.

[0186] In some embodiments, the adjustment parameter determination module 802 is also used to determine a second intermediate value based on the absolute value of the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered, when the average grayscale value of the object to be processed is less than the grayscale value of the color to be rendered; the second intermediate value is positively correlated with the square of the absolute value and is positively correlated with the absolute value; the second intermediate value is negated, the negated second intermediate value is increased based on a preset second increase parameter, and the increased second intermediate value is interval-limited based on a preset second parameter interval to obtain the color scale adjustment parameter.

[0187] In some embodiments, the rendering pixel value determination module 803 is also used to adjust the brightness of each pixel of the image to be processed based on the color scale adjustment parameter to obtain a first pixel value of each pixel of the image to be processed; and to mix the first pixel value of each pixel of the image to be processed with the pixel value of the color to be rendered to obtain the rendering pixel value of each pixel of the image to be processed.

[0188] In some embodiments, the rendering pixel value determination module 803 is also used to numerically adjust the original pixel value of each pixel of the image to be processed based on the color scale adjustment parameter to obtain the first pixel value of the pixel; the numerical adjustment method is positively or negatively correlated with the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

[0189] In some embodiments, the rendering pixel value determination module 803 is further used to determine, for each pixel of the image to be processed, the rendering pixel value of each pixel of the image to be processed based on the brightness of the first pixel value of each pixel of the image to be processed and the hue and saturation of the color to be rendered.

[0190] In some embodiments, the rendering module 804 is further used to determine the mixing weight of the rendering pixel value for each pixel of the image to be processed; and determine the target pixel value of each pixel of the image to be processed based on the rendering pixel value of each pixel of the image to be processed, the mixing weight of the rendering pixel value and the original pixel value of each pixel of the object to be processed.

[0191] In some embodiments, the rendering module 804 is also used to obtain the mask image of the image to be processed; determine the mixing weight of the rendered pixel value based on a preset transparency parameter and a mixing parameter of the mask image of the image to be processed; and the mixing parameter is related to the pixel value of each pixel point of the mask image.

[0192] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiments of the present disclosure can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present disclosure, please refer to the description of the method embodiment of the present disclosure for understanding.

[0193] It should be noted that in the embodiments of the present disclosure, if the above-mentioned image processing method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present disclosure is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiments of the present disclosure are not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.

[0194] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.

[0195] The embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.

[0196] An embodiment of the present disclosure provides a computer program, including a computer-readable code. When the computer-readable code is executed in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.

[0197] The present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.

[0198] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product disclosed in the present invention, please refer to the description of the method embodiment disclosed in the present invention for understanding.

[0199] Fig. 9 A hardware entity diagram of an image processing device provided by an embodiment of the present disclosure, such as Fig. 9 As shown, the hardware entity of the image processing device 900 includes: a processor 901 and a memory 902, wherein the memory 902 stores a computer program that can be run on the processor 901, and the processor 901 implements the steps in the method of any of the above embodiments when executing the program.

[0200] The memory 902 stores a computer program that can be run on the processor. The memory 902 is configured to store instructions and applications executable by the processor 901. It can also cache data to be processed or processed by the processor 901 and each module in the image processing device 900 (for example, image data, audio data, voice communication data, and video communication data). This can be achieved through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0201] When the processor 901 executes the program, the steps of any of the above-mentioned image processing methods are implemented. The processor 901 generally controls the overall operation of the image processing device 900.

[0202] An embodiment of the present disclosure provides a computer storage medium, which stores one or more programs. The one or more programs can be executed by one or more processors to implement the steps of the image processing method of any of the above embodiments.

[0203] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure for understanding.

[0204] The processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understandable that the electronic device that implements the functions of the processor may also be other, which is not specifically limited in the embodiments of the present disclosure.

[0205] The above-mentioned computer storage medium / memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory (Flash Memory), a magnetic surface memory, an optical disk, or a compact disc read-only memory (CD-ROM) and the like; it can also be various terminals including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc.

[0206] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned steps / processes does not mean the order of execution. The execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments.

[0207] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0208] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0209] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0210] In addition, all functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may be separately configured as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0211] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.

[0212] Alternatively, if the above-mentioned integrated unit of the present disclosure is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.

[0213] The above description is only an implementation mode of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure.

Claims

1. An image processing method, characterized in that: The method comprises: Determine an image to be processed and a target area of ​​the image to be processed, wherein the target area indicates a position of an object to be processed in the image to be processed; Acquire a color to be rendered, and determine a color scale adjustment parameter of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area; the color scale adjustment parameter is used to adjust the brightness of the image to be processed; Determining a rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered; Based on the rendering pixel value of each pixel point of the image to be processed, the object to be processed is rendered to obtain a target effect image.

2. The method according to claim 1, characterized in that The step of determining the color scale adjustment parameter of the object to be processed based on the color to be rendered and the pixel values ​​of the pixels in the target area includes: Determine the average grayscale value of the object to be processed based on the pixel values ​​of the pixels in the target area; The color scale adjustment parameter is determined based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

3. The method according to claim 2, characterized in that The step of determining the color scale adjustment parameter based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered includes: When the average grayscale value of the object to be processed is greater than the grayscale value of the color to be rendered, the color scale adjustment parameter is determined based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

4. The method according to claim 3, characterized in that The step of determining the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered includes: When the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered is greater than a preset difference, the preset adjustment parameter is used as the color scale adjustment parameter.

5. The method according to claim 3, characterized in that: The step of determining the color scale adjustment parameter based on the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered includes: When the difference between the average gray value of the object to be processed and the gray value of the color to be rendered is less than or equal to a preset difference, a first intermediate value is determined based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered; the first intermediate value is negatively correlated with the square of the absolute value and positively correlated with the absolute value; The first intermediate value is increased based on a preset first increase parameter, and the increased first intermediate value is subjected to interval restriction processing based on a preset first parameter interval to obtain the color scale adjustment parameter.

6. The method according to claim 2, characterized in that The step of determining the color scale adjustment parameter based on the average grayscale value of the object to be processed and the grayscale value of the color to be rendered includes: In the case where the average gray value of the object to be processed is less than the gray value of the color to be rendered, a second intermediate value is determined based on the absolute value of the difference between the average gray value of the object to be processed and the gray value of the color to be rendered; the second intermediate value is positively correlated with the square of the absolute value and is positively correlated with the absolute value; The second intermediate value is inverted, the inverted second intermediate value is increased based on a preset second increase parameter, and the increased second intermediate value is interval-limited based on a preset second parameter interval to obtain the color scale adjustment parameter.

7. The method according to any one of claims 1 to 6, characterized in that: The step of determining the rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered includes: Based on the color scale adjustment parameter, the brightness of each pixel of the image to be processed is adjusted to obtain a first pixel value of each pixel of the image to be processed; The first pixel value of each pixel point of the image to be processed is mixed with the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel point of the image to be processed.

8. The method according to claim 7, characterized in that The step of adjusting the brightness of each pixel of the image to be processed based on the color scale adjustment parameter to obtain a first pixel value of each pixel of the image to be processed includes: For each pixel of the image to be processed, the original pixel value of the pixel is numerically adjusted based on the color scale adjustment parameter to obtain the first pixel value of the pixel; the numerical adjustment method is positively or negatively correlated with the difference between the average grayscale value of the object to be processed and the grayscale value of the color to be rendered.

9. The method according to claim 7 or 8, characterized in that: The mixing process of the first pixel value of each pixel point of the image to be processed and the pixel value of the color to be rendered to obtain the rendered pixel value of each pixel point of the image to be processed includes: For each pixel of the image to be processed, the rendering pixel value of each pixel of the image to be processed is determined based on the brightness of the first pixel value of each pixel of the image to be processed and the hue and saturation of the color to be rendered.

10. The method according to any one of claims 1 to 9, characterized in that: The step of rendering the object to be processed based on the rendering pixel value of each pixel point of the image to be processed to obtain a target effect image includes: For each pixel point of the image to be processed, determining a mixing weight of the rendered pixel value; A target pixel value of each pixel of the image to be processed is determined based on the rendered pixel value of each pixel of the image to be processed, the mixed weight of the rendered pixel value and the original pixel value of each pixel of the object to be processed.

11. The method according to claim 10, characterized in that The determining the blending weight of the rendered pixel value comprises: Acquire a mask image of the image to be processed; Based on a preset transparency parameter and a mixing parameter of the mask image of the image to be processed, a mixing weight of the rendering pixel value is determined; the mixing parameter is related to the pixel value of each pixel point of the mask image.

12. An image processing device, characterized in that: include: An acquisition module, used for acquiring an image to be processed and a target area of ​​the image to be processed, wherein the target area indicates a position of an object to be processed in the image to be processed; An adjustment parameter determination module, used for acquiring a color to be rendered, and determining a color scale adjustment parameter of the object to be processed based on the color to be rendered and pixel values ​​of pixels in the target area; The color scale adjustment parameter is used to adjust the brightness of the image to be processed; A rendering pixel value determination module, used for determining a rendering pixel value of each pixel of the image to be processed based on the color scale adjustment parameter and the color to be rendered; The rendering module renders the object to be processed based on the rendering pixel value of each pixel point of the image to be processed to obtain a target effect image.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 11 are implemented.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.