Image processing method and apparatus
By determining the upper limit of saturation based on the color information of pixels and calculating the adjustment ratio coefficient using a control curve when adjusting image saturation, the problems of color gamut and brightness changes are solved, and hue and brightness are preserved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING XIAOMI MOBILE SOFTWARE CO LTD
- Filing Date
- 2021-05-19
- Publication Date
- 2026-05-12
AI Technical Summary
When adjusting image saturation, existing techniques are prone to causing out-of-gamut issues and may alter brightness and hue.
When the received saturation adjustment ratio coefficient is greater than 1, the upper limit of saturation is determined based on the color information of the pixel, and the target value of the saturation adjustment ratio coefficient is calculated using the saturation adjustment control curve to avoid the problem of exceeding the color gamut, while keeping the hue and brightness unchanged.
It effectively avoids the problem of exceeding the color gamut, maintains the hue and brightness of the image, and improves the calculation speed.
Smart Images

Figure CN115375555B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method and apparatus. Background Technology
[0002] In related technologies, the image signal processing (ISP) unit of a camera is used to process the image signals acquired by the image sensor. The ISP unit may include multiple modules, such as a raw domain noise reduction module, a black level processing module, a lens shading correction module, a de-mosaic module, a color restoration module, a dynamic range adjustment module, a photoelectric conversion function module, a color preference adjustment module, and a color space conversion module. Color processing is a crucial step in the entire image signal processing process, and the modules involved in color processing include the color restoration module, the photoelectric conversion function module, and the color preference adjustment module. Adjusting saturation is a necessary step in the color preference adjustment module. However, adjusting saturation can easily lead to out-of-gamut issues. Summary of the Invention
[0003] To overcome the problems existing in the related technologies, this disclosure provides an image processing method and apparatus to avoid the problem of exceeding the color gamut when adjusting the saturation of an image.
[0004] According to a first aspect of the present disclosure, an image processing method is provided, comprising:
[0005] When the input value of the received saturation adjustment ratio coefficient is greater than 1, for the pixel in the image to be processed, the corresponding upper limit value of saturation is determined according to the first color information of the pixel.
[0006] A saturation adjustment control curve is determined based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve.
[0007] A first target value for the saturation adjustment ratio coefficient is determined based on the saturation of the pixel and the saturation adjustment control curve;
[0008] The saturation of the pixel is adjusted according to the first target value of the saturation adjustment ratio coefficient.
[0009] In one embodiment, determining the saturation adjustment control curve based on the input values of the upper limit of saturation and the saturation adjustment ratio coefficient includes:
[0010] Acquire coordinate data for at least one control point, the coordinate data including the saturation value and the corresponding saturation adjustment coefficient value;
[0011] A saturation adjustment control curve is determined based on the upper limit of saturation, the coordinate data of the at least one control point, and the input value of the saturation adjustment ratio coefficient, wherein the control point is located on the saturation adjustment control curve.
[0012] In one embodiment, the at least one control point includes a first control point and a second control point, wherein the saturation value of the first control point is less than the saturation value of the second control point, and the saturation value of the second control point is less than or equal to the upper limit of saturation; the functional expression of the saturation adjustment control curve is:
[0013]
[0014] Wherein, k′ is the value of the saturation adjustment ratio coefficient, S is the value of the saturation, k1 is the saturation value of the first control point, k2 is the saturation value of the second control point, MaxS is the upper limit value of the saturation, and k is the input value of the saturation adjustment ratio coefficient.
[0015] In one embodiment, determining the corresponding upper limit of saturation based on the first color information of the pixel includes:
[0016] For each pixel in the image to be processed, the corresponding saturation value is determined based on the first color information of the pixel; the first color information includes R color value, B color value and G color value.
[0017] For the color value in the first color information, calculate the value of the first saturation ratio coefficient corresponding to the color value to obtain the values of three first saturation ratio coefficients;
[0018] The minimum value among the three values of the first saturation scaling factor is obtained to obtain the value of the second saturation scaling factor;
[0019] The upper limit of saturation is determined based on the value of the second saturation scaling factor and the saturation value of the pixel.
[0020] In one embodiment, calculating the value of the first saturation ratio coefficient corresponding to the color value in the first color information, and obtaining three values of the first saturation ratio coefficient, includes:
[0021] For each pixel in the image to be processed, a first brightness value is determined based on the first color information. The first brightness value is the average of the R color value, the B color value and the G color value.
[0022] For the color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated using the following formula:
[0023]
[0024] Where I is the first brightness value, C is the R color value, B color value or G color value, γ(C,I) is the value of the first saturation ratio coefficient corresponding to C, and MAX() is a function that takes the maximum value from the given parameters.
[0025] In one embodiment, the method further includes:
[0026] When the input value of the saturation adjustment ratio coefficient is less than or equal to 1, the input value of the saturation adjustment ratio coefficient is determined as the first target value of the saturation adjustment ratio coefficient.
[0027] In one embodiment, adjusting the saturation of the pixel according to a first target value of the saturation adjustment ratio coefficient includes:
[0028] For each pixel in the image to be processed, a second brightness value is determined based on the first color information and the calculation formula for converting from RGB color space to YUV color space; the first color information includes R color value, B color value and G color value.
[0029] The second target value of the saturation adjustment ratio coefficient is determined based on the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information;
[0030] The saturation of the pixel is adjusted according to the second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel.
[0031] In one embodiment, the formula for converting the RGB color space to the YUV color space is:
[0032] L=C1*r+C2*g+C3*b
[0033] Where r is the R color value, g is the G color value, b is the B color value, C1 is the weighting coefficient of the R color value, C2 is the weighting coefficient of the G color value, C3 is the weighting coefficient of the B color value, and L is the second brightness value.
[0034] In one embodiment, determining the second target value of the saturation adjustment coefficient based on the second brightness value, the first target value of the saturation adjustment coefficient, and the first color information includes:
[0035] Substitute the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information into the following calculation formula to calculate the second target value of the saturation adjustment ratio coefficient:
[0036]
[0037] Wherein, L is the second brightness value, k′ is the first target value of the saturation adjustment ratio coefficient, r is the R color value, g is the G color value, b is the B color value, and t is the second target value of the saturation adjustment ratio coefficient.
[0038] In one embodiment, adjusting the saturation of the pixel based on the second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel includes:
[0039] For each pixel in the image to be processed, the second color information is obtained by substituting the first color information, the second target value of the saturation adjustment coefficient, and the second brightness value into the following calculation formula:
[0040]
[0041] The second color information includes R' color value, G' color value and B' color value, where r' is the R' color value, g' is the G' color value and b' is the B' color value.
[0042] According to a second aspect of the present disclosure, an image processing apparatus is provided, the apparatus comprising:
[0043] The first determining module is configured to determine the corresponding upper limit value of saturation based on the first color information of the pixel in the image to be processed when the input value of the received saturation adjustment ratio coefficient is greater than 1.
[0044] The second determining module is configured to determine a saturation adjustment control curve based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve.
[0045] The third determining module is configured to determine a first target value of the saturation adjustment ratio coefficient based on the saturation of the pixel and the saturation adjustment control curve;
[0046] The adjustment module is configured to adjust the saturation of the pixel according to a first target value of the saturation adjustment ratio coefficient.
[0047] According to a third aspect of the present disclosure, a terminal device is provided, including a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory to implement the above-described method.
[0048] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements the above-described method.
[0049] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: When adjusting the saturation of an image, if the input value of the received saturation adjustment ratio coefficient is greater than 1, for each pixel in the image to be processed, the corresponding upper limit value of saturation is determined according to the first color information of the pixel, and a saturation adjustment control curve is determined according to the upper limit value of saturation and the input value of the saturation adjustment ratio coefficient. This saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve. In this way, when determining the first target value of the saturation adjustment ratio coefficient according to the saturation of the pixel and the saturation adjustment control curve, the saturation value corresponding to the first target value of the saturation adjustment ratio coefficient will not be greater than the upper limit value of saturation. Therefore, when adjusting the saturation of the pixel according to the first target value of the saturation adjustment ratio coefficient, the problem of exceeding the color gamut can be avoided.
[0050] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0051] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0052] Figure 1 This is a flowchart illustrating an image processing method according to an exemplary embodiment.
[0053] Figure 2 This is a flowchart illustrating an image processing method according to another exemplary embodiment.
[0054] Figure 3 This is a flowchart illustrating an image processing method according to another exemplary embodiment.
[0055] Figure 4 This is a schematic diagram of a saturation adjustment control curve according to an exemplary embodiment.
[0056] Figure 5This is a flowchart illustrating an image processing method according to another exemplary embodiment.
[0057] Figure 6 This is a block diagram illustrating an image processing apparatus according to an exemplary embodiment.
[0058] Figure 7 This is a schematic diagram of the structure of a terminal device according to an exemplary embodiment. Detailed Implementation
[0059] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0060] In related technologies, a common approach to adjusting color saturation involves the following steps: First, convert the original RGB values to a perception-based color space (such as HSV, HSL, or HSI) or a color space that separates color and brightness (such as YCbCr or YUV). Then, adjust the saturation in the new color space. Finally, convert the adjusted values back to the RGB color space. The converted RGB values may contain out-of-gamut values (less than zero or greater than the maximum value), requiring truncation of these out-of-gamut pixels.
[0061] For example, adjusting color saturation is achieved using the perception-based HSV color space. The specific steps are: converting the original RGB values to the HSV color space to obtain HSV values; adjusting saturation only changes the S value, keeping the H and V values unchanged; if after adjustment, 0 ≤ S ≤ 1, there will be no out-of-gamut issue. However, adjusting saturation does not guarantee that the pixel brightness will remain constant.
[0062] For example, adjusting color saturation is achieved using the YUV color space. The specific steps are: converting the original RGB values to the YUV color space to obtain YUV values; adjusting saturation simply requires proportionally adjusting the U and V values while keeping the Y value unchanged. Although adjusting saturation does not change brightness, it can easily lead to out-of-gamut issues. Furthermore, the YUV color space has poor hue linearity, and proportionally adjusting the U and V values can also cause changes in the color hue.
[0063] To address the aforementioned problems, this disclosure provides an image processing method and apparatus to solve these technical issues. It can avoid issues such as exceeding the color gamut, brightness changes, and hue changes when adjusting image saturation, and it eliminates the need for color space conversion, thereby improving computational speed.
[0064] Figure 1 This is a flowchart illustrating an image processing method according to an exemplary embodiment. This image processing method can be applied to a terminal device, which can be a camera device or an image processing device, such as... Figure 1 As shown, the image processing method includes the following steps S101 to S107:
[0065] In step S101, the input value of the saturation adjustment ratio coefficient is received.
[0066] In this embodiment, the saturation adjustment scaling factor is a coefficient representing the ratio of the saturation value of the image after saturation adjustment to the saturation value of the image before saturation adjustment. The value of the saturation adjustment scaling factor is the ratio of the saturation value of the image after saturation adjustment to the saturation value of the image before saturation adjustment.
[0067] In this embodiment, the terminal device provides a function to adjust the saturation of an image and provides an interface for receiving an input value of a saturation adjustment ratio coefficient. When a user needs to adjust the saturation of an image, they can input the saturation adjustment ratio coefficient through the aforementioned interface. The input value of the saturation adjustment ratio coefficient reflects the user's desired saturation value for the adjusted image and serves as a reference value for adjusting the image saturation. That is, the final value of the saturation adjustment ratio coefficient can be either the input value or the value adjusted based on the input value.
[0068] In this embodiment, when the input value of the saturation adjustment ratio coefficient is 1, the image saturation remains unchanged; when the input value of the saturation adjustment ratio coefficient is less than 1, the image saturation is reduced; and when the input value of the saturation adjustment ratio coefficient is greater than 1, the image saturation is increased.
[0069] In step S102, it is determined whether the input value of the received saturation adjustment ratio coefficient is greater than 1. If it is determined that the input value of the received saturation adjustment ratio coefficient is greater than 1, step S103 is executed; otherwise, step S104 is executed. That is, if it is determined that the input value of the received saturation adjustment ratio coefficient is less than or equal to 1, step S104 is executed.
[0070] In step S103, for each pixel in the image to be processed, the corresponding upper limit value of saturation is determined based on the first color information of the pixel.
[0071] In this embodiment, when the received input value of the saturation adjustment ratio coefficient is greater than 1, for each pixel in the image to be processed, the corresponding upper limit value of saturation is determined based on the first color information of the pixel. That is, each pixel corresponds to an upper limit value of saturation.
[0072] It should be noted that the saturation range of an image is 0 to 100%. Therefore, the upper limit of saturation is less than or equal to 100%.
[0073] In this embodiment, as Figure 2 As shown, step S103 may include the following steps:
[0074] In step S1031, for each pixel in the image to be processed, the corresponding saturation value is determined according to the first color information of the pixel; the first color information includes R color value, B color value and G color value.
[0075] In this embodiment, the color space used for the image to be processed is the RGB color space. In the RGB color space, a point in three-dimensional space is used to represent a certain color. Each point has three components, which can represent the red brightness value, green brightness value, and blue brightness value of the color at that point, respectively. The brightness value can be limited to between 0 and 1.
[0076] In this embodiment, the first color information of each pixel in the image to be processed includes R color value, G color value and B color value, wherein the R color value, G color value and B color value can be the red brightness value, green brightness value and blue brightness value mentioned above, respectively.
[0077] In this embodiment, the saturation value of each pixel can be calculated using the formula for converting from RGB color space to HSI color space. In the HSI color space, H represents hue, S represents saturation, and I represents intensity (corresponding to image brightness and grayscale). It should be noted that in this embodiment, color space conversion is not required; that is, there is no need to convert the RGB color space to the HSI color space. Only the formula for converting from RGB to HSI color space is needed.
[0078] In this embodiment, for each pixel in the image to be processed, the saturation value of the pixel is calculated using the following formula (1).
[0079]
[0080] Where r is the R color value, g is the G color value, b is the B color value, and S is the saturation value of the pixel.
[0081] In step S1032, for each color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated to obtain the values of the three first saturation ratio coefficients.
[0082] In this embodiment, for each of the R, G, and B color values of each pixel, the value of the first saturation ratio coefficient corresponding to the color value is calculated to obtain the values of the three first saturation ratio coefficients.
[0083] In this embodiment, the method for calculating the value of the first saturation ratio coefficient corresponding to each color value in the first color information is as follows:
[0084] First, for each pixel in the image to be processed, a first brightness value is determined based on the first color information, where the first brightness value is the average of the R color value, the B color value, and the G color value. For example, the first brightness value can be calculated using the following formula (2).
[0085]
[0086] Where I is the first brightness value.
[0087] Next, for each color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated using the following formula (3):
[0088]
[0089] Where C is the R color value, B color value, or G color value, γ(C, I) is the value of the first saturation scaling factor corresponding to C, and MAX() is a function that takes the maximum value from the given parameters.
[0090] For example, when calculating the value of the first saturation ratio coefficient corresponding to the R color value, replace C in the calculation formula (3) with the R color value; when calculating the value of the first saturation ratio coefficient corresponding to the G color value, replace C in the calculation formula (3) with the G color value; when calculating the value of the first saturation ratio coefficient corresponding to the B color value, replace C in the calculation formula (3) with the B color value.
[0091] In this embodiment, for each color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated, and three values of the first saturation ratio coefficient can be obtained: γ(r, I), γ(g, I) and γ(b, I).
[0092] In this embodiment, γ(C, I) is the maximum value of the saturation adjustment ratio used when adjusting the saturation of C, or in other words, the maximum allowable value of the saturation adjustment ratio used when adjusting the saturation of C. That is, the value of the first saturation ratio coefficient corresponding to the color value is the maximum value of the saturation adjustment ratio used when adjusting the saturation of the color value.
[0093] In step S1033, the minimum value among the three values of the first saturation scaling factor is obtained to obtain the value of the second saturation scaling factor.
[0094] In this embodiment, for each pixel, the minimum value can be obtained from the values of the three first saturation scaling coefficients using the following calculation formula (4).
[0095] Ratio=MIN(γ(r,I), γ(g,I), γ(b,I)) (4)
[0096] Wherein, MIN() is a function that takes the minimum value from the given parameters, and Ratio is the value of the second saturation scaling factor.
[0097] In step S1034, the upper limit of saturation is determined based on the value of the second saturation scaling factor and the saturation value of the pixel.
[0098] In this embodiment, the upper limit of saturation can be determined by multiplying the value of the second saturation scaling factor by the saturation value of the pixel. For example, the upper limit of saturation can be calculated by substituting the value of the second saturation scaling factor and the saturation value of the pixel into the following formula (5).
[0099] MaxS = S * Ratio (5)
[0100] Where MaxS is the upper limit of saturation.
[0101] In step S104, the input value of the saturation adjustment ratio coefficient is determined as the first target value of the saturation adjustment ratio coefficient.
[0102] In this embodiment, when it is determined that the input value of the received saturation adjustment ratio coefficient is less than or equal to 1, the input value of the saturation adjustment ratio coefficient can be determined as the first target value of the saturation adjustment ratio coefficient.
[0103] In step S105, a saturation adjustment control curve is determined based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve.
[0104] In this embodiment, a saturation adjustment control curve is determined based on the input values of the upper limit of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient.
[0105] In this embodiment, the method for determining the saturation adjustment control curve based on the input values of the upper limit of saturation and the saturation adjustment ratio coefficient is as follows: Figure 3 As shown, the steps S1051 to S1052 may be included:
[0106] In step S1051, coordinate data of at least one control point is obtained, and the coordinate data includes the value of saturation and the value of the corresponding saturation adjustment coefficient.
[0107] In this embodiment, two control points can be preset: a first control point and a second control point. The coordinate data of each control point includes the saturation value and the corresponding saturation adjustment coefficient value.
[0108] In this embodiment, in step S1051, the coordinate data of the first control point and the coordinate data of the second control point are obtained. The saturation value of the first control point is less than the saturation value of the second control point, and the saturation value of the second control point is less than the upper limit of saturation. The saturation adjustment ratio coefficient of the first control point is the input value of the saturation adjustment ratio coefficient, and the saturation adjustment ratio coefficient of the second control point is 1. Of course, in other embodiments, the saturation value of the second control point can be equal to the upper limit of saturation.
[0109] In step S1052, a saturation adjustment control curve is determined based on the upper limit of saturation, the coordinate data of at least one control point, and the input value of the saturation adjustment ratio coefficient, wherein the control point is located on the saturation adjustment control curve.
[0110] In this embodiment, a saturation adjustment control curve is determined based on the upper limit of saturation, the coordinate data of the first control point, the coordinate data of the second control point, and the input value of the saturation adjustment ratio coefficient. The determined saturation adjustment control curve 41 can be as follows: Figure 4 As shown.
[0111] In this embodiment, as Figure 4 As shown, on the saturation adjustment control curve 41, when the saturation value is less than the saturation value at the first control point D1, the saturation adjustment proportional coefficient is the input value k. When the saturation value is greater than the saturation value at the second control point D2, the saturation adjustment proportional coefficient is 1. When the saturation value is greater than or equal to the saturation value at the first control point D1 and less than or equal to the saturation value at the second control point D2, the saturation value and the saturation adjustment proportional coefficient have a linear relationship.
[0112] In this embodiment, the functional expression of the saturation adjustment control curve 41 is as follows:
[0113]
[0114] Where k′ is the value of the saturation adjustment ratio coefficient, S is the value of saturation, k1 is the saturation value of the first control point, k2 is the saturation value of the second control point, MaxS is the upper limit of saturation, and k is the input value of the saturation adjustment ratio coefficient.
[0115] In step S106, the first target value of the saturation adjustment ratio coefficient is determined based on the saturation of the pixel and the saturation adjustment control curve.
[0116] In this embodiment, the first target value of the saturation adjustment ratio coefficient can be determined based on the saturation of the pixel and the aforementioned saturation adjustment control curve 41. For example, when the saturation value of the pixel is less than the saturation value of the first control point D1, the first target value of the saturation adjustment ratio coefficient is the input value k of the saturation adjustment ratio coefficient; when the saturation value is greater than the saturation value of the second control point D2, the first target value of the saturation adjustment ratio coefficient is 1. When the saturation value is greater than or equal to the saturation value of the first control point D1 and less than the saturation value of the second control point D2, the first target value of the saturation adjustment ratio coefficient corresponding to the saturation value can be calculated according to the aforementioned calculation formula (6), or it can be obtained by interpolation.
[0117] In step S107, the saturation of the pixel is adjusted according to the first target value of the saturation adjustment ratio coefficient.
[0118] In this embodiment, the saturation of a pixel can be adjusted according to a first target value of the saturation adjustment ratio coefficient. For example... Figure 5 As shown, the method for adjusting the saturation of a pixel based on a first target value of the saturation adjustment scaling factor may include the following steps 1071-1073:
[0119] In step 1071, for each pixel in the image to be processed, a second brightness value is determined based on the first color information and the calculation formula for converting the RGB color space to the YUV color space.
[0120] In this embodiment, for each pixel in the image to be processed, a second luminance value is determined based on the first color information and the calculation formula for converting from RGB color space to YUV color space. In the YUV color space, Y represents luminance, and U and V represent color difference. The calculation formula for converting from RGB color space to YUV color space is as follows:
[0121] L=C1*r+C2*g+C3*b (7)
[0122] Where r is the R color value, g is the G color value, b is the B color value, C1 is the weighting coefficient of the R color value, C2 is the weighting coefficient of the G color value, C3 is the weighting coefficient of the B color value, and L is the second brightness value.
[0123] In this embodiment, C1, C2, and C3 are generally calculated using the weighting coefficients for brightness in the BT.601 standard, with values of 0.299, 0.587, and 0.114, respectively. Of course, the weighting coefficients for brightness in the BT.709 and BT.2020 standards can also be used.
[0124] It should be noted that in this embodiment, the RGB color space is not converted to the YUV color space; only the calculation formula for converting the RGB color space to the YUV color space is used.
[0125] In step 1072, the second target value of the saturation adjustment ratio coefficient is determined based on the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information.
[0126] In this embodiment, the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information can be substituted into the following calculation formula (8) to calculate the second target value of the saturation adjustment ratio coefficient:
[0127]
[0128] Where L is the second brightness value, k′ is the first target value of the saturation adjustment ratio coefficient, r is the R color value, g is the G color value, b is the B color value, and t is the second target value of the saturation adjustment ratio coefficient.
[0129] In this embodiment, the second target value of the saturation adjustment ratio coefficient is calculated using the method of calculating the value of the saturation adjustment ratio coefficient in the HSI color space. Although this embodiment does not convert the RGB color space to the HSI color space, it is equivalent to the method of calculating the value of the saturation adjustment ratio coefficient after converting the RGB color space to the HSI color space, and it avoids color space conversion, which can improve the calculation speed.
[0130] In step 1073, the saturation of the pixel is adjusted according to the second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel.
[0131] In this embodiment, for each pixel in the image to be processed, the first color information, the second target value of the saturation adjustment coefficient, and the second brightness value are substituted into the following calculation formula to obtain the second color information:
[0132]
[0133] The second color information includes R' color value, G' color value and B' color value, where r' is the R' color value, g' is the G' color value and b' is the B' color value.
[0134] In this embodiment, after adjusting the saturation of the image to be processed, for each pixel, the R color value becomes the R' color value, the G color value becomes the G' color value, and the B color value becomes the B' color value.
[0135] In this embodiment, when adjusting the saturation of an image, if the input value of the received saturation adjustment ratio coefficient is greater than 1, for each pixel in the image to be processed, the corresponding upper limit value of saturation is determined based on the first color information of the pixel. A saturation adjustment control curve is then determined based on the upper limit value of saturation and the input value of the saturation adjustment ratio coefficient. This saturation adjustment control curve represents the relationship between the saturation value and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve. Therefore, when determining the first target value of the saturation adjustment ratio coefficient based on the saturation of the pixel and the saturation adjustment control curve, the saturation value corresponding to the first target value of the saturation adjustment ratio coefficient will not be greater than the upper limit value of saturation. Thus, when adjusting the saturation of the pixel based on the first target value of the saturation adjustment ratio coefficient, the problem of exceeding the color gamut can be avoided.
[0136] Furthermore, since the second target value of the saturation adjustment coefficient is calculated using the same method as that used in the HSI color space, the method for adjusting saturation in this embodiment is the same as that used in the HSI color space. Therefore, the hue remains unchanged when adjusting saturation. Thus, the solution provided in this embodiment avoids the problem of hue alteration.
[0137] Furthermore, since the pixel brightness value used when calculating the second target value of the saturation adjustment coefficient is the second brightness value, which is the pixel brightness value in the YUV color space, i.e. the pixel display brightness value, the problem of brightness change can be avoided when adjusting the saturation of the image.
[0138] Figure 6 This is a block diagram of an image processing apparatus according to an exemplary embodiment. Figure 6 As shown, in this embodiment, the device includes:
[0139] The first determining module 61 is configured to determine the corresponding upper limit value of saturation for a pixel in the image to be processed based on the first color information of the pixel when the input value of the received saturation adjustment ratio coefficient is greater than 1.
[0140] The second determining module 62 is configured to determine a saturation adjustment control curve based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve.
[0141] The third determining module 63 is configured to determine a first target value of the saturation adjustment ratio coefficient based on the saturation of the pixel and the saturation adjustment control curve.
[0142] The adjustment module 64 is configured to adjust the saturation of the pixel according to a first target value of the saturation adjustment ratio coefficient.
[0143] In one embodiment, the second determining module 62 includes:
[0144] The first acquisition submodule is configured to acquire coordinate data of at least one control point, the coordinate data including the saturation value and the corresponding saturation adjustment coefficient value;
[0145] The first determining submodule is configured to determine a saturation adjustment control curve based on the upper limit of saturation, the coordinate data of the at least one control point, and the input value of the saturation adjustment ratio coefficient, wherein the control point is located on the saturation adjustment control curve.
[0146] In one embodiment, the at least one control point includes a first control point and a second control point, wherein the saturation value of the first control point is less than the saturation value of the second control point, and the saturation value of the second control point is less than or equal to the upper limit of saturation; the functional expression of the saturation adjustment control curve is:
[0147]
[0148] Wherein, k′ is the value of the saturation adjustment ratio coefficient, S is the value of the saturation, k1 is the saturation value of the first control point, k2 is the saturation value of the second control point, MaxS is the upper limit value of the saturation, and k is the input value of the saturation adjustment ratio coefficient.
[0149] In one embodiment, the first determining module 61 includes:
[0150] The second determining submodule is configured to determine the saturation value of a pixel in the image to be processed based on the first color information of the pixel; the first color information includes R color value, B color value and G color value.
[0151] The first calculation submodule is configured to calculate the value of the first saturation ratio coefficient corresponding to the color value in the first color information, and obtain the values of three first saturation ratio coefficients.
[0152] The second acquisition submodule is configured to acquire the minimum value among the three values of the first saturation scaling factor to obtain the value of the second saturation scaling factor;
[0153] The third determining submodule is configured to determine the upper limit of saturation based on the value of the second saturation scaling factor and the saturation value of the pixel.
[0154] In one embodiment, the first computing submodule includes:
[0155] The fourth determining submodule is configured to determine a first brightness value for a pixel in the image to be processed based on the first color information. The first brightness value is the average of the R color value, the B color value and the G color value.
[0156] The second calculation submodule is configured to calculate the value of the first saturation ratio coefficient corresponding to the color value in the first color information using the following formula:
[0157]
[0158] Where I is the first brightness value, C is the R color value, B color value or G color value, γ(C,I) is the value of the first saturation ratio coefficient corresponding to C, and MAX() is a function that takes the maximum value from the given parameters.
[0159] In one embodiment, the apparatus further includes:
[0160] The fourth determining module is configured to determine the input value of the saturation adjustment ratio coefficient as the first target value of the saturation adjustment ratio coefficient when the input value of the saturation adjustment ratio coefficient is less than or equal to 1.
[0161] In one embodiment, the adjustment module 64 includes:
[0162] The fifth determining submodule is configured to determine a second brightness value for each pixel in the image to be processed, based on the first color information and the calculation formula for converting RGB color space to YUV color space; the first color information includes R color value, B color value and G color value.
[0163] The sixth determining submodule is configured to determine the second target value of the saturation adjustment ratio coefficient based on the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information;
[0164] The adjustment submodule is configured to adjust the saturation of the pixel according to a second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel.
[0165] In one embodiment, the formula for converting the RGB color space to the YUV color space is:
[0166] L=C1*r+C2*g+C3*b
[0167] Where r is the R color value, g is the G color value, b is the B color value, C1 is the weighting coefficient of the R color value, C2 is the weighting coefficient of the G color value, C3 is the weighting coefficient of the B color value, and L is the second brightness value.
[0168] In one embodiment, the sixth determining submodule is further configured to substitute the second brightness value, the first target value of the saturation adjustment coefficient, and the first color information into the following calculation formula to calculate the second target value of the saturation adjustment coefficient:
[0169]
[0170] Wherein, L is the second brightness value, k′ is the first target value of the saturation adjustment ratio coefficient, r is the R color value, g is the G color value, b is the B color value, and t is the second target value of the saturation adjustment ratio coefficient.
[0171] In one embodiment, the adjustment submodule is further configured to, for pixels in the image to be processed, substitute the first color information, the second target value of the saturation adjustment coefficient, and the second brightness value into the following calculation formula to obtain the second color information:
[0172]
[0173] The second color information includes R' color value, G' color value and B' color value, where r' is the R' color value, g' is the G' color value and b' is the B' color value.
[0174] Figure 7 This is a block diagram illustrating a terminal device according to an exemplary embodiment. For example, device 1000 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0175] Reference Figure 7The device 1000 may include one or more of the following components: a processing component 1002, a memory 1004, a power supply component 1006, a multimedia component 1008, an audio component 1010, an input / output (I / O) interface 1012, a sensor component 1014, and a communication component 1016.
[0176] Processing component 1002 typically controls the overall operation of device 1000, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 1002 may include one or more processors 1020 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 1002 may include one or more modules to facilitate interaction between processing component 1002 and other components. For example, processing component 1002 may include a multimedia module to facilitate interaction between multimedia component 1008 and processing component 1002.
[0177] Memory 1004 is configured to store various types of data to support the operation of device 1000. Examples of this data include instructions for any application or method operating on device 1000, contact data, phonebook data, messages, pictures, videos, etc. Memory 1004 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0178] The power supply component 1006 provides power to the various components of the device 1000. The power supply component 1006 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 1000.
[0179] Multimedia component 1008 includes a screen that provides an output interface between the device 1000 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 1008 includes a front-facing camera and / or a rear-facing camera. When the device 1000 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0180] Audio component 1010 is configured to output and / or input audio signals. For example, audio component 1010 includes a microphone (MIC) configured to receive external audio signals when device 1000 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 1004 or transmitted via communication component 1016. In some embodiments, audio component 1010 also includes a speaker for outputting audio signals.
[0181] I / O interface 1012 provides an interface between processing component 1002 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0182] Sensor assembly 1014 includes one or more sensors for providing state assessments of various aspects of device 1000. For example, sensor assembly 1014 may detect the on / off state of device 1000, the relative positioning of components such as the display and keypad of device 1000, changes in the position of device 1000 or a component of device 1000, the presence or absence of user contact with device 1000, the orientation or acceleration / deceleration of device 1000, and temperature changes of device 1000. Sensor assembly 1014 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 1014 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 1014 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0183] Communication component 1016 is configured to facilitate wired or wireless communication between device 1000 and other devices. Device 1000 can access wireless networks based on communication standards, such as WiFi, 2G or 3G, 4G LTE, 5G NR, or combinations thereof. In one exemplary embodiment, communication component 1016 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 1016 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0184] In an exemplary embodiment, device 1000 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0185] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1004 including instructions, which can be executed by a processor 1020 of device 1000 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0186] Regarding the apparatus in the above embodiments, the specific manner in which the processor performs the operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0187] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0188] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that, The method includes: When the input value of the received saturation adjustment ratio coefficient is greater than 1, for the pixel in the image to be processed, the corresponding upper limit value of saturation is determined according to the first color information of the pixel. A saturation adjustment control curve is determined based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve. A first target value for the saturation adjustment ratio coefficient is determined based on the saturation of the pixel and the saturation adjustment control curve; The saturation of the pixel is adjusted according to the first target value of the saturation adjustment ratio coefficient; Adjusting the saturation of the pixel according to the first target value of the saturation adjustment ratio coefficient includes: For each pixel in the image to be processed, a second brightness value is determined based on the first color information and the calculation formula for converting from RGB color space to YUV color space; the first color information includes R color value, B color value and G color value. The second target value of the saturation adjustment ratio coefficient is determined based on the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information; The saturation of the pixel is adjusted according to the second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel; The formula for converting the RGB color space to the YUV color space is as follows: Where r is the R color value, g is the G color value, b is the B color value, C1 is the weighting coefficient of the R color value, C2 is the weighting coefficient of the G color value, and C3 is the weighting coefficient of the B color value. This is the second brightness value; The step of determining the second target value of the saturation adjustment ratio coefficient based on the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information includes: Substitute the second brightness value, the first target value of the saturation adjustment ratio coefficient, and the first color information into the following calculation formula to calculate the second target value of the saturation adjustment ratio coefficient: in, This is the second brightness value. The first target value of the saturation adjustment ratio coefficient is r, where r is the R color value, g is the G color value, b is the B color value, and t is the second target value of the saturation adjustment ratio coefficient.
2. The method according to claim 1, characterized in that, The step of determining the saturation adjustment control curve based on the input values of the upper limit of saturation and the saturation adjustment ratio coefficient includes: Acquire coordinate data for at least one control point, the coordinate data including the saturation value and the corresponding saturation adjustment coefficient value; A saturation adjustment control curve is determined based on the upper limit of saturation, the coordinate data of the at least one control point, and the input value of the saturation adjustment ratio coefficient, wherein the control point is located on the saturation adjustment control curve.
3. The method according to claim 2, characterized in that, The at least one control point includes a first control point and a second control point, wherein the saturation value of the first control point is less than the saturation value of the second control point, and the saturation value of the second control point is less than or equal to the upper limit of saturation; the functional expression of the saturation adjustment control curve is: in, The value of the saturation adjustment coefficient, where S is the value of the saturation. The value of saturation at the first control point. The value of saturation at the second control point. is the upper limit value of saturation, and k is the input value of the saturation adjustment ratio coefficient.
4. The method according to claim 1, characterized in that, Determining the corresponding upper limit of saturation based on the first color information of the pixel includes: For each pixel in the image to be processed, the corresponding saturation value is determined based on the first color information of the pixel; the first color information includes R color value, B color value and G color value. For the color value in the first color information, calculate the value of the first saturation ratio coefficient corresponding to the color value to obtain the values of three first saturation ratio coefficients; The minimum value among the three values of the first saturation scaling factor is obtained to obtain the value of the second saturation scaling factor; The upper limit of saturation is determined based on the value of the second saturation scaling factor and the saturation value of the pixel.
5. The method according to claim 4, characterized in that, For the color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated, resulting in three values of the first saturation ratio coefficient, including: For each pixel in the image to be processed, a first brightness value is determined based on the first color information. The first brightness value is the average of the R color value, the B color value and the G color value. For the color value in the first color information, the value of the first saturation ratio coefficient corresponding to the color value is calculated using the following formula: Wherein, I represents the first brightness value, and C represents the R color value, B color value, or G color value. Let C be the value of the first saturation scaling factor, and MAX() is a function that takes the maximum value from the given parameters.
6. The method according to claim 1, characterized in that, Also includes: When the input value of the saturation adjustment ratio coefficient is less than or equal to 1, the input value of the saturation adjustment ratio coefficient is determined as the first target value of the saturation adjustment ratio coefficient.
7. The method according to claim 1, characterized in that, The step of adjusting the saturation of the pixel according to the second target value of the saturation adjustment ratio coefficient to obtain the second color information of the pixel includes: For each pixel in the image to be processed, the second color information is obtained by substituting the first color information, the second target value of the saturation adjustment coefficient, and the second brightness value into the following calculation formula: The second color information includes R' color value, G' color value and B' color value, where r' is the R' color value, g' is the G' color value and b' is the B' color value.
8. An image processing apparatus for performing the image processing method as described in any one of claims 1 to 7, characterized in that, The device includes: The first determining module is configured to determine the corresponding upper limit value of saturation for a pixel in the image to be processed based on the first color information of the pixel when the input value of the received saturation adjustment ratio coefficient is greater than 1. The second determining module is configured to determine a saturation adjustment control curve based on the input values of the upper limit value of saturation and the saturation adjustment ratio coefficient. The saturation adjustment control curve is used to represent the relationship between the value of saturation and the value of the saturation adjustment ratio coefficient. The upper limit value of saturation is the maximum value of saturation on the saturation adjustment control curve. The third determining module is configured to determine a first target value of the saturation adjustment ratio coefficient based on the saturation of the pixel and the saturation adjustment control curve; The adjustment module is configured to adjust the saturation of the pixel according to a first target value of the saturation adjustment ratio coefficient.
9. A terminal device, characterized in that, It includes a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory to implement the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-7.