Image Processing Method, Image Processing Apparatus, Electronic Device, and Storage Medium
By determining the face mask in image processing, acquiring image blocks, synthesizing the brightness transformation relationship and performing brightness transformation, the problem of poor image contrast enhancement effect in the prior art is solved, and efficient contrast enhancement is achieved while ensuring the visual effect of the portrait subject.
Patent Information
- Application Number
- CN202211180495.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-26
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2042-09-26
AI Technical Summary
The prior art has poor results in image contrast enhancement processing, especially when ensuring the visual effect of the portrait subject, it is difficult to coordinate the contrast between the face and the background.
By determining the face mask of the character image, acquiring image blocks, determining the global and local brightness transformation relationships, and synthesizing the brightness transformation relationships of each image block based on the face brightness transformation relationship, brightness transformation is performed to enhance image contrast.
On the premise of ensuring the visual effect of the portrait subject, effectively enhance image contrast and improve image quality.
Smart Images

Figure CN115423721B_ABST
Abstract
Description
Technical Field
[0001] This application relates to image processing technology, and more particularly, to an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium. Background Art
[0002] In order to improve image quality, contrast enhancement processing can be performed on an image. However, in the related art, the contrast enhancement effect of the image is poor. Summary of the Invention
[0003] Embodiments of this application provide an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium.
[0004] The image processing method according to the embodiments of this application is used to process a human image. The image processing method includes: determining a face mask of the human image; obtaining a plurality of image blocks of the human image; determining a global brightness transformation relationship of the human image and local brightness transformation relationships of the respective image blocks; determining a face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask; determining the brightness transformation relationships of the respective image blocks according to the global brightness transformation relationship, the local brightness transformation relationships, and the face brightness transformation relationship; and performing brightness transformation on the respective image blocks according to the brightness transformation relationships of the respective image blocks to obtain an output image.
[0005] The image processing apparatus according to the embodiments of this application is used to process a human image. The image processing apparatus includes a first determination module, an acquisition module, a second determination module, a third determination module, a fourth determination module, and a processing module. The first determination module is used to determine a face mask of the human image. The acquisition module is used to obtain a plurality of image blocks of the human image. The second determination module is used to determine a global brightness transformation relationship of the human image and local brightness transformation relationships of the respective image blocks. The third determination module is used to determine a face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask. The fourth determination module is used to determine the brightness transformation relationships of the respective image blocks according to the global brightness transformation relationship, the local brightness transformation relationships, and the face brightness transformation relationship. The processing module is used to perform brightness transformation on the respective image blocks according to the brightness transformation relationships of the respective image blocks to obtain an output image.
[0006] The electronic device according to the embodiments of this application includes one or more processors and a memory. When the computer program stored in the memory is executed by the processor, the steps of the image processing method according to any of the above embodiments are implemented.
[0007] A computer-readable storage medium according to an embodiment of the present application stores a computer program thereon. When the program is executed by a processor, the steps of the image processing method according to any one of the above embodiments are implemented.
[0008] In the image processing method, image processing device, electronic device, and computer-readable storage medium according to an embodiment of the present application, the brightness transformation relationship of each image block is determined according to the global brightness transformation relationship, local brightness transformation relationship, and face brightness transformation relationship. Therefore, the brightness transformation relationship of each image block can refer to the brightness of the face region image, global brightness, and local brightness, so as to enhance the image contrast on the premise of ensuring the visual effect of the portrait subject.
[0009] Additional aspects and advantages of the embodiments of the present application will be given in part in the following description, become apparent in part from the following description, or be understood through the practice of the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The above and / or additional aspects and advantages of the present application will become apparent and be readily understood from the description of the embodiments in conjunction with the following drawings, where:
[0011] Figure 1 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0012] Figure 2 is a schematic diagram of an image processing device according to some embodiments of the present application;
[0013] Figure 3 is a schematic diagram of an electronic device according to some embodiments of the present application;
[0014] Figure 4 is a schematic diagram of a portrait image according to some embodiments of the present application;
[0015] Figure 5 is a schematic diagram of a mapping curve according to some embodiments of the present application;
[0016] Figure 6 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0017] Figure 7 is a schematic diagram before image histogram equalization according to some embodiments of the present application;
[0018] Figure 8 is a schematic diagram after image histogram equalization according to some embodiments of the present application;
[0019] Figure 9 is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0020] Figure 10 It is a schematic diagram of a human image according to some embodiments of the present application;
[0021] Figure 11 It is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0022] Figures 12 to 14 It is a schematic diagram of the relationship between face brightness transformation according to some embodiments of the present application;
[0023] Figure 15 and Figure 16 It is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0024] Figure 17 It is a schematic diagram of an image processing apparatus according to some embodiments of the present application;
[0025] Figure 18 It is a schematic diagram of a portrait mask according to some embodiments of the present application;
[0026] Figure 19 It is a schematic diagram of an image block according to some embodiments of the present application;
[0027] Figure 20 It is a schematic flowchart of an image processing method according to some embodiments of the present application;
[0028] Figure 21 It is a schematic diagram of an image processing apparatus according to some embodiments of the present application;
[0029] Figure 22 and Figure 23 It is a schematic flowchart of an image processing method according to some embodiments of the present application. Detailed Embodiments
[0030] The following details the embodiments of the present application. The examples of the embodiments are shown in the accompanying drawings, and the same or similar reference numerals indicate the same or similar elements or elements with the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary only for explaining the present application and should not be construed as limiting the present application.
[0031] The following disclosure provides many different embodiments or examples for implementing different structures of the embodiments of the present application. To simplify the disclosure of the embodiments of the present application, the components and settings of specific examples are described below. Of course, they are only examples and are not intended to limit the present application.
[0032] To improve the image quality, the image can be processed by contrast enhancement. Among them, contrast refers to the measurement of different brightness levels between the brightest white and the darkest black in the light and dark areas of an image. The larger the difference range, the greater the contrast, and the smaller the difference range, the smaller the contrast. In the related art, the face and the area outside the face can be recognized, and different tone mapping schemes are used for different areas. However, in the related art, the coordination between the face and the body, and the coordination between the face and the background are not considered, and the image contrast enhancement effect is poor.
[0033] Please refer to Figure 1 , the image processing method of the embodiment of the present application is used to process a person image. The image processing method includes:
[0034] 01: Determine the face mask of the person image;
[0035] 02: Obtain multiple image blocks of the person image;
[0036] 03: Determine the global brightness transformation relationship of the person image and the local brightness transformation relationship of each image block;
[0037] 04: Determine the face brightness transformation relationship according to the brightness of the face area image corresponding to the face mask;
[0038] 05: Determine the brightness transformation relationship of each image block according to the global brightness transformation relationship, the local brightness transformation relationship and the face brightness transformation relationship;
[0039] 06: Perform brightness transformation on each image block respectively according to the brightness transformation relationship of each image block to obtain the output image.
[0040] Please refer to Figure 2 , the image processing device 100 includes a first determination module 11, an acquisition module 12, a second determination module 13, a third determination module 14, a fourth determination module 15 and a processing module 16.
[0041] The image processing method according to the embodiments of the present application can be implemented by the image processing apparatus 100 according to the embodiments of the present application. Among them, step 01 can be implemented by the first determination module 11, step 02 can be implemented by the acquisition module 12, step 03 can be implemented by the second determination module 13, step 04 can be implemented by the third determination module 14, step 05 can be implemented by the fourth determination module 15, and step 06 can be implemented by the processing module 16. That is to say, the first determination module 11 can be used to determine the face mask of the person image. The acquisition module 12 can be used to acquire a plurality of image blocks of the person image. The second determination module 13 can be used to determine the global brightness transformation relationship of the person image and the local brightness transformation relationship of each image block. The third determination module 14 can be used to determine the face brightness transformation relationship according to the brightness of the face area image corresponding to the face mask. The fourth determination module 15 can be used to determine the brightness transformation relationship of each image block according to the global brightness transformation relationship, the local brightness transformation relationship, and the face brightness transformation relationship. The processing module 16 can be used to perform brightness transformation on each image block respectively according to the brightness transformation relationship of each image block to obtain the output image.
[0042] In the image processing method and the image processing apparatus 100 according to the embodiments of the present application, the brightness transformation relationship of each image block is determined according to the global brightness transformation relationship, the local brightness transformation relationship, and the face brightness transformation relationship. Therefore, the brightness transformation relationship of each image block can refer to the brightness of the face area image, the global brightness, and the local brightness, so that the image contrast can be enhanced on the premise of ensuring the visual effect of the portrait subject.
[0043] Please refer to Figure 3 , the image processing apparatus 100 can be applied to the electronic device 1000. The electronic device 1000 may include devices such as a smart phone, a tablet computer, a smart watch, a smart bracelet, etc., which are not specifically limited herein. The electronic device 1000 according to the embodiments of the present application is exemplified by a smart phone, and should not be construed as a limitation to the present application.
[0044] Step 01 to determine the face mask of the person image can be implemented by using deep learning algorithms, image recognition, or depth map segmentation, etc., so as to obtain the area where the face area image is located in the person image, which is represented by a face mask. Determining the face mask can facilitate subsequent determination of the face brightness transformation relationship according to the face area image corresponding to the face mask.
[0045] To acquire a plurality of image blocks of the person image, specifically, the person image can be divided into a plurality of image blocks (block), where the size of the image block can be set differently according to the field of view (FOV) of the camera that captures the person image. In one embodiment, please refer to Figure 4, the character image can be divided into M*N image blocks, where M and N are both positive numbers greater than or equal to 1. For example, the character image can be divided into 4*4 image blocks.
[0046] Determine the global brightness transformation relationship Cg of the character image, and determine the local brightness transformation relationship Cxy of each image block, where x is the number of columns of the image block in the character image, and y is the number of rows of the image block in the character image. For example, the local brightness transformation relationship of the image block in the 2nd column and the 1st row is C21. The brightness transformation relationships (global brightness transformation relationship, local brightness transformation relationship, face brightness transformation relationship, filtered brightness transformation relationship, etc.) of the present application can all be mapping curves. A mapping curve is a transformation curve that describes the mapping transformation of image pixels from one value to another. Please refer to Figure 5 , the mapping curve can be Figure 5 As shown, the horizontal axis is the input brightness value and the vertical axis is the output brightness value. The purpose is to transform the pixel from one brightness to another.
[0047] The face brightness transformation curve Ch is determined according to the brightness of the face area image, and the brightness transformation relationship of each image block is determined according to the global brightness transformation relationship, the local brightness transformation relationship and the face brightness transformation relationship. The global brightness transformation relationship, the local brightness transformation relationship and the face brightness transformation relationship are integrated, and a balance is made in global contrast enhancement and local contrast enhancement. In order to prevent the portrait from being uncoordinated or the face being too dark or too bright during the contrast enhancement process, the face brightness transformation relationship is also applied. Therefore, the image contrast can be enhanced while ensuring the visual effect of the portrait subject.
[0048] The brightness of each image block is transformed according to the brightness transformation relationship of each image block. After all the image blocks are transformed, an output image can be obtained.
[0049] See also Figure 6 In some embodiments, step 03 (determining the global brightness transformation relationship of the character image and the local brightness transformation relationship of each image block) includes:
[0050] 032: Determine the global brightness transformation relationship and the local brightness transformation relationship through the histogram equalization method.
[0051] See also Figure 2 In some implementations, step 032 may be implemented by the second determination module 13, that is, the second determination module 13 may be used to determine the global brightness transformation relationship and the local brightness transformation relationship by using a histogram equalization method.
[0052] In this way, the global brightness transformation relationship and the local brightness transformation relationship can be determined quickly and accurately.
[0053] Specifically, the histogram equalization method is a method for adjusting the contrast using the image histogram in the field of image processing. The histogram equalization method calculates the global brightness transformation relationship by statistically analyzing the histogram of the brightness of the human image; and calculates the local brightness transformation relationship of each image block by statistically analyzing the histogram of the brightness of each image block, so that the transformed image has a more balanced histogram distribution. Please refer to Figure 7 and Figure 8 , Figure 7 is the effect before image histogram equalization, Figure 8 is the effect after image histogram equalization.
[0054] In other embodiments, the global brightness transformation relationship and the local brightness transformation relationship can also be obtained by other means, which are not specifically limited herein. Through the global brightness transformation relationship and the local brightness transformation relationship, the contrast of the transformed image can be enhanced.
[0055] Please refer to Figure 9 , in some embodiments, step 04 (determining the face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask) includes:
[0056] 042: Determining the average brightness of the face region image;
[0057] 044: Determining the face brightness transformation relationship according to the average brightness.
[0058] Please refer to Figure 2 , in some embodiments, step 042 and step 044 can be implemented by the third determination module 14, that is to say, the third determination module 14 can be used to: determine the average brightness of the face region image; determine the face brightness transformation relationship according to the average brightness.
[0059] In this way, the face brightness transformation relationship can be accurately determined according to the average brightness of the face region image.
[0060] Specifically, please refer to Figure 10, the face mask can, as shown in the figure, determine the average brightness of the face area image corresponding to the face mask. Among them, the calculation formula for the brightness of each pixel in the face area image can be L = (R + G + B) / 3, where R, G, and B represent the values corresponding to the red, green, and blue channels of the pixel. Of course, the brightness of each pixel can also be calculated using other weighted formulas, such as L = 0.299R + 0.587G + 0.114B, which is not specifically limited here. The average brightness of the face area image is the sum of the brightnesses of all pixels in the face area image divided by the number of pixels in the face area image. After obtaining the average brightness, the face brightness transformation relationship can be determined according to the average brightness.
[0061] Please refer to Figure 11 , in some embodiments, the face brightness transformation relationship includes one-to-one corresponding brightness input values and brightness output values. Step 044 (determining the face brightness transformation relationship according to the average brightness) includes:
[0062] 0442: When the average brightness is less than the first preset brightness, determine that the face brightness transformation relationship is the first transformation relationship, and the brightness output value of the first transformation relationship is greater than the corresponding brightness input value;
[0063] 0444: When the average brightness is greater than the first preset brightness and less than the second preset brightness, determine that the face brightness transformation relationship is the second transformation relationship, and the brightness output value of the second transformation relationship is equal to the corresponding brightness input value, and the second preset brightness is greater than the first preset brightness;
[0064] 0446: When the average brightness is greater than the second preset brightness, determine that the face brightness transformation relationship is the third transformation relationship, and the brightness output value of the third transformation relationship is less than the corresponding brightness input value.
[0065] Please refer to Figure 2 , in some embodiments, the face brightness transformation relationship includes one-to-one corresponding brightness input values and brightness output values. Step 0442, step 0444, and step 0446 can be implemented by the third determination module 14. That is to say, the third determination module 14 can be used to: when the average brightness is less than the first preset brightness, determine that the face brightness transformation relationship is the first transformation relationship, and the brightness output value of the first transformation relationship is greater than the corresponding brightness input value; when the average brightness is greater than the first preset brightness and less than the second preset brightness, determine that the face brightness transformation relationship is the second transformation relationship, and the brightness output value of the second transformation relationship is equal to the corresponding brightness input value, and the second preset brightness is greater than the first preset brightness; when the average brightness is greater than the second preset brightness, determine that the face brightness transformation relationship is the third transformation relationship, and the brightness output value of the third transformation relationship is less than the corresponding brightness input value.
[0066] In this way, different face brightness transformation relationships can be determined according to different average brightness levels to ensure the visual effect of the portrait subject.
[0067] Specifically, a brightness interval [th1, th2] can be set, where th1 is the first preset brightness and th2 is the second preset brightness. The face brightness transformation relationship is determined based on the average brightness and this brightness interval. When the average brightness Lf is greater than the first preset brightness th1 and less than the second preset brightness th2 (within the brightness interval), the face brightness transformation relationship is determined to be the second transformation relationship. The brightness output value of the second transformation relationship is equal to the corresponding brightness input value. That is to say, the second transformation relationship can be a straight line with a slope of 1. In other words, the face brightness transformation relationship can be a mapping curve with unchanged brightness, as Figure 12 shown. When the average brightness Lf is less than the first preset brightness th1, the face brightness transformation relationship is determined to be the first transformation relationship. The brightness output value of the first transformation relationship is greater than the corresponding brightness input value. The first transformation relationship can be as Figure 13 shown. The first transformation relationship can be a piecewise straight line. Using the first transformation relationship can increase the image brightness. In one embodiment, the pixel with brightness Lf in the first transformation relationship is just brightened to the first preset brightness th1. When the average brightness Lf is greater than the second preset brightness th2, the face brightness transformation relationship is determined to be the third transformation relationship. The brightness output value of the third transformation relationship is less than the corresponding brightness input value. The third transformation relationship can be as Figure 14 shown. The third transformation relationship can be a piecewise straight line. Using the third transformation relationship can darken the image. In one embodiment, the pixel with brightness Lf in the third transformation relationship is just darkened to the second preset brightness th2.
[0068] In other embodiments, the first transformation relationship and the third transformation relationship can also use spline curves or other interpolation curves to replace the piecewise straight lines, which are not specifically limited here.
[0069] Please refer to Figure 15 , in some embodiments, step 05 (determining the brightness transformation relationship of each image block according to the global brightness transformation relationship, the local brightness transformation relationship, and the face brightness transformation relationship) includes:
[0070] 052: Determining the brightness transformation relationship of each image block according to the global brightness transformation relationship and the global weight, the local brightness transformation relationship and the local weight, and the face brightness transformation relationship and the portrait area weight.
[0071] Please refer to Figure 2, in some embodiments, step 052 can be implemented by the fourth determination module 15, that is to say, the fourth determination module 15 can be used to: determine the brightness transformation relationship of each image block according to the global brightness transformation relationship and global weight, local brightness transformation relationship and local weight, and face brightness transformation relationship and portrait area weight.
[0072] In this way, the global brightness transformation relationship, local brightness transformation relationship, and face brightness transformation relationship can be fused through the global weight, local weight, and portrait area weight to form the brightness transformation relationship of each image block.
[0073] Specifically, the global weight Wg, local weight Wb, and portrait area weight Wh can be set in advance, then Cxy_out = (Wg * Cg + Wb * Cxy + Wh * Ch) / (Wg + Wb + Wh), where Cxy_out is the brightness transformation relationship of the image block in the x-th column and y-th row, that is, each brightness output value of the brightness transformation relationship of each image block is the weighted average of the brightness output values of the global brightness transformation relationship, local brightness transformation relationship, and face brightness transformation relationship. For example, in the global brightness transformation relationship, when the brightness input value is I1 (the value range of I1 is, for example, 0 - 255), the brightness output value is Og1; in the local brightness transformation relationship, when the brightness input value is I1, the brightness output value is Ob1; in the face brightness transformation relationship, when the brightness input value is I1, the brightness output value is Oh1, then in the brightness transformation relationship of the corresponding image block, when the brightness input value is I1, the brightness output value is (Wg * Og1 + Wb * Ob1 + Wh * Oh1) / (Wg + Wb + Wh).
[0074] Please refer to Figure 16 , in some embodiments, the portrait area weight includes a basic weight and a portrait proportion weight, and the image processing method includes:
[0075] 07: Determine the portrait mask of the person image;
[0076] 08: Determine the portrait proportion of each image block according to the portrait mask as the portrait proportion weight.
[0077] Please refer to Figure 17 , in some embodiments, the portrait area weight includes a basic weight and a portrait proportion weight, and the image processing device 100 includes a fifth determination module 17 and a sixth determination module 18. Step 07 can be implemented by the fifth determination module 17, and step 08 can be implemented by the sixth determination module 18. That is to say, the fifth determination module 17 can be used to determine the portrait mask of the person image. The sixth determination module 18 can be used to determine the portrait proportion of each image block according to the portrait mask as the portrait proportion weight.
[0078] In this way, the portrait ratio weight can be determined according to the portrait ratio, and the portrait area weight can be determined according to the portrait ratio weight.
[0079] Specifically, in step 07, a portrait mask of the person image can be determined, which can be implemented by means of deep learning algorithms, image recognition, depth map segmentation, etc., so as to obtain the area where the portrait area image is located in the person image, represented by a portrait mask. The portrait mask can be referred to Figure 18 , and the face mask is similar to the portrait mask. Wh = Wa * Pxy, where Wa is the basic weight and Pxy is the portrait ratio weight. The portrait ratio of each image block is determined according to the portrait mask. For example Figure 19 As shown, if the portrait accounts for 70% of the corresponding image block, then Pxy can be 0.7.
[0080] When determining the face brightness transformation relationship, it is mainly based on the face area image, and the weight corresponding to the face brightness transformation relationship is determined according to the portrait ratio. Therefore, the contrast can be adjusted by combining the portrait and the face, reducing the sense of fragmentation caused by adjusting the contrast only through the face.
[0081] Please refer to Figure 20 , in some embodiments, the image processing method further includes:
[0082] 09: Filter the brightness transformation relationship of the image block to obtain the filtered brightness transformation relationship of the image block;
[0083] Step 06 (performing brightness transformation on each image block according to the brightness transformation relationship of each image block to obtain an output image) includes:
[0084] 062: Performing brightness transformation on each image block according to the filtered brightness transformation relationship of each image block to obtain an output image.
[0085] Please refer to Figure 21 , in some embodiments, the image processing apparatus 100 further includes a filtering module 19. Step 09 can be implemented by the filtering module 19, and step 062 can be implemented by the processing module 16. That is to say, the filtering module 19 can be used to filter the brightness transformation relationship of the image block to obtain the filtered brightness transformation relationship of the image block. The processing module 16 can be used to perform brightness transformation on each image block according to the filtered brightness transformation relationship of each image block to obtain an output image.
[0086] In this way, a more accurate and smoother filtered brightness transformation relationship can be obtained.
[0087] Specifically, since the brightness transformation relationships of the respective image blocks are obtained independently (without mutual reference between the image blocks), the brightness transformation relationships of the respective image blocks may vary significantly. As a result, after the adjacent image blocks are subjected to brightness transformation according to the brightness transformation relationships, obvious dividing lines are likely to exist, that is, the respective regions of the output image are disjointed from each other, and the visual effect of the output image is poor. Therefore, the brightness transformation relationships of the image blocks can be filtered (spatial domain smoothing) to obtain the filtered brightness transformation relationships of the image blocks, thereby reducing the gap between the filtered brightness transformation relationships of the adjacent image blocks, and further enabling the respective regions of the output image obtained by performing brightness transformation according to the filtered brightness transformation relationships to have smooth transitions, and preventing the brightness transformation relationship of a certain image block from being abnormal, which may cause the image block to be abnormal after brightness transformation.
[0088] Please refer to Figure 22 , in some embodiments, step 09 (filtering the brightness transformation relationships of the image blocks to obtain the filtered brightness transformation relationships of the image blocks) includes:
[0089] 092: Obtain the current brightness output values corresponding to the same current brightness input value in the brightness transformation relationships of all the image blocks;
[0090] 094: Arrange all the current brightness output values according to the division manner of the image blocks;
[0091] 096: Filter the arranged current brightness output values to obtain the filtered brightness output values, and the filtered brightness transformation relationships of the respective image blocks include the corresponding relationships between the current brightness input values and the filtered brightness output values;
[0092] 098: Filter the brightness output values corresponding to all the brightness input values in the brightness transformation relationships of all the image blocks to obtain the filtered brightness transformation relationships of the respective image blocks.
[0093] Please refer to Figure 21 , in some embodiments, step 092, step 094, step 096, and step 098 can be implemented by the filtering module 19, that is to say, the filtering module 19 can be used to: obtain the current brightness output values corresponding to the same current brightness input value in the brightness transformation relationships of all the image blocks; arrange all the current brightness output values according to the division manner of the image blocks; filter the arranged current brightness output values to obtain the filtered brightness output values, and the filtered brightness transformation relationships of the respective image blocks include the corresponding relationships between the current brightness input values and the filtered brightness output values; filter the brightness output values corresponding to all the brightness input values in the brightness transformation relationships of all the image blocks to obtain the filtered brightness transformation relationships of the respective image blocks.
[0094] In this way, filtering processing can be performed to obtain the filtered luminance transformation relationship.
[0095] Specifically, obtain the current luminance output values corresponding to the same current luminance input value in the luminance transformation relationships of all image blocks. For example, the luminance transformation relationship can be represented by a mapping table. If the range of the luminance input value is 0 - 255, then each value in the range of 0 - 255 can be used as the current luminance input value respectively, and determine the current luminance output value corresponding to the current luminance input value in the luminance transformation relationships of all image blocks. Arrange all the current luminance output values according to the division method of the image blocks. For example, if a person image is divided into multiple image blocks in the M*N division method, then the current luminance output values are arranged into a two-dimensional matrix of M*N according to the positional relationship of the image blocks. Each current luminance input value corresponds to a two-dimensional matrix of M*N. In the case where the range of the luminance input value is 0 - 255, all the luminance input values can form 256 two-dimensional matrices of M*N. Perform filtering processing on the arranged current luminance output values to obtain the filtered luminance output values. Among them, the filtering processing methods can include Gaussian filtering, mean filtering, etc. Taking Gaussian filtering as an example, performing Gaussian filtering on the two-dimensional matrix of M*N is similar to performing Gaussian filtering on a two-dimensional image. A Gaussian kernel with a preset size (the preset size is an adjustable parameter, such as 3*3, 5*5, 7*7, 3*5, etc.) can be selected, and the Gaussian kernel is used to perform Gaussian filtering on the two-dimensional matrix of M*N, so as to obtain the filtered luminance output values. The current luminance input value and the filtered luminance output value are used as a set of corresponding relationships in the filtered luminance transformation relationship of the corresponding image block. During the process of performing filtering processing on the arranged current luminance output values, several convolutions can be performed, that is, several filtering processes can be performed (the number of filtering times is adjustable, such as 1 time, 2 times, 3 times, etc.).
[0096] In one embodiment, the luminance input value of the luminance transformation relationship Cxy_out of the image block in the x-th column and the y-th row is 0 - 255, and Cxy_out[i] represents the value corresponding to the luminance transformation relationship of the image block in the x-th column and the y-th row when the subscript is i, that is, when the luminance input value is i, the corresponding luminance output value of the image block in the x-th column and the y-th row is Cxy_out[i]. The filtering processing is aimed at the arranged current luminance output values. Among them, the arranged current luminance output values are each two-dimensional matrix of M*N composed of the same subscript (sequence number) in the luminance transformation relationships of all image blocks, rather than the luminance transformation relationship itself. For example, the meaning of performing filtering processing on Cxy_out[0] is: take out the values with subscript 0 (the luminance output values corresponding to the luminance input value of 0) in the luminance transformation relationships of all image blocks, arrange them in the M*N manner, and then perform filtering processing to obtain the filtered luminance output values.
[0097] Filter processing is performed on the brightness output values corresponding to all brightness input values in the brightness transformation relationship of all image blocks to obtain the filtered brightness transformation relationship of each image block. That is, filter processing is performed on all values of all subscripts (such as 0 - 255), so as to obtain the filtered brightness output values corresponding to all brightness input values of each image block, and all brightness input values and the corresponding filtered brightness output values form the filtered brightness transformation relationship.
[0098] Please refer to Figure 23 , in some embodiments, step 06 (performing brightness transformation on each image block according to the brightness transformation relationship of each image block to obtain the output image) includes:
[0099] 064: Determine the gain value according to the brightness value of the current pixel of the current image block and the brightness transformation relationship of the current image block;
[0100] 066: Perform gain on the color channels of the current pixel according to the gain value;
[0101] 068: Perform gain processing on all pixels of all image blocks to obtain the output image.
[0102] Please refer to Figure 2 , in some embodiments, step 064, step 066, and step 068 can be implemented by the processing module 16. That is to say, the processing module 16 can be used to: determine the gain value according to the brightness value of the current pixel of the current image block and the brightness transformation relationship of the current image block; perform gain on the color channels of the current pixel according to the gain value; perform gain processing on all pixels of all image blocks to obtain the output image.
[0103] In this way, gain can be performed on each image block to obtain a high - contrast output image.
[0104] Specifically, apply the brightness transformation relationship of the current image block or the filtered brightness transformation relationship of the current image block to all pixels of the current image block. Taking the three-channel values of each pixel as R, G, and B respectively as an example, calculate the brightness value of the current pixel. The calculation formula for the brightness value of the current pixel can be L = (R + G + B) / 3. Of course, it can also be L = 0.299R + 0.587G + 0.114B, etc., which is not specifically limited here. Then, obtain the target brightness value Lo = Cxy_out[L] according to the brightness transformation relationship or the filtered transformation relationship of the current image block, that is, use the brightness value of the current pixel as the brightness input value, and determine the brightness output value corresponding to the brightness transformation relationship or the filtered transformation relationship of the current image block as the target brightness value. Calculate the gain value Gain = Lo / L according to the brightness value of the current pixel and the target brightness value. Perform gain on the color channels of the current pixel according to the gain value, that is, Ro = R * Gain, Go = G * Gain, Bo = B * Gain. Perform gain processing on all pixels of all image blocks to obtain a high-contrast output image.
[0105] Please refer to Figure 3 , the image processing method of the embodiment of the present application can be implemented by the electronic device 1000 of the embodiment of the present application. Specifically, the electronic device 1000 includes one or more processors 200 and a memory 300. The memory 300 stores a computer program. When the computer program is executed by the processor 200, the steps of the image processing method of any of the above embodiments are implemented.
[0106] For example, when the computer program is executed by the processor 200, the steps of the following image test method are implemented:
[0107] 01: Determine the face mask of the person image;
[0108] 02: Obtain multiple image blocks of the person image;
[0109] 03: Determine the global brightness transformation relationship of the person image and the local brightness transformation relationship of each image block;
[0110] 04: Determine the face brightness transformation relationship according to the brightness of the face area image corresponding to the face mask;
[0111] 05: Determine the brightness transformation relationship of each image block according to the global brightness transformation relationship, the local brightness transformation relationship, and the face brightness transformation relationship;
[0112] 06: Perform brightness transformation on each image block respectively according to the brightness transformation relationship of each image block to obtain an output image.
[0113] A computer-readable storage medium according to an embodiment of the present application stores a computer program thereon. When the program is executed by a processor, the steps of the image processing method according to any one of the above embodiments are implemented.
[0114] For example, when the program is executed by a processor, the steps of the following image processing method are implemented:
[0115] 01: Determine the face mask of the person image;
[0116] 02: Obtain multiple image patches of the person image;
[0117] 03: Determine the global brightness transformation relationship of the person image and the local brightness transformation relationship of each image patch;
[0118] 04: Determine the face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask;
[0119] 05: Determine the brightness transformation relationship of each image patch according to the global brightness transformation relationship, the local brightness transformation relationship, and the face brightness transformation relationship;
[0120] 06: Perform brightness transformation on each image patch respectively according to the brightness transformation relationship of each image patch to obtain an output image.
[0121] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a specific logical function or process. The scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in the reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the technical field of the embodiments of the present application.
[0122] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion with one or more wirings (control method), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing as appropriate, and then stored in a computer memory.
[0123] It should be understood that various parts of the embodiments of the present application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits with suitable combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0124] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0125] In addition, each functional unit in various embodiments of the present application may be integrated into a processing module, or each unit may exist physically alone, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0126] The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disc, etc.
[0127] In the description of this specification, the description with reference to terms such as "certain embodiments" means that the specific features, structures or characteristics described in connection with the embodiments or examples are included in at least one embodiment of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment. Moreover, the specific features, structures or characteristics described may be combined in any one or more embodiments in a suitable manner.
[0128] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present application. Those of ordinary skill in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present application.
Claims
1. An image processing method for processing a human image, characterized in that, The described image processing method includes: Determining a face mask of the human image; Obtaining a plurality of image patches of the human image; Determining a global brightness transformation relationship of the human image and local brightness transformation relationships of each of the image patches; Determining a face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask; Determining the brightness transformation relationships of each of the image patches according to the global brightness transformation relationship, the local brightness transformation relationships, and the face brightness transformation relationship; Performing brightness transformation on each of the image patches respectively according to the brightness transformation relationships of each of the image patches to obtain an output image; The determining the face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask includes: Determining the average brightness of the face region image; Determining the face brightness transformation relationship according to the average brightness; The face brightness transformation relationship includes a one-to-one corresponding brightness input value and brightness output value, and the determining the face brightness transformation relationship according to the average brightness includes: When the average brightness is less than a first preset brightness, determining the face brightness transformation relationship as a first transformation relationship, and the brightness output value of the first transformation relationship is greater than the corresponding brightness input value; When the average brightness is greater than the first preset brightness and less than a second preset brightness, determining the face brightness transformation relationship as a second transformation relationship, and the brightness output value of the second transformation relationship is equal to the corresponding brightness input value, and the second preset brightness is greater than the first preset brightness; When the average brightness is greater than the second preset brightness, determining the face brightness transformation relationship as a third transformation relationship, and the brightness output value of the third transformation relationship is less than the corresponding brightness input value.
2. The image processing method according to claim 1, wherein The determining the global brightness transformation relationship of the human image and the local brightness transformation relationships of each of the image patches includes: Determining the global brightness transformation relationship and the local brightness transformation relationships by a histogram equalization method.
3. The image processing method according to claim 1, wherein The determining the brightness transformation relationships of each of the image patches according to the global brightness transformation relationship, the local brightness transformation relationships, and the face brightness transformation relationship includes: Determining the brightness transformation relationships of each of the image patches according to the global brightness transformation relationship and global weight, the local brightness transformation relationships and local weight, and the face brightness transformation relationship and portrait region weight.
4. The image processing method according to claim 3, wherein The portrait region weight includes a basic weight and a portrait proportion weight, and the image processing method includes: Determining a portrait mask of the human image; Determining the portrait proportion of each of the image patches according to the portrait mask as the portrait proportion weight.
5. The image processing method according to claim 1, wherein The image processing method further includes: Performing a filtering process on the brightness transformation relationships of the image patches to obtain the filtered brightness transformation relationships of the image patches; The performing brightness transformation on each of the image patches respectively according to the brightness transformation relationships of each of the image patches to obtain an output image includes: Performing brightness transformation on each of the image patches respectively according to the filtered brightness transformation relationships of each of the image patches to obtain the output image.
6. The image processing method according to claim 5, wherein Filtering the brightness transformation relationship of the image block to obtain the filtered brightness transformation relationship of the image block, including: Obtaining the current brightness output values corresponding to the same current brightness input value in the brightness transformation relationships of all the image blocks; Arranging all the current brightness output values according to the division manner of the image blocks; Performing filtering processing on the arranged current brightness output values to obtain the filtered brightness output values, and the filtered brightness transformation relationship of each image block includes the corresponding relationship between the current brightness input value and the filtered brightness output value; Performing filtering processing on the brightness output values corresponding to all the brightness input values in the brightness transformation relationships of all the image blocks to obtain the filtered brightness transformation relationships of each image block.
7. The image processing method according to claim 1, wherein Performing brightness transformation on each image block respectively according to the brightness transformation relationship of each image block to obtain the output image, including: Determining a gain value according to the brightness value of the current pixel of the current image block and the brightness transformation relationship of the current image block; Performing gain on the color channels of the current pixel according to the gain value; Performing gain processing on all the pixels of all the image blocks to obtain the output image.
8. An image processing apparatus for processing a human image, characterized in that, The image processing device includes: A first determination module for determining the face mask of the human image; An acquisition module for acquiring a plurality of image blocks of the human image; A second determination module for determining the global brightness transformation relationship of the human image and the local brightness transformation relationships of each image block; A third determination module for determining the face brightness transformation relationship according to the brightness of the face region image corresponding to the face mask; A fourth determination module for determining the brightness transformation relationship of each image block according to the global brightness transformation relationship, the local brightness transformation relationship and the face brightness transformation relationship; A processing module for performing brightness transformation on each image block respectively according to the brightness transformation relationship of each image block to obtain the output image; The third determination module is used to determine the average brightness of the face region image; and determine the face brightness transformation relationship according to the average brightness; The face brightness transformation relationship includes a one-to-one corresponding brightness input value and brightness output value. The third determination module is used to determine that when the average brightness is less than a first preset brightness, the face brightness transformation relationship is a first transformation relationship, and the brightness output value of the first transformation relationship is greater than the corresponding brightness input value; when the average brightness is greater than the first preset brightness and less than a second preset brightness, determine that the face brightness transformation relationship is a second transformation relationship, and the brightness output value of the second transformation relationship is equal to the corresponding brightness input value, and the second preset brightness is greater than the first preset brightness; when the average brightness is greater than the second preset brightness, determine that the face brightness transformation relationship is a third transformation relationship, and the brightness output value of the third transformation relationship is less than the corresponding brightness input value.
9. An electronic device, characterized in that, The electronic device includes one or more processors and a memory, and the memory stores a computer program. When the computer program is executed by the processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, the steps of the image processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
HUD image brightness adjusting system and implementation method
CN111935428A
Image processing method and electronic equipment
CN114463191A
Global mapping table generation method and device applied to image enhancement
CN115034975A