Chroma adjustment method, electronic device and readable storage medium
View Patent ↗A chroma adjustment method, an electronic device and a non-transitory computer-readable storage medium are provided. The input color data is converted into preset color data in a preset color space. The preset color data is processed to determine a maximum chroma value among multiple chroma values for each of which the number of corresponding pixels is a peak in a chroma statistical graph, and a maximum luminance value of pixels corresponding to the maximum chroma value is determined. A chroma adjustment coefficient is obtained, according to the maximum chroma value, the maximum luminance value and a chroma mapping curve. The input color data is adjusted based on the chroma adjustment coefficient, to obtain output color data.
1 . A chroma adjustment method, comprising:
converting input color data into preset color data in a preset color space;
processing the preset color data to determine a maximum chroma value among a plurality of chroma values for each of which a number of corresponding pixels is a peak in a chroma statistical graph, and determining a maximum luminance value of pixels corresponding to the maximum chroma value;
obtaining a chroma adjustment coefficient, according to the maximum chroma value, the maximum luminance value and a chroma mapping curve; and
adjusting, based on the chroma adjustment coefficient, the input color data to obtain output color data;
wherein the method further comprises:
determining, as a peak, the number of corresponding pixels of a chroma value, in response to the number of corresponding pixels of the chroma value being greater than both numbers of corresponding pixels of two chroma values adjacent to the chroma value, thereby determining the plurality of chroma values for each of which the number of corresponding pixels is the peak in the chroma statistical graph.
2 . The chroma adjustment method as claimed in claim 1 , further comprising:
converting raw color data in a nonlinear space into the input color data in a linear space, wherein the linear space and the preset color space are different color spaces.
3 . The chroma adjustment method as claimed in claim 1 , wherein the converting input color data into preset color data in a preset color space, comprises:
processing the input color data to obtain a region of interest in an image corresponding to the input color data; and
converting input color data of the region of interest into the preset color data of the region of interest in the preset color space.
4 . The chroma adjustment method as claimed in claim 3 , wherein the processing the input color data to obtain a region of interest in an image corresponding to the input color data, comprises:
determining, according to a plurality of pixel values of the input color data, an average value of the plurality of the pixel values and a maximum value of the plurality of the pixel values;
determining, according to the average value and the maximum value, a threshold of the plurality of pixel values; and
determining a pixel region where the pixel values are greater than the threshold, as the region of interest.
5 . The chroma adjustment method as claimed in claim 4 , wherein the determining, according to the average value and the maximum value, a threshold of the plurality of pixel values, comprises:
determining, as the threshold, a median value between the average value and the maximum value.
6 . The chroma adjustment method as claimed in claim 3 , wherein the processing the preset color data to determine a maximum chroma value among a plurality of chroma values for each of which the number of corresponding pixels is a peak in a chroma statistical graph, and determine a maximum luminance value of pixels corresponding to the maximum chroma value, comprises:
processing the preset color data of the region of interest, to obtain the chroma statistical graph corresponding to the region of interest;
determining the plurality of chroma values for each of which the number of corresponding pixels is a peak in the chroma statistical graph, and obtaining the maximum chroma value of the plurality of chroma values; and
determining, the maximum luminance value of the pixels corresponding to the maximum chroma value.
7 . The chroma adjustment method as claimed in claim 3 , wherein the processing the input color data to obtain a region of interest in an image corresponding to the input color data, comprises:
in response to the image being a portrait, determining a face region in the image as the region of interest.
8 . The chroma adjustment method as claimed in claim 1 , wherein the obtaining a chroma adjustment coefficient according to the maximum chroma value, the maximum luminance value and a chroma mapping curve, comprises:
obtaining a target chroma value, according to the maximum luminance value and the chroma mapping curve; and
determining the chroma adjustment coefficient, according to a ratio of the target chroma value to the maximum chroma value.
9 . The chroma adjustment method as claimed in claim 1 , wherein the preset color space is an LCH color space.
10 . The chroma adjustment method as claimed in claim 1 , wherein the input color data is in an RGB color space, and the adjusting, based on the chroma adjustment coefficient, the input color data to obtain output color data is implemented by using the following expressions:
Ro=Ks *( Ri−Y )+ Y;
Go=Ks *( Gi−Y )+ Y;
Bo=Ks *( Bi−Y )+ Y;
where Ro represents a red primary value in the output color data, Go represents a green primary value in the output color data, Bo represents a blue primary value in the output color data, Ks represents the chroma adjustment coefficient, Y represents a luminance value corresponding to a pixel obtained through conversion from the RGB color space to a YUV color space, Ri represents a red primary value in the input color data, Gi represents a green primary value in the input color data, and Bi represents a blue primary value in the input color data.
11 . The chroma adjustment method as claimed in claim 10 , further comprising:
performing a Gamma operation on Ro, Go and Bo to obtain the output color data in a linear space.
12 . The chroma adjustment method as claimed in claim 1 , further comprising:
fitting chroma target values to obtain the chroma mapping curve.
13 . An electronic device, comprising one or more processors, wherein the one or more processors are configured to:
convert input color data into preset color data in a preset color space;
process the preset color data to determine a maximum chroma value among a plurality of chroma values for each of which a number of corresponding pixels is a peak in a chroma statistical graph, and determine a maximum luminance value of pixels corresponding to the maximum chroma value;
obtain a chroma adjustment coefficient, according to the maximum chroma value, the maximum luminance value and a chroma mapping curve; and
adjust, based on the chroma adjustment coefficient, the input color data to obtain output color data;
wherein the one or more processors are further configured to: determine, as a peak, the number of corresponding pixels of a chroma value, in response to the number of corresponding pixels of the chroma value being greater than both numbers of corresponding pixels of two chroma values adjacent to the chroma value, thereby determining the plurality of chroma values for each of which the number of corresponding pixels is the peak in the chroma statistical graph.
14 . The electronic device as claimed in claim 13 , wherein the one or more processors are configured to:
convert raw color data in a nonlinear space into the input color data in a linear space; and
convert the input color data in a linear space into the preset color data in a LCH color space.
15 . The electronic device as claimed in claim 13 , wherein the one or more processors are configured to:
process the input color data to obtain a region of interest in an image corresponding to the input color data; and
convert input color data of the region of interest into the preset color data of the region of interest in the preset color space.
16 . The electronic device as claimed in claim 15 , wherein the one or more processors are configured to:
determine, according to a plurality of pixel values of the input color data, an average value of the plurality of the pixel values and a maximum value of the plurality of the pixel values;
determine, according to the average value and the maximum value, a threshold of the plurality of pixel values; and
determine a pixel region where the pixel values are greater than the threshold, as the region of interest.
17 . The electronic device as claimed in claim 13 , wherein the one or more processors are configured to:
obtain a target chroma value, according to the maximum luminance value and the chroma mapping curve; and
determine the chroma adjustment coefficient, according to a ratio of the target chroma value to the maximum chroma value.
18 . The electronic device as claimed in claim 13 ,
wherein the input color data is in an RGB color space, and the one or more processors is configured to:
adjust, based on the chroma adjustment coefficient, the input color data to obtain output color data by using the following expressions:
Ro=Ks *( Ri−Y )+ Y;
Go=Ks *( Gi−Y )+ Y;
Bo=Ks *( Bi−Y )+ Y;
where Ro represents a red primary value in the output color data, Go represents a green primary value in the output color data, Bo represents a blue primary value in the output color data, Ks represents the chroma adjustment coefficient, Y represents a luminance value corresponding to a pixel obtained through conversion from the RGB color space to a YUV color space, Ri represents a red primary value in the input color data, Gi represents a green primary value in the input color data, and Bi represents a blue primary value in the input color data.
19 . A non-transitory computer-readable storage medium storing a computer program thereon, wherein the computer program, when being executed by one or more processors, causes operations of a chroma adjustment method be implemented, and the method comprises:
converting input color data into preset color data in a preset color space processing the preset color data to determine a maximum chroma value among a plurality of chroma values for each of which a number of corresponding pixels is a peak in a chroma statistical graph, and determining a maximum luminance value of pixels corresponding to the maximum chroma value;
obtaining a chroma adjustment coefficient, based on the maximum chroma value, the maximum luminance value and a chroma mapping curve; and
adjusting, based on the chroma adjustment coefficient, the input color data to obtain output color data;
wherein the method further comprises:
determining, as a peak, the number of corresponding pixels of a chroma value, in response to the number of corresponding pixels of the chroma value being greater than both numbers of corresponding pixels of two chroma values adjacent to the chroma value, thereby determining the plurality of chroma values for each of which the number of corresponding pixels is the peak in the chroma statistical graph.