WO2020000255A1 - 一种rgb数据的色彩调整方法 - Google Patents

一种rgb数据的色彩调整方法 Download PDF

Info

Publication number
WO2020000255A1
WO2020000255A1 PCT/CN2018/093105 CN2018093105W WO2020000255A1 WO 2020000255 A1 WO2020000255 A1 WO 2020000255A1 CN 2018093105 W CN2018093105 W CN 2018093105W WO 2020000255 A1 WO2020000255 A1 WO 2020000255A1
Authority
WO
WIPO (PCT)
Prior art keywords
rgb
value
hue
adjustment
input data
Prior art date
Application number
PCT/CN2018/093105
Other languages
English (en)
French (fr)
Inventor
李宗原
吕臻凯
孙新江
那柏林
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2018/093105 priority Critical patent/WO2020000255A1/zh
Priority to CN201880086830.7A priority patent/CN111615714B/zh
Publication of WO2020000255A1 publication Critical patent/WO2020000255A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N1/00Scanning, transmission or reproduction of documents or the like, e.g. facsimile transmission; Details thereof
    • H04N1/46Colour picture communication systems
    • H04N1/56Processing of colour picture signals
    • H04N1/60Colour correction or control
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour

Definitions

  • the present application relates to the field of image processing, and in particular, to a method and device for color adjustment of RGB data.
  • image processing such as camera image signal processing (ISP) for camera, image processing (Display), digital image processing (Digital Image Processing) and other related fields, for the hue, saturation of the image (saturation) ) And brightness (brightness) adjustment is a common method to improve image quality.
  • ISP camera image signal processing
  • Display digital image processing
  • Digital Image Processing Digital Image Processing
  • hue, saturation of the image saturation
  • brightness (brightness) adjustment is a common method to improve image quality.
  • the HSV / HSL-based color adjustment method mainly includes: converting the input RGB data into the HSV / HSL color space to obtain the hue, brightness, and saturation corresponding to the input RGB data; and the obtained hue 3 parameters of brightness, brightness and saturation and hue adjustment value, brightness adjustment value and saturation adjustment value to perform a large number of floating-point operations to obtain color adjusted hue, brightness, and saturation; and then adjust the hue, brightness after adjustment And saturation are converted to RGB color space; finally displayed on the electronic device.
  • the corresponding hardware circuit needs to do a lot of floating-point operations, especially division Operation.
  • the division operation can be implemented by a divider or LUT (Look Up Table), but the divider requires a complex and high-precision fixed-point simplification process, and the LUT will occupy a lot of hardware resources and increase the clock delay, so it increases the The hardware area also reduces the rate of color adjustments to RGB data.
  • the embodiments of the present application provide a color adjustment method for RGB data, which can be used to solve the problems of large hardware and high power consumption caused by an LUT or a divider used as a floating point operation in the color adjustment process.
  • RGB a color space (mode) that adds the three primary colors of red, green, and blue in different proportions to produce a variety of color lights.
  • HSL A color space (mode) in which colors are represented by the superposition of three components: hue (hue), saturation (Saturation), and lightness (Lightness).
  • HSV Hue Saturation Value, a color space (mode) similar to HSL.
  • an embodiment of the present application provides a color adjustment method for RGB data, which is used to adjust hue, saturation, and brightness of RGB input data.
  • the above adjustment method includes: obtaining RGB input data, and obtaining a hue adjustment value, a saturation adjustment value, and a brightness adjustment value required for color adjustment of the RGB input data; calculating a first hue interval corresponding to the hue adjustment value; and according to the RGB input Data and the obtained first tone interval, determine that the RGB output data corresponds to the second tone interval; use the saturation adjustment value to adjust the saturation of the RGB input data, and use the brightness adjustment value to adjust the brightness of the RGB input data to obtain RGB adjustment data , And select RGB output data from the RGB adjustment data according to the second tone interval; display the obtained RGB output data.
  • calculating the first hue interval corresponding to the hue adjustment value includes: performing a division operation on the hue adjustment value H and the divisor 2 N1 , and obtaining the corresponding quotient Q and the remainder Rem, where the divisor 2 N1 is the hue's Overall angle, N1 is a non-negative integer.
  • the quotient Q obtained in the above calculation process represents the first tone interval corresponding to the tone adjustment value H
  • the remainder Rem represents the tone change amount of the tone adjustment value H to the tone value of the RGB input data in the adjusted tone interval.
  • a division operation is performed on the tone adjustment value to obtain a first tone interval corresponding to the tone adjustment value, so as to determine a change amount of the tone adjustment value to the tone interval of the RGB input data.
  • the hue adjustment value when the hue adjustment value is greater than or equal to the hue threshold value, the hue adjustment value is subtracted from the hue threshold value, otherwise the hue adjustment value is kept unchanged, and the hue threshold value is the maximum number of sections multiplied by an integer power of 2. square. Adjust the hue adjustment value so that the hue adjustment value is in a proper hue interval, to avoid that the hue interval in which the hue adjustment value is located is too large, resulting in an increase in the amount of calculation.
  • the step of determining a second tone interval corresponding to the RGB output data according to the RGB input data and the first tone interval includes: preprocessing the RGB input data to obtain an RGB parameter set; Perform linear calculation on one or more parameters in the set to obtain the candidate parameter set; determine the RGB output according to the size relationship between the RGB input data and the parameters in the RGB parameter set, and the size relationship between the RGB input data and the parameters in the above candidate parameter set
  • the second tone interval corresponding to the data can be determined through the above-mentioned calculation process, and the above-mentioned calculation process only involves simple addition operation, subtraction operation, multiplication operation, and comparison operation, and a large number of hardware resources are saved through a simple logic calculation circuit.
  • the step of calculating the RGB parameter set includes: calculating a maximum value and a minimum value of the RGB input data; calculating a difference between the maximum value and the minimum value; and calculating a sub-pixel difference value, wherein the sub-pixel difference value Includes the absolute value of the difference between every two color components. Since the calculation of the RGB parameter set only involves addition and subtraction of non-negative integers, a lot of hardware resources are saved.
  • the size relationship between a color component in the RGB input data and a parameter in the RGB parameter set is compared, and the size relationship between a color component in the RGB input data and a parameter in the above candidate parameter set is respectively compared.
  • a parameter is selected as the saturation coefficient from the above candidate parameter set.
  • the saturation coefficient is obtained by comparing the above parameters, and is used as a calculation parameter for subsequent brightness adjustment and saturation adjustment.
  • a hue interval index value is calculated according to the size relationship, and the hue interval index value is a sum of the quotient and the hue constant, where the hue constant is determined by the size relationship.
  • the hue interval index value is obtained through the above size relationship, and is used as a basis for subsequent selection of RGB output data.
  • the RGB adjustment data includes a second parameter p 1 , a third parameter p 2 , a fourth parameter p 3, and a fifth parameter RGB max , where:
  • p 1 (2 n1 ⁇ RGB max- ⁇ RGB ⁇ S) ⁇ 2 n2 ⁇ V;
  • p 2 (2 n3 ⁇ VS ⁇ Sx) ⁇ 2 n4 ⁇ V;
  • n1 to n7 are integers
  • RGB max is the maximum value
  • ⁇ RGB is the difference between the maximum value and the minimum value
  • S is the saturation adjustment value
  • V is the brightness adjustment value
  • Sx is the saturation coefficient.
  • the second parameter p 1 , the third parameter p 2 , the fourth parameter p 3, and the fifth parameter RGB max are obtained through the above process as optional parameters of the RGB output data, and the calculation process of the RGB adjustment data includes only addition operations, Subtraction operations, comparison operations, and multiplication operations that can be implemented through shifts save a lot of hardware resources and reduce power consumption.
  • three parameters in the RGB adjustment data are selected as RGB output data according to the hue interval index value.
  • the RGB output data is selected by using the above-mentioned tone interval index value to obtain RGB output data in a correct tone interval.
  • the hue interval index value when the hue interval index value is greater than or equal to the maximum number of hue interval numbers, the hue interval index value is subtracted from the maximum hue interval number; when the hue interval index value is less than the maximum hue interval number, the hue interval index is maintained The value does not change. Adjust the hue interval index value to an appropriate value range to reduce unnecessary calculations and save hardware resources.
  • an embodiment of the present application provides a color adjustment device for RGB data, which is used to adjust hue, saturation, and brightness of RGB input data.
  • the color adjusting device includes an obtaining module for obtaining RGB input data, and obtaining a hue adjustment value, a saturation adjustment value, and a brightness adjustment value required for color adjustment of the RGB input data; a first calculation module for calculating the hue adjustment The first hue interval corresponding to the value; the second calculation module is used to determine the second hue interval corresponding to the RGB output data according to the RGB input data and the obtained first hue interval; the adjustment module is used to adjust using the saturation adjustment value Saturation of RGB input data, and adjustment of brightness of RGB input data by using brightness adjustment values to obtain RGB adjustment data, and selecting RGB output data from RGB adjustment data according to the obtained second tone interval; a display module for displaying The obtained RGB output data;
  • the first calculation module 320 performs a division operation on the hue adjustment value and the divisor 2 N1 , and obtains the corresponding quotient Q and the remainder Rem, where the divisor 2 N1 is the total angle of the hue, and N1 is Non-negative integer.
  • the quotient Q obtained by the above calculation process represents the first tone interval corresponding to the tone adjustment
  • the remainder represents the tone change amount of the tone adjustment value to the tone value of the RGB input data in the adjusted tone interval.
  • a division operation is performed on the tone adjustment value to obtain a first tone interval corresponding to the tone adjustment value, so as to determine a change amount of the tone adjustment value to the tone interval of the RGB input data.
  • the first calculation module is further configured to subtract the hue adjustment value from the hue adjustment value; otherwise, the hue adjustment value is kept unchanged, and the hue threshold is Multiply the maximum number of tone intervals by a power of two. Adjust the hue adjustment value so that the hue adjustment value is in a proper hue interval, to avoid that the hue interval in which the hue adjustment value is located is too large, resulting in an increase in the amount of calculation.
  • the second calculation module is used to preprocess RGB input data to obtain an RGB parameter set; perform linear calculation on the remainder Rem and one or more parameters in the RGB parameter set to obtain a backup Selecting a parameter set; determining a second hue interval corresponding to the RGB output data according to the size relationship between the RGB input data and the parameter in the RGB parameter set, and the size relationship between the RGB input data and the parameter in the candidate parameter set.
  • the second hue interval corresponding to the RGB output data can be determined through the above-mentioned calculation process, and the above-mentioned calculation process only involves simple addition operation, subtraction operation, multiplication operation, and comparison operation, and a large number of hardware resources are saved through a simple logic calculation circuit.
  • the second calculation module is configured to calculate a maximum value and a minimum value of the RGB input data; calculate a difference value between the maximum value and the minimum value; and calculate a sub-pixel difference value, where the sub-pixel difference value Includes the absolute value of the difference between every two color components. Since the calculation of the RGB parameter set only involves addition and subtraction of non-negative integers, a lot of hardware resources are saved.
  • the magnitude relationship between a color component in the RGB input data and a parameter in the RGB parameter set, and a color component in the RGB input data and a parameter in the above-mentioned candidate parameter set are respectively compared. Size relationship.
  • the second calculation module selects one parameter from the candidate parameter set as the saturation coefficient according to the magnitude relationship.
  • the saturation coefficient is obtained by comparing the above parameters, and is used as a calculation parameter for subsequent brightness adjustment and saturation adjustment.
  • the second calculation module calculates a hue interval index value, and the hue interval index value is a sum of a quotient and a hue constant, where the hue constant is determined by the size relationship.
  • the hue interval index value is obtained through the above size relationship, and is used as a basis for subsequent selection of RGB output data.
  • the adjustment module calculates RGB adjustment data, and the RGB adjustment data includes a second parameter p 1 , a third parameter p 2 , a fourth parameter p 3, and a fifth parameter RGB max , where:
  • p1 (2 n1 ⁇ RGB max- ⁇ RGB ⁇ S) ⁇ 2 n2 ⁇ V;
  • p2 (2 n3 ⁇ VS ⁇ Sx) ⁇ 2 n4 ⁇ V;
  • n1 to n7 are integers
  • RGB max is the maximum value
  • ⁇ RGB is the difference between the maximum value and the minimum value
  • S is the saturation adjustment value Sat
  • V is the brightness adjustment value V
  • Sx is the saturation coefficient.
  • the second parameter p 1 , the third parameter p 2 , the fourth parameter p 3, and the fifth parameter RGB max are obtained through the above process as optional parameters of the RGB output data, and the calculation process of the RGB adjustment data includes only addition operations, Subtraction operations, comparison operations, and multiplication operations that can be implemented through shifts save a lot of hardware resources and reduce power consumption.
  • the adjustment module 340 uses the hue interval index value Indx as an index value of the RGB adjustment data, and selects among the second p 1 , the third p 2 , the fourth p 3, and the fifth RGB max .
  • the three parameters of R are the values of the three color components R, G, and B of the RGB output data.
  • the RGB output data is selected by using the above-mentioned tone interval index value to obtain RGB output data in a correct tone interval.
  • the adjustment module uses the hue interval index value minus the maximum hue interval number; when the hue interval index value is less than the maximum hue interval number, The above adjustment module keeps the hue interval index value unchanged. Adjust the hue interval index value to an appropriate value range to reduce unnecessary calculations and save hardware resources.
  • an embodiment of the present application provides a color adjustment device for RGB data, which is used to adjust the hue, saturation, and brightness of RGB input data.
  • the color adjustment device includes a memory for storing computer instructions, and a processor.
  • the processor is communicatively coupled to the above memory, wherein computer instructions configure the processor and are used to execute the color adjustment method in the first aspect and its possible implementations.
  • a computer-readable storage medium in an embodiment of the present application, which is characterized in that the computer-readable storage medium stores a computer program and is implemented by one or more processors when read and executed. And its possible implementations.
  • FIG. 1 is a schematic flowchart of a color adjustment method according to an embodiment of the present invention.
  • FIG. 2 is a more specific data flow diagram of a color adjustment method according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a color adjustment device according to an embodiment of the present invention.
  • FIG. 4 is an electronic device for color adjustment according to an embodiment of the present invention.
  • pixel data is represented by hue, saturation, and brightness.
  • the hue represents the basic attributes of the color, that is, the name of the color, and its value ranges from 0 to 360 °.
  • a color represented by a hue of 0 ° or 360 ° is red
  • a color represented by a hue of 120 ° is green
  • a color represented by a hue of 240 ° is blue.
  • Saturation represents the purity of the color, and its value ranges from 0 to 100%. The higher the saturation, the less gray and the more vivid the color.
  • the value ranges from 0 to 100%, representing the brightness of the color. The higher the brightness, the closer the color is to white.
  • the hue is 0 ° and the brightness is 100%, the color is white, and when the brightness is 50%, the color is gray.
  • all embodiments according to the present application use the HSV color space. It should be noted that according to all embodiments of the present application, the HSL color space can also be adopted.
  • FIG. 1 is a schematic flowchart of a color adjustment method according to an embodiment of the present application.
  • This method can perform an adjustment in the RGB color space according to the input hue adjustment value H, saturation adjustment value S, and brightness adjustment value V.
  • RGB input data adjusts hue, saturation, and brightness, and outputs color-adjusted RGB output data.
  • Both the RGB input data and the RGB output data are expressed in the RGB color space, that is, the values of the three color components R (Red, Red), G (Green, Green), and B (Blue, Blue) in the RGB color space.
  • step 110 RGB input data is acquired, and a hue adjustment value, a saturation adjustment value, and a brightness adjustment value required for color adjustment of the RGB input data are obtained.
  • step 120 the hue adjustment is calculated.
  • the hue adjustment value H, the saturation adjustment value S, and the brightness adjustment value V always perform color adjustment on the RGB input data in the RGB color space, and there is no need to first transform the RGB input data to the HSV color space. Perform inverse transformation to avoid a large number of floating-point operations and division operations.
  • the color adjustment process can only be implemented by adding, subtracting, comparing, and multiplying the color adjustment values, RGB input data, and intermediate parameters.
  • the data involved in the calculations are all non-negative integers and multiplication operations. Both are multiplications with 2 n , where n is an integer. Therefore, multiplication can be implemented by shifting or other simple calculation methods.
  • the color adjustment method according to the embodiment of the present application realizes color adjustment of RGB input data by adding, subtracting, comparing, and multiplying non-negative integers, thereby avoiding a large number of LUTs in the prior art.
  • the use of a divider saves hardware resources and reduces hardware power consumption.
  • FIG. 2 is a more specific data flow diagram of a color adjustment method provided by an embodiment of the present application.
  • the input tone adjustment value H is calculated to obtain a first tone interval corresponding to the tone adjustment value H.
  • hues with a total angle of 360 ° are usually divided into multiple hues by the maximum number of hues, where the maximum number of hus is a positive integer. For example, when the maximum number of tone intervals is 6, a tone interval is determined every 60 °. When the maximum number of tone intervals is larger, the tone interval is divided into finer tone intervals. Therefore, the accuracy of the tone adjustment increases, and the calculation complexity increases accordingly.
  • the total angle of the hue is 2 N1 °, where 2 N1 ° is divided by the maximum number of hue intervals M, and the angle of each divided hue interval is (2 N1 / M) °.
  • 0 hue angle range is 0 ⁇ (2 N1 / M) °, a first hue angle section (2 N1 /M)° ⁇ (2.2 N1 / M) °, and so on.
  • calculating the first hue interval corresponding to the hue adjustment value includes: performing a division operation 210 on the hue adjustment value H and the divisor 2 N1 , and obtaining the corresponding quotient Q and the remainder Rem, where the divisor 2 N1 is the total angle of the hue , N1 is a non-negative integer.
  • the division calculation of the hue adjustment value H in this application is not the only implementation method of the division operation 210, and other methods can be used to realize the calculation of the quotient Q and the remainder Rem, so as to implement the division operation using smaller hardware resources. The specific method is listed in detail below.
  • the quotient Q obtained from the above calculation process represents the first tone interval corresponding to the tone adjustment value H, that is, the quotient Q can reflect the change of the tone adjustment value H to the tone interval in which the RGB input data is located, or how many tone intervals are increased or decreased, that is, the The change of color attributes; and the remainder Rem represents the tone change amount of the tone adjustment value H to the tone value of the RGB input data in the adjusted tone interval, that is, the remainder Rem can reflect the hue adjustment value H to the RGB in the adjusted tone interval.
  • the amount of change in the hue value of the input data is from 0 to the maximum number of tone intervals M, and the remainder Rem is less than or equal to 2 N1 -1.
  • the hue adjustment value H when the hue adjustment value H is large, it may exceed the hue threshold value H thd . Therefore, before performing the division operation (210) on the hue adjustment value H, it is necessary to perform value range processing (211) on it to make the hue adjustment.
  • the value H is in an appropriate hue interval, and an increase in calculation amount caused by an excessive hue adjustment value H is avoided. Specifically, when the hue adjustment value H is greater than or equal to the hue threshold value H thd , the hue adjustment value H is subtracted from the hue threshold value H thd , otherwise the hue adjustment value H is kept unchanged, where the expression of the hue threshold value H thd is obtained for:
  • H thd M ⁇ 2 N1 .
  • N1 is an integer and M is the maximum number of intervals. Since the divisor in the above division operation is 2 N1 , the division operation (210) can be implemented by a relatively simple method to obtain the quotient Q and the remainder Rem, avoiding the use of a divider or LUT to implement the division operation, thereby reducing the division operation.
  • the area occupied by the hardware resources of (210) saves power consumption. For example, compare the hue adjustment values H and n ⁇ 2 N1 one by one, where n is 0, 1, 2,....
  • the hue adjustment value H is a non-negative integer
  • the quotient Q and the remainder Rem obtained are both non-negative integers.
  • a first hue interval corresponding to the hue adjustment value H can be determined.
  • the value range processing (211) is performed when the tone adjustment value H is too large, and the first tone interval corresponding to the tone adjustment value H can be adjusted to be in a proper tone interval.
  • a second tone interval corresponding to the RGB output data is determined according to the RGB input data and the first tone interval.
  • the step of determining the second tone interval corresponding to the RGB output data according to the RGB input data and the first tone interval includes: preprocessing (220) the RGB input data to obtain an RGB parameter set; the Rem and the RGB parameters Perform linear calculation (230) on one or more parameters in the set to obtain the candidate parameter set; according to the size relationship between the RGB input data and the parameters in the RGB parameter set, and the size relationship between the RGB input data and the parameter in the above candidate parameter set Determine the second tone interval corresponding to the RGB output data.
  • the step of preprocessing (220) the RGB input data to obtain the RGB parameter set includes:
  • the sub-pixel difference includes the absolute value of the difference between each two color components, that is, the absolute value of the difference between the red component R and the blue component B, RB abs , and the red component
  • the above-mentioned RGB parameter set includes RGB max , RGB min , ⁇ RGB, RB abs , RG abs and GB abs . Since the RGB input data are all non-negative integers, the obtained RGB parameter sets are all non-negative integers.
  • the candidate parameter set includes a result of performing a linear transformation on the above-mentioned remainder Rem and one or more parameters in the RGB parameter set, that is, parameters S 1 to S 11 .
  • the calculation method of the parameters S 1 to S 11 in the candidate parameter set is determined by the expressions in the following table:
  • S 3 S 1 +2 n ⁇ RG abs
  • S 4 S 1 +2 n ⁇ RB abs
  • S 5 S 2 -2 n ⁇ ⁇ RGB
  • S 6 S 3 -2 n ⁇ ⁇ RGB
  • S 7 S 4 -2 n ⁇ ⁇ RGB
  • S 8 S 1 +2 n ⁇ ⁇ RGB-2 n ⁇ GB abs
  • S 9 ⁇ RGB ⁇ Rem-2 n ⁇ GB abs
  • S 10 ⁇ RGB ⁇ Rem-2 n ⁇ RG abs
  • S 11 ⁇ RGB ⁇ Rem-2 n ⁇ RB abs
  • the candidate parameter set may include one or more other parameters, but these parameters include at least the first parameter S 1 or one or more obtained by performing a linear calculation (230) on the first parameter S 1 . parameter.
  • n is an integer
  • n in the expression of each parameter is an independent value.
  • the second tone interval corresponding to the RGB output data is determined according to the size relationship between the RGB input data and the parameter in the RGB parameter set, and the size relationship between the RGB input data and the parameter in the above candidate parameter set. Specifically, the size relationship between a color component in the RGB input data and a parameter in the RGB parameter set, and the size relationship between a color component in the RGB input data and a parameter in the above candidate parameter set are respectively compared. , And select a parameter from the candidate parameter set as the saturation coefficient Sx according to the size relationship, and calculate the hue interval index value Indx according to the size relationship and the quotient Q obtained by the division operation (210).
  • the above-mentioned comparison (240) includes at least one first-type comparison and at least one second-type comparison.
  • the first type of comparison includes the size comparison between the three color components R, G, and B in the RGB input data, the comparison between the RGB input data and the maximum value RGB max , and the RGB input data with the first threshold thd 1 and the second threshold thd.
  • the expressions for calculating the first threshold thd 1 and the second threshold thd 2 are:
  • thd 1 2 n ⁇ ⁇ RGB + B;
  • thd 2 2 n ⁇ ⁇ RGB + R.
  • n is an integer
  • n in thd 1 and thd 2 are mutually independent values
  • B is a blue color component
  • R is a red color component.
  • the second type of comparison includes a comparison between the parameters in the above-mentioned parameters S 2 , S 3 , S 4 , RB abs , RG abs, and GB abs and S 1 and ⁇ RGB ⁇ 2 n + S 1 . Based on the results of the above two comparisons, the values of the saturation coefficient Sx and the hue interval index value Indx are determined. Specifically, one of the parameters S 1 to S 11 is selected as the saturation index value Sx from the candidate parameter set according to the size relationship, and the hue interval index value Indx is calculated according to the size relationship.
  • the color component R is the maximum value of the RGB input data, and at the same time, determine whether the value of the color component G is greater than or equal to the value of the color component B, that is, G ⁇ B; in the second type of comparison, The magnitude relationship between the value of ⁇ RGB ⁇ 2 n + S 1 and the magnitudes of RB abs and S 5 were determined.
  • comparing results are a case of comparing results.
  • the above-mentioned comparison (240) and calculating the hue interval index value Indx can indirectly determine the hue interval corresponding to the RGB output data.
  • the quotient Q obtained by the division operation (210) can reflect the change in the hue interval of the hue adjustment value H to the RGB input data in the RGB color space, and the remainder Rem obtained by the division operation (210) can reflect the hue.
  • the adjustment value H is the adjustment amount of the hue of the RGB input data in the hue interval.
  • the tone interval corresponding to the RGB output data can be determined, that is, the tone interval index value Indx can reflect the tone interval after the tone adjustment value H acts on the RGB input data, that is, the tone interval corresponding to the RGB output data.
  • the saturation of the RGB input data is adjusted by using the saturation adjustment value S, and the brightness of the RGB input data is adjusted by using the brightness adjustment value V to obtain the RGB adjustment data.
  • RGB output data is selected from RGB adjustment data.
  • range processing may be performed on the hue interval index value Indx. Specifically, when the tone interval index value Indx is greater than or equal to the maximum tone interval number, the tone interval index value Indx is subtracted from the maximum tone interval number; when the tone interval index value Indx is less than the maximum tone interval number, the tone interval index is maintained. The value Indx does not change.
  • adjusting the saturation of the RGB input data by using the saturation adjustment value S, and adjusting the brightness of the RGB input data by using the brightness adjustment value V includes: calculating RGB adjustment data.
  • the RGB adjustment data includes a second parameter p 1 , a third parameter p 2 , a fourth parameter p 3, and a fifth parameter RGB max .
  • the calculation formula is determined by the following expression:
  • p 1 (2 n ⁇ RGB max- ⁇ RGB ⁇ S) ⁇ 2 n ⁇ V;
  • n is an integer
  • n in the expression of each parameter is an independent value.
  • the product of the maximum RGB max minus the saturation adjustment value S and the difference ⁇ RGB is used as the saturation adjustment value S to adjust the saturation of the RGB input data; the obtained result and the brightness adjustment
  • the value V is multiplied to adjust the brightness of the RGB input data as the brightness adjustment value V.
  • the saturation adjustment value S is multiplied with the saturation coefficient Sx, and the saturation adjustment value S is used to adjust the saturation of the RGB input data; the brightness adjustment value V is subtracted from the result It is then multiplied with the brightness adjustment value V to adjust the brightness of the RGB input data as the brightness adjustment value V.
  • the intermediate parameters p 31 , p 32 and p 33 need to be calculated first.
  • the calculation formula is determined by the following expression:
  • n is an integer.
  • the saturation adjustment value S is multiplied by the minimum value RGB min and the saturation coefficient Sx, respectively, as the saturation adjustment value S to adjust the saturation of the RGB input data.
  • p 3 [p 31 + p 32- (2 n1 ⁇ RGB max ⁇ p 33 )] ⁇ 2 n2 ⁇ V;
  • p 3 [p 31 + p 32 + (2 n1 ⁇ RGB max ⁇ p 33 )] ⁇ 2 n2 ⁇ V.
  • n 1 and n 2 are independent integers.
  • RGB max ⁇ p 33 and V and 2 Multiply integer powers of. Specifically, multiplying RGB max ⁇ p 33 and the integer power of V and 2 can be achieved by shifting the above data to the left or right by one or more times.
  • the hue interval index value Indx is used as the index value of the RGB adjustment data, and three parameters of the second p 1 , the third p 2 , the fourth p 3 and the fifth RGB max are selected.
  • the values of the three color components R, G, and B as RGB output data.
  • the tone interval index value Indx 0
  • the selected RGB output data may be any three of the parameters p 1 , p 2 , p 3 and RGB max .
  • the obtained RGB output data is displayed on a display device (270) to obtain a color adjustment effect on the RGB input data.
  • the embodiment of the application also provides a corresponding color adjustment device.
  • FIG. 3 is a schematic structural diagram of a RGB data color adjustment device 300 according to an embodiment of the present application.
  • the color adjustment device 300 includes:
  • the obtaining module 310 is configured to obtain RGB input data and obtain a hue adjustment value, a saturation adjustment value, and a brightness adjustment value required for color adjustment of the RGB input data;
  • a first calculation module 320 configured to calculate a first hue interval corresponding to a hue adjustment value
  • a second calculation module 330 configured to determine a second tone interval corresponding to the RGB output data according to the RGB input data and the obtained first tone interval;
  • An adjustment module 340 is configured to adjust the saturation of the RGB input data by using the saturation adjustment value, and adjust the brightness of the RGB input data by using the brightness adjustment value to obtain the RGB adjustment data, and adjust the data from the RGB according to the obtained second tone interval Select RGB output data;
  • the first calculation module 320 performs the division operation 210 on the hue adjustment value H and the divisor 2 N1 , and obtains the corresponding quotient Q and the remainder Rem, where the divisor 2 N1 is the total angle of the hue, N1 is a non-negative integer.
  • the quotient Q obtained in the above calculation process represents the first tone interval corresponding to the tone adjustment value H
  • the remainder Rem represents the tone change amount of the tone adjustment value H to the tone value of the RGB input data in the adjusted tone interval.
  • the foregoing first calculation module 320 is further configured to subtract the hue adjustment value H from the hue threshold H thd , otherwise the hue adjustment value is maintained H does not change, and the above-mentioned hue threshold is the integer power of 2 times the maximum number of hue intervals.
  • the second calculation module 330 is configured to preprocess RGB input data to obtain an RGB parameter set; perform linear calculation on the remainder Rem and one or more parameters in the RGB parameter set to obtain A candidate parameter set; determining a second hue interval corresponding to the RGB output data according to the size relationship between the RGB input data and the parameter in the RGB parameter set, and the size relationship between the RGB input data and the parameter in the candidate parameter set.
  • the magnitude relationship between a color component in the RGB input data and a parameter in the RGB parameter set, and a color component in the RGB input data and a parameter in the above-mentioned candidate parameter set are respectively compared. Size relationship.
  • the above-mentioned second calculation module 330 calculates a hue interval index value, and the hue interval index value is a sum of a quotient Q and a hue constant, where the hue constant is determined through the size relationship.
  • the second calculation module 330 selects one parameter from the candidate parameter set as the saturation coefficient according to the size relationship.
  • the adjustment module 340 uses the hue interval index value Indx to subtract the maximum hue interval number; when the hue interval index value Indx is less than the maximum hue For the number of intervals, the adjustment module 340 keeps the hue interval index value Indx unchanged.
  • the adjustment module 340 calculates RGB adjustment data, and the RGB adjustment data includes a second parameter p 1 , a third parameter p 2 , a fourth parameter p 3, and a fifth parameter RGB max , where:
  • p 1 (2 n1 ⁇ RGB max- ⁇ RGB ⁇ S) ⁇ 2 n2 ⁇ V;
  • p 2 (2 n3 ⁇ VS ⁇ Sx) ⁇ 2 n4 ⁇ V;
  • n1 to n7 are integers
  • RGB max is the maximum value
  • ⁇ RGB is the difference between the maximum value and the minimum value
  • S is the saturation adjustment value Sat
  • V is the brightness adjustment value V
  • Sx is the saturation coefficient
  • the adjustment module 340 uses the hue interval index value Indx as an index value of the RGB adjustment data, and selects among the second p 1 , the third p 2 , the fourth p 3, and the fifth RGB max .
  • the three parameters of R are the values of the three color components R, G, and B of the RGB output data.
  • the electronic device 400 shown in FIG. 4 is a device that can execute the color adjustment method in the above embodiment.
  • the electronic device 400 includes a bus 401, a processor 402, a memory 403, and a display device 404.
  • the electronic device 400 may further include an input device 405, a radio frequency circuit 406, a communication device 407, a sensor device 408, an audio device 409, and a power supply device. 410.
  • the electronic device 400 may be a communication device, such as a mobile phone, a portable computer, and the like.
  • the processor 402 and the memory 403 are communicatively coupled with each other, and there is a high-speed data transmission connection.
  • the high-speed data transmission connection can be achieved by communicating with the bus 401 of the processor 402 and the memory 403, and the bus 401 can be an AXI (Advanced Xtensible Interface) ) Bus protocol, or other bus protocols.
  • the processor 402 may be a central processing unit (CPU), and is configured to run software programs and / or instructions stored in the memory 403 to perform various functions of the electronic device 400.
  • the CPU may be based on an X86 architecture, CPU based on ARM architecture and cortex-A architecture.
  • the processor 402 may also be an application processor (AP) and / or an image signal processor (ISP).
  • AP application processor
  • ISP image signal processor
  • the memory 403 may include volatile memory, such as random access memory (RAM), and may also include non-volatile memory, such as flash memory, hard disk, or solid-state drive (SSD). It can also be a combination of the above types of memories.
  • the display device 404 is used to output visible text, graphics, video, and any combination thereof.
  • the display device 404 may be an LCD (Liquid Crystal Display) or an LPD (Lighting Power Density).
  • the user can input commands and information into the electronic device 400 through an input device 405, such as image data or video stream data to be adjusted for color.
  • the input device 405 can be a mouse, a keyboard, a scanner, or a camera.
  • the radio frequency circuit 406 is used to receive and send electromagnetic waves, convert electric signals into electromagnetic waves, or convert electromagnetic waves into electric signals, and communicate with a communication network or other communication equipment through the electromagnetic waves.
  • the communication module 407 is configured to process communication data, for example, communication data represented by an electrical signal received by the radio frequency circuit 406 and transformed into.
  • the sensor device 408 includes one or more sensors for receiving an external environmental stimulus and providing a physical response.
  • the sensor device 408 may include a distance sensor configured to detect whether an object exists nearby; the sensor device 408 may further include a light sensor, Acceleration sensors, temperature sensors, etc.
  • the audio device 409 is used for inputting or outputting an audio signal.
  • the audio device 409 may include a microphone for receiving an external audio signal.
  • the power supply device 410 is configured to provide power for each of the above devices / circuits / modules.
  • the power supply device 410 may include a power management system, and one or more power supplies.
  • the image data is written into the memory 403 through the bus 401 through the input device 405.
  • the image data is data in the RGB color space. Parameters such as the hue adjustment value, the saturation adjustment value, and the brightness adjustment value may be input through the input device 405, or may be read from the memory 403.
  • the processor 402 reads the image data in the memory 403 through the bus 401, and reads instructions that can execute the color adjustment method as in all embodiments of the present application, and performs color adjustment on the image data according to the instructions.
  • the color-adjusted image data may be stored in the memory 403 or displayed on the display device 404 in the form of an image.
  • the steps of the method or algorithm described in combination with the disclosure of this application may be implemented in a hardware manner, or may be implemented in a manner that a processor executes software instructions.
  • Software instructions can be composed of corresponding software modules, which can be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, mobile hard disk, CD-ROM, or any other form of storage known in the art Media.
  • An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium.
  • the storage medium may also be an integral part of the processor.
  • the processor and the storage medium may reside in an ASIC.
  • the ASIC may be located in a data receiving device and / or a data transmitting device.
  • the processor and the storage medium may also exist as discrete components in the data receiving device and / or the data transmitting device.
  • Computer-readable media includes computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another.
  • a storage media may be any available media that can be accessed by a general purpose or special purpose computer.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Color Image Communication Systems (AREA)
  • Facsimile Image Signal Circuits (AREA)
  • Image Processing (AREA)

Abstract

本申请实施例公开了一种RGB数据的色彩调整方法及装置,该方法包括:计算色调调整值对应的第一色调区间;根据RGB输入数据和上述第一色调区间确定RGB输出数据对应的第二色调区间;分别利用饱和度调整值和亮度调整值调节RGB输入数据的饱和度和亮度,得到RGB调节数据,并根据上述第二色调区间从上述RGB调节数据中选择RGB输出数据。由于色调调整值、饱和度调整值以及亮度调整值始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,并且整个色彩调整过程都通过加法运算、减法运算、比较运算和乘法运算来实现,从而避免了大量的浮点运算和除法运算,节省了大量LUT或除法器的资源,降低了硬件的功耗。

Description

一种RGB数据的色彩调整方法 技术领域
本申请涉及图像处理领域,尤其涉及RGB数据的色彩调整方法和装置。
背景技术
在图像处理领域,诸如相机影像信号处理(ISP for Camera)﹑显示图像处理(Image Processing for Display)、数位图处理(Digital Image Processing)等相关领域,针对图像的色调(hue)、饱和度(saturation)和亮度(brightness)进行调整是改善画质的常见方法。现有技术中,以HSV/HSL为主的色彩调整方法主要包括:将输入的RGB数据转换到HSV/HSL色彩空间,得到与输入的RGB数据对应的色调、亮度和饱和度;将得到的色调、亮度和饱和度3个参量与色调调整值、亮度调整值和饱和度调整值进行大量的浮点运算,得到经过色彩调整后的色调、亮度和饱和度;再将上述调整后的色调、亮度和饱和度转换到RGB色彩空间;最后显示在电子设备上。
为了实现图像数据在RGB色彩空间和HSV/HSL色彩空间的正变换和逆变换,以及色调、亮度和饱和度与对应调整值的计算,相应的硬件电路需要做大量的浮点运算,尤其是除法运算。除法运算可以通过除法器或LUT(Look Up Table,查找表)来实现,但除法器需要复杂且高精度的定点化简过程,而LUT会占据大量的硬件资源并增大时钟延迟,因此增加了硬件面积并降低了对RGB数据进行色彩调整的速率。
发明内容
本申请的实施例提供一种RGB数据的色彩调整方法,可以用于解决色彩调整过程中用作浮点运算的LUT或除法器导致的硬件较大,功耗较高的问题。
为了更加清楚的描述本申请,下面对三种色彩空间(模式)予以说明:
RGB:一种色彩空间(模式),将红(Red)、绿(Green)、蓝(Blue)三原色的色光以不同的比例相加,以产生多种多样的色光。
HSL:一种色彩空间(模式),其中颜色通过色调H(hue)、饱和度S(Saturation)和亮度(Lightness)3个分量的叠加来表示。
HSV:Hue Saturation Value,与HSL类似的一种色彩空间(模式)。
第一方面,在本申请的实施例中提供一种RGB数据的色彩调整方法,用于调节RGB输入数据的色调、饱和度和亮度。上述调整方法包括:获取RGB输入数据,以及获取对RGB输入数据进行色彩调节所需的色调调整值、饱和度调整值和亮度调整值;计算上述色调调整值对应的第一色调区间;根据RGB输入数据和求得的第一色调区间,确定RGB输出数据对应第二色调区间;利用饱和度调整值调节RGB输入数据的饱和度,以及利用亮度调整值调节RGB输入数据的亮度,以得到RGB调节数据,并根据第二色调区间从RGB调节数据中选择RGB输出数据;显示得到的RGB输出数据。
由于色调调整值、饱和度调整值以及亮度调整值始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,并且整个色彩调整过程都通过加法运算、减法运算、比较运算和乘法运算来实现,从而避免了大量的浮点运算和除法运算,节省了大量LUT或除法器的资源,降低了硬件的功耗。
在一种实施方式中,计算色调调整值对应的第一色调区间包括:将色调调整值H与除数2 N1做除法运算,并得到对应的商Q和余数Rem,其中,除数2 N1为色调的总角度,N1为非负整数。上述计算过程得到的商Q代表色调调整值H对应的第一色调区间,而余数Rem代表色调调整值H对RGB输入数据在调整后的色调区间中的色调值的色调改变量。对色调调整值做除法运算,可以得到色调调整值对应的第一色调区间,以确定色调调整值对RGB输入数据的色调区间的改变量。
在一种实施方式中,当色调调整值大于或等于色调阈值时,则将色调调整值减去色调阈值,否则保持色调调整值不变,上述色调阈值为最大区间数乘以2的整数幂次方。对色调调整值做调整,以使得色调调整值处于合适的色调区间,避免色调调整值所处的色调区间过大,导致计算量增大。
在一种实施方式中,根据RGB输入数据和第一色调区间,确定RGB输出数据对应的第二色调区间的步骤包括:预处理RGB输入数据,以得到RGB参数集;对上述余数和上述RGB参数集中的一个或多个参数做线性计算,以得到备选参数集;根据RGB输入数据和RGB参数集中的参数的大小关系,以及RGB输入数据和上述备选参数集中的参数的大小关系确定RGB输出数据对应的第二色调区间。经过上述计算过程可以确定RGB输出数据对应的第二色调区间,且上述计算过程只涉及简单的加法运算、减法运算、乘法运算和比较运算,通过简单的逻辑计算电路节省大量的硬件资源。
在一种实施方式中,计算上述RGB参数集的步骤包括:计算RGB输入数据的最大值和最小值;计算上述最大值和最小值的差值;以及计算子像素差值,其中子像素差值包括每两个色彩分量的差值的绝对值。由于RGB参数集的计算只涉及非负整数的加减运算,因此节省了大量的硬件资源。
在一种实施方式中,上述备选参数集包括第一参数S1,该第一参数S1的计算表达式为:S1=△RGB·Rem,其中△RGB为上述RGB输入数据的最大值与最小值的差值,Rem为上述余数。计算第一参数S1,为后续的备选参数集提供计算基础。
在一种实施方式中,分别比较RGB输入数据中的一个色彩分量和RGB参数集中的的一个参数的大小关系,以及RGB输入数据中的一个色彩分量和上述备选参数集中的一个参数的大小关系,根据上述大小关系,从上述备选参数集中选取一个参数作为饱和度系数。通过比较上述参数以求得饱和度系数,作为后续亮度调节和饱和度调节的计算参数。
在一种实施方式中,根据上述大小关系计算色调区间索引值,该色调区间索引值为上述商与色调常数的和,其中色调常数通过上述大小关系确定。通过上述大小关系求得色调区间索引值,作为后续选择RGB输出数据的依据。
在一种实施方式中,上述RGB调节数据包括第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,其中:
p 1=(2 n1·RGB max-△RGB·S)·2 n2·V;
p 2=(2 n3·V-S·Sx)·2 n4·V;
p 3=[RGB min·S·2 n5+S·Sx-2 n6·RGB max·(Sat-128)]·2 n7·V(当S≥128);
p 3=[RGB min·S·2 n5+S·Sx+2 n6·RGB max·(128-Sat)]·2 n7·V(当S<128);
其中,n1~n7为整数,RGB max为上述最大值,△RGB为上述最大值与上述最小值的差值,S为上述饱和度调整值,V为上述亮度调整值,Sx为上述饱和度系数。通过上述过程求得第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,作为RGB输出数据的备选参数,且RGB调节数据的计算过程只包括加法运算、减法运算、比较运算和能够通过移位实现的乘法运算,大量节省了硬件资源,降低了功耗。
在一种实施方式中,根据上述色调区间索引值选择上述RGB调节数据中的3个参数作为RGB输出数据。以上述色调区间索引值选择RGB输出数据,以得到处于正确色调区间的RGB输出数据。
在一种实施方式中,当色调区间索引值大于或等于最大色调区间数时,则色调区间索引值减去最大色调区间数;当色调区间索引值小于最大色调区间数时,则保持色调区间索引值不变。将色调区间索引值调整到合适的值域范围,以减少不必要的计算,节省硬件资源。
第二方面,在本申请的实施例中提供一种RGB数据的色彩调整装置,用于调节RGB输入数据的色调、饱和度和亮度。上述色彩调整装置包括获取模块,用于获取RGB输入数据,以及获取对RGB输入数据进行色彩调节所需的色调调整值、饱和度调整值和亮度调整值;第一计算模块,用于计算色调调整值对应的第一色调区间;第二计算模块,用于根据RGB输入数据和求得的第一色调区间,确定RGB输出数据对应的第二色调区间;调节模块,用于利用饱和度调整值调节RGB输入数据的饱和度,以及利用亮度调整值调节RGB输入数据的亮度,以得到RGB调节数据,并根据求得的第二色调区间从RGB调节数据中选择RGB输出数据;显示模块,用于显示得到的RGB输出数据;
由于色调调整值、饱和度调整值以及亮度调整值始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,并且整个色彩调整过程都通过加法运算、减法运算、比较运算和乘法运算来实现,从而避免了大量的浮点运算和除法运算,节省了大量LUT或除法器的资源,降低了硬件的功耗。
在一种可能的实施方式中,上述第一计算模块320将色调调整值与除数2 N1做除法运算,并得到对应的商Q和余数Rem,其中,除数2 N1为色调的总角度,N1为非负整数。上述计算过程得到的商Q代表色调调整对应的第一色调区间,而余数代表色调调整值对RGB输入数据在调整后的色调区间中的色调值的色调改变量。对色调调整值做除法运算,可以得到色调调整值对应的第一色调区间,以确定色调调整值对RGB输入数据的色调区间的改变量。
在一种可能的实施方式中,当色调调整值大于或等于色调阈值时,上述第一计算模块还用于则将色调调整值减去色调阈值,否则保持色调调整值不变,上述色调阈值为最大色调区间数乘以2的整数幂次方。对色调调整值做调整,以使得色调调整值处于合适的色调区间,避免色调调整值所处的色调区间过大,导致计算量增大。
在一种可能的实施方式中,上述第二计算模块用于预处理RGB输入数据,以得到RGB参数集;对上述余数Rem和上述RGB参数集中的一个或多个参数做线性计算,以得到备选参数集;根据RGB输入数据和RGB参数集中的参数的大小关系,以及RGB输入数据和上述备选参数集中的参数的大小关系确定RGB输出数据对应的第二色调区间。经过上述计算过程可以确定RGB输出数据对应的第二色调区间,且上述计算过程只涉及简单的加法运算、减法运算、乘法运算和比较运算,通过简单的逻辑计算电路节省大量的硬件资源。
在一种可能的实施方式中,上述第二计算模块用于计算RGB输入数据的最大值和最小值;计算上述最大值和最小值的差值;以及计算子像素差值,其中子像素差值包括每两个色彩分量的差值的绝对值。由于RGB参数集的计算只涉及非负整数的加减运算,因此节省了大量的硬件资源。
在一种可能的实施方式中,上述第二计算模块计算备选参数集,其中备选参数集包括第一参数S1,所述第一参数S1的计算表达式为:S1=△RGB·Rem;其中,△RGB为所述RGB输入数据的最大值与最小值的差值,Rem为所述余数。计算第一参数S1,为后续的备选参数集提供计算基础。
在一种可能的实施方式中,分别比较RGB输入数据中的一个色彩分量和RGB参数集中的的一个参数的大小关系,以及RGB输入数据中的一个色彩分量和上述备选参数集中的一个参数的大小关系。上述第二计算模块根据上述大小关系,从备选参数集中选取一个参数作为饱和度系数。通过比较上述参数以求得饱和度系数,作为后续亮度调节和饱和度调节的计算参数。
在一种可能的实施方式中,上述第二计算模块计算色调区间索引值,该色调区间索引值为商与色调常数的和,其中色调常数通过上述大小关系确定。通过上述大小关系求得色调区间索引值,作为后续选择RGB输出数据的依据。
在一种可能的实施方式中,上述调节模块计算RGB调节数据,该RGB调节数据包括第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,其中:
p1=(2 n1·RGB max-△RGB·S)·2 n2·V;
p2=(2 n3·V-S·Sx)·2 n4·V;
p 3=[RGB min·S·2 n5+S·Sx-2 n6·RGB max·(Sat-128)]·2 n7·V(当S≥128);
p 3=[RGB min·S·2 n5+S·Sx+2 n6·RGB max·(128-Sat)]·2 n7·V(当S<128);
其中,n1~n7为整数,RGB max为最大值,△RGB为最大值与最小值的差值,S为饱和度调整值Sat,V为亮度调整值V,Sx为饱和度系数。通过上述过程求得第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,作为RGB输出数据的备选参数,且RGB调节数据的计算过程只包括加法运算、减法运算、比较运算和能够通过移位实现的乘法运算,大量节省了硬件资源,降低了功耗。
在一种可能的实施方式中,上述调节模块340将色调区间索引值Indx作为RGB调节数据的索引值,选择其中的第二p 1、第三p 2、第四p 3和第五RGB max中的3个参数作为RGB输出数据的3个色彩分量R、G和B的值。以上述色调区间索引值选择RGB输出数据,以得到处于正确色调区间的RGB输出数据。
在一种可能的实施方式中,当色调区间索引值大于或等于最大色调区间数时,上 述调节模块使用色调区间索引值减去最大色调区间数;当色调区间索引值小于最大色调区间数时,上述调节模块保持色调区间索引值不变。将色调区间索引值调整到合适的值域范围,以减少不必要的计算,节省硬件资源。
第三方面,在本申请的实施例中提供一种RGB数据的色彩调整装置,用于调节RGB输入数据的色调、饱和度和亮度。上述色彩调整装置包括用于存储计算机指令的存储器,以及处理器。该处理器与上述存储器通信耦合,其中计算机指令配置该处理器,并用于执行第一方面中及其可能的实施方式中的色彩调整方法。
由于色调调整值、饱和度调整值以及亮度调整值始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,并且整个色彩调整过程都通过加法运算、减法运算、比较运算和乘法运算来实现,从而避免了大量的浮点运算和除法运算,节省了大量LUT或除法器的资源,降低了硬件的功耗。
第四方面,在本申请的实施例中提供一种计算机可读存储介质,其特征在于,该计算机可读存储介质存储计算机程序,被一个或多个处理器读取并执行时实现第一方面中及其可能的实施方式中的色彩调整方法。
由于色调调整值、饱和度调整值以及亮度调整值始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,并且整个色彩调整过程都通过加法运算、减法运算、比较运算和乘法运算来实现,从而避免了大量的浮点运算和除法运算,节省了大量LUT或除法器的资源,降低了硬件的功耗。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍。
图1为本发明实施例中一种色彩调整方法的流程示意图。
图2为本发明实施例中一种色彩调整方法的更为具体的数据流示意图。
图3为本发明实施例中一种色彩调整装置的结构示意图。
图4为本发明实施例中一种用于色彩调整的电子设备。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚地描述。
在HSV/HSL色彩空间中,像素数据通过色调、饱和度以及亮度来表示。其中,色调代表颜色的基本属性,即颜色的名称,其取值范围为0~360°。例如,色调为0°或360°时表示的颜色为红色,色调为120°时表示的颜色为绿色,而色调为240°时表示的颜色为蓝色。饱和度代表颜色的纯度,其取值范围为0~100%,饱和度越高则灰色越少,颜色越鲜艳。亮度的取值范围为0~100%,代表颜色的明暗,亮度越高则颜色越接近白色。例如,当色调为0°,亮度为100%时表示的颜色是白色,而亮度为50%时表示的颜色是灰色。为了方便,根据本申请的所有实施例均采用HSV色彩空间。需要 注意的是,根据本申请的所有实施例也可以采用HSL色彩空间。
如图1所示的是本申请实施例提供的一种色彩调整方法的流程示意图,该方法可以根据输入的色调调整值H、饱和度调整值S以及亮度调整值V,在RGB色彩空间中对RGB输入数据进行色调调整、饱和度调整以及亮度调整,并输出经过色彩调整的RGB输出数据。RGB输入数据和RGB输出数据均在RGB色彩空间表示,即RGB色彩空间中三个色彩分量R(Red,红)、G(Green,绿)和B(Blue,蓝)的值。
如图1所示,在步骤110中,获取RGB输入数据,以及获取对RGB输入数据进行色彩调节所需的色调调整值、饱和度调整值和亮度调整值;在步骤120中,计算上述色调调整值对应的第一色调区间;在步骤130中,根据RGB输入数据和求得的第一色调区间,确定RGB输出数据对应第二色调区间;在步骤140中,利用饱和度调整值调节RGB输入数据的饱和度,以及利用亮度调整值调节RGB输入数据的亮度,以得到RGB调节数据,并根据步骤130中求得的第二色调区间从RGB调节数据中选择RGB输出数据;最后,在步骤150中,显示得到的RGB输出数据。
一方面,在上述色彩调整过程中,色调调整值H、饱和度调整值S以及亮度调整值V始终在RGB色彩空间对RGB输入数据进行色彩调整,无需将RGB输入数据先变换到HSV色彩空间,再进行逆变换,从而避免了大量的浮点运算和除法运算。另一方面,色彩调整过程可以仅仅通过对色彩调整值、RGB输入数据和中间参数进行加法运算、减法运算、比较运算和乘法运算来实现,其中参与运算的数据均为非负整数,且乘法运算均为与2 n的乘法运算,其中n为整数。因此,乘法运算可以通过移位或其他简单的计算方法实现。相对于现有技术,根据本申请实施例的色彩调整方法通过对非负整数的加法运算、减法运算、比较运算和乘法运算实现对RGB输入数据的色彩调整,避免了现有技术中大量的LUT或除法器的使用,节省硬件资源,降低了硬件的功耗。
如图2所示的是本申请实施例提供的一种色彩调整方法的更为具体的数据流示意图。
首先,对输入的色调调整值H进行计算,以得到色调调整值H对应的第一色调区间。在HSV色彩空间中,总角度为360°的色调通常被最大色调区间数划分为多个色调区间,其中最大色调区间数为正整数。例如,当最大色调区间数为6时,则每60°确定一个色调区间。当最大色调区间数越大,则色调区间被划分为更为精细的色调区间,因此色调调整的精度增大,其计算复杂程度也随之增大。在本申请实施例中,色调的总角度为2 N1°,其中2 N1°被最大色调区间数M划分,被划分后的每个色调区间的角度为(2 N1/M)°,例如,第0个色调区间的角度为0~(2 N1/M)°,第1个色调区间的角度为(2 N1/M)°~(2.2 N1/M)°,以此类推。
具体来说,计算色调调整值对应的第一色调区间包括:将色调调整值H与除数2 N1做除法运算210,并得到对应的商Q和余数Rem,其中,除数2 N1为色调的总角度,N1为非负整数。需要注意的是,本申请中做对色调调整值H除法计算不是进行除法运算210 的唯一实现方法,可以通过其他方法以实现商Q和余数Rem的计算,以利用较小的硬件资源实现除法运算,具体方法在下文会以详细的方式列出。上述计算过程得到的商Q代表色调调整值H对应的第一色调区间,即商Q可以反映色调调整值H对RGB输入数据所处的色调区间的改变,或者说增减多少色调区间,即对颜色属性的改变;而余数Rem代表色调调整值H对RGB输入数据在调整后的色调区间中的色调值的色调改变量,即余数Rem可以反映色调调整值H在调整后的色调区间中对RGB输入数据的色调值具体的改变量。经过上述除法运算得到的商Q的值域为0到最大色调区间数M,而余数Rem小于等于2 N1-1。
可选的,当色调调整值H较大时,可能超过色调阈值H thd,因此在对色调调整值H做除法运算(210)之前,需要先对其进行值域处理(211),使得色调调整值H处于合适的色调区间,避免色调调整值H过大带来的计算量的增大。具体来说,当色调调整值H大于或等于色调阈值H thd时,则将色调调整值H减去色调阈值H thd,否则保持色调调整值H不变,其中求取色调阈值H thd的表达式为:
H thd=M·2 N1
其中N1为整数,M为最大区间数。由于上述除法运算中的除数为2 N1,因此可以通过较为简单的方法实现除法运算(210)以求得商Q和余数Rem,避免采用除法器或者LUT来实现除法运算,从而减小了除法运算(210)的硬件资源所占用的面积,节省了功耗。例如,将色调调整值H与n·2 N1逐一进行比较,其中n为0、1、2…。当色调调整值H满足n·2 N1≤H<(n+1)·2 N1时,确定商Q=n的值,并计算Rem=H-n·2 N1以确定余数Rem的值。
由于色调调整值H为非负整数,因此求得的商Q和余数Rem均为非负整数。将色调调整值H做如上所述的除法运算(210),可以确定色调调整值H对应的第一色调区间。此外,在色调调整值H过大时进行值域处理(211),可以调整色调调整值H对应的第一色调区间,使其处在合适的色调区间中。
在得到上述色调区间调整量后,根据RGB输入数据和第一色调区间,确定RGB输出数据对应的第二色调区间。其中,上述根据RGB输入数据和第一色调区间,确定RGB输出数据对应的第二色调区间的步骤包括:预处理(220)RGB输入数据,以得到RGB参数集;对上述余数Rem和上述RGB参数集中的一个或多个参数做线性计算(230),以得到备选参数集;根据RGB输入数据和RGB参数集中的参数的大小关系,以及RGB输入数据和上述备选参数集中的参数的大小关系确定RGB输出数据对应的第二色调区间。
具体来说,预处理(220)RGB输入数据,以得到RGB参数集的步骤包括:
计算RGB输入数据的最大值RGB max和最小值RGB min
计算上述最大值RGB max和最小值RGB min的差值△RGB,即,△RGB=RGB max-RGB min
以及计算子像素(sub-pixel)差值,其中子像素差值包括每两个色彩分量的差值的 绝对值,即红色分量R和蓝色分量B的差值的绝对值RB abs、红色分量R和绿色分量G的差值的绝对值RG abs、以及绿色分量G和蓝色分量B的差值的绝对值GB abs
因此,上述RGB参数集包括RGB max、RGB min、△RGB、RB abs、RG abs以及GB abs。由于RGB输入数据均为非负整数,因此求得的RGB参数集均为非负整数。
对上述色调调整值H做除法运算(210)后得到的余数Rem,以及上述RGB参数集中的一个或多个参数做线性计算(230),得到备选参数集。其中,备选参数集包括对上述余数Rem和上述RGB参数集中的一个或多个参数做线性变换的结果,即参数S 1~S 11。备选参数集中的参数S 1~S 11的计算方法由下表中的表达式确定:
S 1=△RGB·Rem
S 2=S 1+2 n·GB abs
S 3=S 1+2 n·RG abs
S 4=S 1+2 n·RB abs
S 5=S 2-2 n·△RGB
S 6=S 3-2 n·△RGB
S 7=S 4-2 n·△RGB
S 8=S 1+2 n·△RGB-2 n·GB abs
S 9=△RGB·Rem-2 n·GB abs
S 10=△RGB·Rem-2 n·RG abs
S 11=△RGB·Rem-2 n·RB abs
需要注意的是,本申请中备选参数集中的参数不限定为以上11个参数,也不限定为以上参数的表达形式。备选参数集可以包括其他的一个或多个参数,但这些参数中至少包括参数第一参数S 1,或者包含通过对第一参数参数S 1进行线性计算(230)所得到的一个或多个参数。在上述备选参数集中的参数的表达式中,n均为整数,其中每个参数的表达式中的n为相互独立的取值。在计算参数S 1~S 11时,为了在做加法运算或减法运算时将加号或减号两边的变量对齐到同一位宽并保证计算的结果为非负整数,将△RGB、RB abs、RG abs以及GB abs与2的整数幂次方相乘,例如在计算当S 1与GB abs的位宽不同时,将GB abs与2 n相乘以对齐S 1与GB abs。具体来说,将△RGB、RB abs、RG abs以及GB abs与2 n相乘可以通过将上述数据进行一次或多次向左位移或向右位移来实现。
在完成备选参数集的计算后,根据RGB输入数据和RGB参数集中的参数的大小关系,以及RGB输入数据和上述备选参数集中的参数的大小关系确定RGB输出数据对应的第二色调区间。具体来说,分别比较(240)RGB输入数据中的一个色彩分量和RGB参数集中的的一个参数的大小关系,以及RGB输入数据中的一个色彩分量和上述备选参数集中的一个参数的大小关系,并根据上述大小关系从备选参数集中选择一个参数作为饱和度系数Sx,同时根据上述大小关系和上述除法运算(210)得到的商Q计算色调区间索引值Indx。
具体来说,上述比较(240)的过程包括至少一次第一类比较和至少一次第二类比较。第一类比较包括RGB输入数据中三个色彩分量R、G和B之间的大小比较,RGB输入数据与最大值RGB max的比较,以及RGB输入数据与第一阈值thd 1和第二阈值thd 2的比较,或者同时满足上述多个比较的表达式。其中,计算第一阈值thd 1和第二阈值thd 2的表达式分别为:
thd 1=2 n·△RGB+B;
thd 2=2 n·△RGB+R。
其中n均为整数,且thd 1和thd 2中的n为相互独立的取值,B为蓝色色彩分量,R为红色色彩分量。将差值△RGB与2的整数幂次方相乘,可以使上述表达式中的两个加数的位宽对齐。
第二类比较包括上述参数S 2、S 3、S 4、RB abs、RG abs和GB abs中的参数与S 1和△RGB·2 n+S 1之间的比较。根据上述两次比较的结果,确定饱和度系数Sx和色调区间索引值Indx的值。具体来说,根据上述大小关系从备选参数集中选取参数S 1~S 11中的一个参数作为饱和度索引值Sx,同时根据上述大小关系计算色调区间索引值Indx。该色调区间索引值Indx可以表示为Indx=Q+k,其中k为色调常数,其值域为非负整数,Q为步骤120中求得的商。通过上述大小关系,可以确定k的值,从而计算色调区间索引值Indx。
例如,在第一类比较中,判断色彩分量R是否为RGB输入数据的最大值,同时判断色彩分量G的值是否大于等于色彩分量B的值,即G≥B;在第二类比较中,分别判断△RGB·2 n+S 1的值与RB abs、S 5的大小关系。这里列举一种比较结果的情况。在第一类比较中,当R=RGB max,且R≥B;同时,在第二类比较中,当△RGB·2 n+S 1=RB abs时,色调区间索引值Indx=Q+1,饱和度系数Sx=S 1;当△RGB·2 n+S 1≤S 5时,色调区间索引值Indx=Q+1,饱和度系数Sx=S 5-△RGB·2 n+S 1。其中,n为整数,以对齐上述表达式中的两个加数的位宽。如果上述两种第二类比较的情况均不满足,则色调区间索引值Indx=Q,饱和度系数Sx=S 5。对于第一类比较中的其他情况,则通过其他方式的第二类比较来确定饱和度系数Sx和色调区间索引值Indx的值。
由于RGB输入数据与色调调整值H为不同的物理量,因此通过上述比较(240)并计算色调区间索引值Indx,可以间接地判断RGB输出数据对应的色调区间。具体来说,除法运算(210)所求得的商Q可以反映色调调整值H在RGB色彩空间对于RGB输入数据的色调区间改变量,而除法运算(210)所求得的余数Rem可以反映色调调整值H在该色调区间对RGB输入数据的色调的调整量。通过上述大小关系的比较,可以确定RGB输出数据对应的色调区间,即色调区间索引值Indx可以反映色调调整值H作用于RGB输入数据之后的色调区间,即RGB输出数据对应的色调区间。
在求得饱和度系数和色调区间索引值后,利用饱和度调整值S调节上述RGB输入数据的饱和度,同时利用亮度调整值V调节上述RGB输入数据的亮度,以得到RGB调 节数据,并根据上述RGB输出数据对应的第二色调区间从RGB调节数据中选择RGB输出数据。可选的,在进行调节(260)之前,可以对色调区间索引值Indx进行值域处理。具体来说,当色调区间索引值Indx大于或等于最大色调区间数时,则色调区间索引值Indx减去最大色调区间数;当色调区间索引值Indx小于最大色调区间数时,则保持色调区间索引值Indx不变。
在上述调节(260)步骤中,利用饱和度调整值S调节上述RGB输入数据的饱和度,同时利用亮度调整值V调节上述RGB输入数据的亮度包括:计算RGB调节数据。其中,该RGB调节数据包括第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max。对于RGB调节数据中的第二参数p 1和第三参数p 2,其计算式由下列的表达式确定:
p 1=(2 n·RGB max-△RGB·S)·2 n·V;
p 2=(2 n·V-S·Sx)·2 n·V;
上述第二参数p 1和第三参数p 2的表达式中,n均为整数,其中每个参数的表达式中的n为相互独立的取值。在计算第二参数p 1和第三参数p 2时,为了在做加法运算或减法运算时将加号或减号两边的变量对齐到同一位宽,将RGB max和V与2 n相乘。在上述计算p 1的表达式中,最大值RGB max减去饱和度调整值S与差值△RGB的积,作为饱和度调整值S对RGB输入数据的饱和度调节;得到的结果与亮度调整值V相乘,作为亮度调整值V对RGB输入数据的亮度调节。同理,在上述计算p 2的表达式中,饱和度调整值S与饱和度系数Sx相乘,作为饱和度调整值S对RGB输入数据的饱和度调节;亮度调整值V减去得到的结果再与亮度调整值V相乘,作为亮度调整值V对RGB输入数据的亮度调节。
对于RGB调节数据中的第四参数p 3,需要首先计算中间参数p 31、p 32和p 33,对于参数p 31和p 32,其计算式由下列的表达式确定:
P 31=RGB min·S·2 n
P 32=S·Sx。
其中n为整数。在上述计算p 31和p 32的表达式中,饱和度调整值S分别与最小值RGB min和饱和度系数Sx相乘,作为饱和度调整值S对RGB输入数据的饱和度调节。
对于参数p 33的计算,为了使参数p 33的计算结果为正数,需要判断饱和度调整值S是否超过饱和度标准值,该饱和度标准值可以为2 n,其中n为正整数,例如n=7。以n=7为例说明参数p 33的计算过程,但需要注意的是,根据本申请实施例的饱和度标准值还可以为其他满足2 n的值,例如32、64等。当饱和度调整值S大于或等于饱和度标准值,即S≥128,即饱和度调整值起到增强饱和度的作用,因此p 33=Sat-128,否则当S<128时,饱和度调整值起到衰减饱和度的作用,此时p 33=128-Sat。
因此,当参数Sat≥128,则:
p 3=[p 31+p 32-(2 n1·RGB max·p 33)]·2 n2·V;
当参数Sat<128,则:
p 3=[p 31+p 32+(2 n1·RGB max·p 33)]·2 n2·V。
上述参数p 3的表达式中,n 1和n 2为相互独立的整数。在计算参数p 3时,为了在做加法运算或减法运算时将加号或减号两边的变量对齐到同一位宽并保证计算的结果为非负整数,将RGB max·p 33以及V与2的整数幂次方相乘。具体来说,将RGB max·p 33以及V与2的整数幂次方相乘可以通过将上述数据进行一次或多次向左位移或向右位移来实现。
在完成RGB调节数据的计算后,将色调区间索引值Indx作为RGB调节数据的索引值,选择其中的第二p 1、第三p 2、第四p 3和第五RGB max中的3个参数作为RGB输出数据的3个色彩分量R、G和B的值。例如,当色调区间索引值Indx=0,则RGB输出数据中的R=RGB max、G=p 3、B=p 1;当色调区间索引值Indx=1,则RGB输出数据中的R=p 2、G=RGB max、B=p 1。需要注意的是,本申请不对色调区间索引值Indx和选择RGB输出数据的方式做任何限定。根据不同的色调区间索引值Indx,被选择的RGB输出数据可能是参数p 1、p 2、p 3和RGB max中的任意3个。
在完成调节(260)后,将得到的RGB输出数据在显示设备上进行显示(270),以获得对RGB输入数据的色彩调整效果。
上述内容详细阐述了本申请实施例的方法,为了便于更好地实施本申请实施例的上述方案,本申请实施例还提供了相应的色彩调整装置。
如图3所示的是本申请实施例提供的一种RGB数据的色彩调整装置300的结构示意图。该色彩调整装置300包括:
获取模块310,用于获取RGB输入数据,以及获取对RGB输入数据进行色彩调节所需的色调调整值、饱和度调整值和亮度调整值;
第一计算模块320,用于计算色调调整值对应的第一色调区间;
第二计算模块330,用于根据RGB输入数据和求得的第一色调区间,确定RGB输出数据对应的第二色调区间;
调节模块340,用于利用饱和度调整值调节RGB输入数据的饱和度,以及利用亮度调整值调节RGB输入数据的亮度,以得到RGB调节数据,并根据求得的第二色调区间从RGB调节数据中选择RGB输出数据;
显示模块350,用于显示得到的RGB输出数据;
在一种可能的实施方式中,上述第一计算模块320将色调调整值H与除数2 N1做除法运算210,并得到对应的商Q和余数Rem,其中,除数2 N1为色调的总角度,N1为非负整数。上述计算过程得到的商Q代表色调调整值H对应的第一色调区间,而余数Rem代表色调调整值H对RGB输入数据在调整后的色调区间中的色调值的色调改变量。
在一种可能的实施方式中,当色调调整值H大于或等于色调阈值H thd时,上述第一计算模块320还用于则将色调调整值H减去色调阈值H thd,否则保持色调调整值H不变,上述色调阈值为最大色调区间数乘以2的整数幂次方。
在一种可能的实施方式中,上述第二计算模块330用于预处理RGB输入数据,以得到RGB参数集;对上述余数Rem和上述RGB参数集中的一个或多个参数做线性计算,以得到备选参数集;根据RGB输入数据和RGB参数集中的参数的大小关系,以及RGB输入数据和上述备选参数集中的参数的大小关系确定RGB输出数据对应的第二色调区间。
在一种可能的实施方式中,上述第二计算模块330用于计算RGB输入数据的最大值RGB max和最小值RGB min;计算上述最大值RGB max和最小值RGB min的差值△RGB,即,△RGB=RGB max-RGB min;以及计算子像素差值,其中子像素差值包括每两个色彩分量的差值的绝对值,
在一种可能的实施方式中,上述第二计算模块330计算备选参数集,其中备选参数集包括第一参数S1,所述第一参数S1的计算表达式为:S1=△RGB·Rem;其中,△RGB为所述RGB输入数据的最大值与最小值的差值,Rem为所述余数。
在一种可能的实施方式中,分别比较RGB输入数据中的一个色彩分量和RGB参数集中的的一个参数的大小关系,以及RGB输入数据中的一个色彩分量和上述备选参数集中的一个参数的大小关系。
在一种可能的实施方式中,上述第二计算模块330计算色调区间索引值,该色调区间索引值为商Q与色调常数的和,其中色调常数通过上述大小关系确定。
在一种可能的实施方式中,上述第二计算模块330根据上述大小关系,从备选参数集中选取一个参数作为饱和度系数。
在一种可能的实施方式中,当色调区间索引值Indx大于或等于最大色调区间数时,上述调节模块340使用色调区间索引值Indx减去最大色调区间数;当色调区间索引值Indx小于最大色调区间数时,上述调节模块340保持色调区间索引值Indx不变。
在一种可能的实施方式中,上述调节模块340计算RGB调节数据,该RGB调节数据包括第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,其中:
p 1=(2 n1·RGB max-△RGB·S)·2 n2·V;
p 2=(2 n3·V-S·Sx)·2 n4·V;
p 3=[RGB min·S·2 n5+S·Sx-2 n6·RGB max·(Sat-128)]·2 n7·V(当S≥128);
p 3=[RGB min·S·2 n5+S·Sx+2 n6·RGB max·(128-Sat)]·2 n7·V(当S<128);
其中,n1~n7为整数,RGB max为最大值,△RGB为最大值与最小值的差值,S为饱和度调整值Sat,V为亮度调整值V,Sx为饱和度系数。
在一种可能的实施方式中,上述调节模块340将色调区间索引值Indx作为RGB调节数据的索引值,选择其中的第二p 1、第三p 2、第四p 3和第五RGB max中的3个参数作为RGB输出数据的3个色彩分量R、G和B的值。
如图4所示的电子设备400为一种可以执行上述实施例中的色彩调整方法的设备。电子设备400包括总线401、处理器402、存储器403、显示设备404,可选的,电子设备400还可以包括输入设备405、射频电路406、通信设备407、传感器设备408、 音频设备409和电源设备410。电子设备400可以为一种通讯设备,例如移动电话、便携式电脑等。处理器402和存储器403之间互相通信耦合,并存在高速数据传输连接,该高速数据传输连接可以通过分别通信连接处理器402和存储器403的总线401来实现,总线401可以为AXI(Advanced eXtensible Interface)总线协议,或其他总线协议。处理器402可以是中央处理器(Central Processing Unit,CPU),用于运行存储在存储器403中的软件程序和/或指令,以执行电子设备400的各种功能,上述CPU可以是基于X86架构、基于ARM架构和基于cortex-A架构的CPU。处理器402还可以是应用处理器(Application Processor,AP)和/或图像信号处理器(Image Signal Processor,ISP)。存储器403可以包括易失性存储器,例如随机存取存储器(Random Access Memory,RAM),也可以包括非易失性存储器,例如闪存(flash memory),硬盘或固态硬盘(Solid-State Drive,SSD),也可以是上述种类的存储器的组合。显示设备404用于输出可视的文本、图形、视频及其任意的组合,显示设备404可以是LCD(Liquid Crystal Display,液晶显示器)或LPD(Lighting Power Density,发光聚合物显示器)。用户可以通过输入设备405输入命令和信息至电子设备400中,例如待调整色彩的图像数据或视频流数据,其中输入设备405可以是鼠标、键盘、扫描仪或摄像头等。射频电路406用于接收和发送电磁波,将电信号变换成电磁波,或是将电磁波变换成电信号,并且通过电磁波与通信网络或其他通信设备进行通信。通信模块407用于处理通信数据,例如射频电路406接收的电磁波并变换成的电信号所表示的通信数据。传感器设备408包括一个或多个传感器,用于接收外部环境激励并提供物理响应,例如,传感器设备408可以包括距离传感器,被配置为检测附近是否有物体存在;传感器设备408还可以包括光传感器、加速度传感器、温度传感器等。音频设备409用于输入或输出音频信号,例如,音频设备409可以包括麦克风,用于接收外部音频信号。电源设备410用于为上述各个设备/电路/模块提供电力,电源设备410可以包括电源管理系统,以及一个或多个电源。
在一种实施方式中,图像数据通过输入设备405经过总线401被写入存储器403中,在存储器403中,图像数据为RGB色彩空间的数据。色调调整值、饱和度调整值和亮度调整值等参数可以通过输入设备405输入,也可以从存储器403中读取。处理器402通过总线401读取存储器403中的图像数据,以及读取可以执行如本申请所有实施例中的色彩调整方法的指令,并根据该指令对图像数据进行色彩调整。经过色彩调整后的图像数据可以保存于存储器403中,或者以图像的形式显示在显示设备404上。
结合本申请公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于RAM存储器、闪存、ROM存储器、EPROM存储器、EEPROM存储器、寄存器、硬盘、移动硬盘、CD-ROM或者本领域熟知的任何其它形式的存储介质中。一 种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。另外,该ASIC可以位于数据接收设备和/或数据发送设备中。当然,处理器和存储介质也可以作为分立组件存在于数据接收设备和/或数据发送设备中。
本领域技术人员应该可以意识到,在上述一个或多个示例中,本申请所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。计算机可读介质包括计算机存储介质和通信介质,其中通信介质包括便于从一个地方向另一个地方传送计算机程序的任何介质。存储介质可以是通用或专用计算机能够存取的任何可用介质。
以上所述的具体实施方式,对本申请的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本申请的具体实施方式而已,并不用于限定本申请的保护范围,凡在本申请的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本申请的保护范围之内。

Claims (24)

  1. 一种RGB数据的色彩调整方法,包括:
    获取RGB输入数据、色调调整值、饱和度调整值和亮度调整值;
    计算所述色调调整值对应的第一色调区间;
    根据所述RGB输入数据和所述第一色调区间确定RGB输出数据对应的第二色调区间;
    分别利用所述饱和度调整值调节所述RGB输入数据的饱和度,以及利用所述亮度调整值调节所述RGB输入数据的亮度,以得到RGB调节数据,并根据所述第二色调区间从所述RGB调节数据中选择所述RGB输出数据;
    显示所述RGB输出数据。
  2. 如权利要求1所述的色彩调整方法,其特征在于,所述计算所述色调调整值对应的第一色调区间的步骤包括:
    计算所述色调调整值与除数相除的商和余数,其中所述商代表所述色调调整值对应的第一色调区间,所述余数代表所述色调调整值对所述RGB输入数据在调整后的色调区间的色调改变量,所述除数为2 n,其中n为整数。
  3. 如权利要求1或2所述的色彩调整方法,其特征在于,所述计算所述色调调整值对应的第一色调区间的步骤之前,还包括:
    当所述色调调整值大于或等于色调阈值,则将所述色调调整值减去所述色调阈值,否则保持所述色调调整值不变,所述色调阈值为最大色调区间数乘以2的整数幂次方。
  4. 如权利要求2或3所述的色彩调整方法,其特征在于,所述根据所述RGB输入数据和所述第一色调区间确定RGB输出数据对应的第二色调区间的步骤包括:
    根据所述RGB输入数据计算RGB参数集;
    对所述余数和所述RGB参数集中的一个或多个参数做线性计算,得到备选参数集;
    根据所述RGB输入数据与所述RGB参数集,以及所述RGB输入数据与所述备选参数集中的参数的大小关系确定所述RGB输出数据对应的第二色调区间。
  5. 如权利要求4所述的色彩调整方法,其特征在于,所述根据所述RGB输入数据计算RGB参数集的步骤包括:
    计算所述RGB输入数据中的最大值和最小值;
    计算所述最大值与所述最小值的差值;
    计算子像素差值,所述子像素差值为所述RGB输入数据中每两个色彩分量的差值的绝对值。
  6. 如权利要求4或5所述的色彩调整方法,其特征在于,所述备选参数集包括第一参数S1,所述第一参数S1的计算表达式为:
    S1=△RGB·Rem;
    其中,△RGB为所述RGB输入数据的最大值与最小值的差值,Rem为所述余数。
  7. 如权利要求4至6中任意一项所述的色彩调整方法,其特征在于,所述根据所述RGB输入数据与所述RGB参数集,以及所述RGB输入数据与所述备选参数集中的参数的大小关系确定所述RGB输出数据对应的第二色调区间的步骤包括:
    分别比较所述RGB输入数据中的一个色彩分量与所述RGB参数集中的一个参数,以及比较所述RGB输入数据中的一个色彩分量与所述备选参数集中的一个参数的大小关系;
    根据所述大小关系,从所述备选参数集中选取一个参数作为饱和度系数。
  8. 如权利要求4至7中任意一项所述的色彩调整方法,其特征在于,所述根据所述RGB输入数据和所述第一色调区间确定RGB输出数据对应的第二色调区间的步骤还包括:
    计算色调区间索引值,所述色调区间索引值为所述商与色调常数的和,所述色调常数通过所述大小关系确定。
  9. 如权利要求8所述的色彩调整方法,其特征在于,所述RGB调节数据包括:
    第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,其中:
    p 1=(2 n1·RGB max-△RGB·S)·2 n2·V;
    p 2=(2 n3·V-S·Sx)·2 n4·V;
    p 3=[RGB min·S·2 n5+S·Sx-2 n6·RGB max·(Sat-128)]·2 n7·V(当S≥128);
    p 3=[RGB min·S·2 n5+S·Sx+2 n6·RGB max·(128-Sat)]·2 n7·V(当S<128);
    其中,n1~n7为整数,RGB max为所述最大值,△RGB为所述最大值与所述最小值的差值,S为所述饱和度调整值,V为所述亮度调整值,Sx为所述饱和度系数。
  10. 如权利要求9所述的色彩调整方法,其特征在于,所述根据所述第二色调区间从所述RGB调节数据中选择RGB输出数据的步骤包括:
    根据所述色调区间索引值选择所述RGB调节数据中的3个参数作为所述RGB输出数据。
  11. 如权利要求7至10中任意一项所述的色彩调整方法,其特征在于,所述根据所述第二色调区间从所述RGB调节输入数据中选择所述RGB输出数据的步骤之前,还包括:
    当所述色调区间索引值大于或等于所述最大色调区间数,则将所述色调区间索引值减去所述最大色调区间数,否则保持所述色调区间索引值不变。
  12. 一种RGB数据的色彩调整装置,包括:
    获取模块,所述获取模块获取RGB输入数据、色调调整值、饱和度调整值和亮度调整值;
    第一计算模块,所述第一计算模块计算所述色调调整值对应的第一色调区间;
    第二计算模块,所述第二计算模块根据所述RGB输入数据和所述第一色调区间确定RGB输出数据对应的第二色调区间;
    调节模块,所述调节模块分别利用所述饱和度调整值调节所述RGB输入数据的饱和度,以及利用所述亮度调整值调节所述RGB输入数据的亮度,以得到RGB调节数据,并根据所述第二色调区间从所述RGB调节数据中选择所述RGB输出数据;
    显示模块,所述显示模块显示所述RGB输出数据。
  13. 如权利要求12所述的色彩调整装置,其特征在于,所述第一计算模块计算所述色调调整值对应的第一色调区间包括:
    计算所述色调调整值与除数相除的商和余数,其中所述商代表所述色调调整值对应的第一色调区间,所述余数代表所述色调调整值对所述RGB输入数据在调整后的色调区间的色调改变量,所述除数为2 n,其中n为整数。
  14. 如权利要求12或13所述的色彩调整方法,其特征在于,所述第一计算模块在计算所述色调调整值对应的第一色调区间之前,还用于:
    当所述色调调整值大于或等于色调阈值,则将所述色调调整值减去所述色调阈值,否则保持所述色调调整值不变,所述阈值为最大色调区间数乘以2的整数幂次方。
  15. 如权利要求13或14所述的色彩调整装置,其特征在于,所述第二计算模块根据所述RGB输入数据和所述第一色调区间确定RGB输出数据对应的第二色调区间包括:
    根据所述RGB输入数据计算RGB参数集;
    对所述余数和所述RGB参数集中的一个或多个参数做线性计算,得到备选参数集;
    根据所述RGB输入数据与所述RGB参数集,以及所述RGB输入数据与所述备选参数集中的参数的大小关系确定所述RGB输出数据对应的第二色调区间。
  16. 如权利要求15所述的色彩调整装置,其特征在于,所述第二计算模块根据所述RGB输入数据计算RGB参数集包括:
    计算所述RGB输入数据中的最大值和最小值;
    计算所述最大值与所述最小值的差值;
    计算子像素差值,所述子像素差值为所述RGB输入数据中每两个色彩分量的差值的绝对值。
  17. 如权利要求15或16所述的色彩调整装置,其特征在于,所述备选参数集包括第一参数S1,所述第一参数S1的计算表达式为:
    S1=△RGB·Rem;
    其中,△RGB为所述RGB输入数据的最大值与最小值的差值,Rem为所述余数。
  18. 如权利要求15至17中任意一项所述的色彩调整装置,其特征在于,所述第二计算模块根据所述RGB输入数据与所述RGB参数集,以及所述RGB输入数据与所述备选参数集中的参数的大小关系确定所述RGB输出数据对应的第二色调区间包括:
    分别比较所述RGB输入数据中的一个色彩分量与所述RGB参数集中的一个参数,以及比较所述RGB输入数据中的一个色彩分量与所述备选参数集中的一个参数的大小关系;
    根据所述大小关系,从所述备选参数集中选取一个参数作为饱和度系数。
  19. 如权利要求15至18中任意一项所述的色彩调整装置,其特征在于,第二计算模块还用于:
    计算色调区间索引值,所述色调区间索引值为所述商与色调常数的和,所述色调常数通过所述大小关系确定。
  20. 如权利要求19所述的色彩调整装置,其特征在于,所述RGB调节数据包括:
    第二参数p 1、第三参数p 2、第四参数p 3和第五参数RGB max,其中:
    p 1=(2 n1·RGB max-△RGB·S)·2 n2·V;
    p 2=(2 n3·V-S·Sx)·2 n4·V;
    p 3=[RGB min·S·2 n5+S·Sx-2 n6·RGB max·(Sat-128)]·2 n7·V(当S≥128);
    p 3=[RGB min·S·2 n5+S·Sx+2 n6·RGB max·(128-Sat)]·2 n7·V(当S<128);
    其中,n1~n6为整数,RGB max为所述最大值,△RGB为所述最大值与所述最小值的差值,S为所述饱和度调整值,V为所述亮度调整值,Sx为所述饱和度系数。
  21. 如权利要求20所述的色彩调整装置,其特征在于,所述调节模块根据所述第二色调区间从所述RGB调节数据中选择RGB输出数据包括:
    根据所述色调区间索引值选择所述RGB调节数据中的3个参数作为所述RGB输出数据。
  22. 如权利要求18至21中任意一项所述的色彩调整装置,其特征在于,所述调节模块根据所述第二色调区间从所述RGB调节输入数据中选择所述RGB输出数据之前,还用于:
    当所述色调区间索引值大于或等于所述最大色调区间数,则将所述色调区间索引值减去所述最大色调区间数,否则保持所述色调区间索引值不变。
  23. 一种RGB数据的色彩调整装置,包括:
    存储器,用于存储计算机指令;
    处理器,所述处理器与所述存储器通信耦合,其中所述计算机指令配置所述处理器,并用于执行权利要求1至11中任意一项所述的色彩调整方法。
  24. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储计算机程序,所述计算机程序被一个或多个处理器读取并执行时实现权利要求1至11中任意一项所述的色彩调整方法。
PCT/CN2018/093105 2018-06-27 2018-06-27 一种rgb数据的色彩调整方法 WO2020000255A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/093105 WO2020000255A1 (zh) 2018-06-27 2018-06-27 一种rgb数据的色彩调整方法
CN201880086830.7A CN111615714B (zh) 2018-06-27 2018-06-27 一种rgb数据的色彩调整方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/093105 WO2020000255A1 (zh) 2018-06-27 2018-06-27 一种rgb数据的色彩调整方法

Publications (1)

Publication Number Publication Date
WO2020000255A1 true WO2020000255A1 (zh) 2020-01-02

Family

ID=68985566

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/093105 WO2020000255A1 (zh) 2018-06-27 2018-06-27 一种rgb数据的色彩调整方法

Country Status (2)

Country Link
CN (1) CN111615714B (zh)
WO (1) WO2020000255A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114663548A (zh) * 2022-02-16 2022-06-24 广东时谛智能科技有限公司 一种图像或图像区域改色方法、系统、设备及存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112288661B (zh) * 2020-12-28 2021-04-09 成都索贝数码科技股份有限公司 一种图像色彩校正方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101742340A (zh) * 2010-02-08 2010-06-16 腾讯科技(深圳)有限公司 图像的优化编辑方法及装置
CN102446345A (zh) * 2010-09-30 2012-05-09 株式会社理光 一种对于白板彩色图像进行颜色增强的方法、装置及系统
CN103327323A (zh) * 2012-03-14 2013-09-25 杜比实验室特许公司 高比特深度视频到低比特深度显示器的高效色调映射
US9349345B2 (en) * 2011-01-31 2016-05-24 Marvell World Trade Ltd. Systems and methods for performing color adjustment of pixels on a color display

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4227322B2 (ja) * 2001-10-01 2009-02-18 キヤノン株式会社 画像処理方法、画像処理装置、記憶媒体及びプログラム
CN105100762B (zh) * 2015-07-17 2017-09-29 敦泰电子有限公司 一种图像处理方法以及图像处理装置
CN107862657A (zh) * 2017-10-31 2018-03-30 广东欧珀移动通信有限公司 图像处理方法、装置、计算机设备及计算机可读存储介质
CN108024104B (zh) * 2017-12-12 2020-02-28 上海顺久电子科技有限公司 一种对输入的高动态范围图像进行处理的方法和显示设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101742340A (zh) * 2010-02-08 2010-06-16 腾讯科技(深圳)有限公司 图像的优化编辑方法及装置
CN102446345A (zh) * 2010-09-30 2012-05-09 株式会社理光 一种对于白板彩色图像进行颜色增强的方法、装置及系统
US9349345B2 (en) * 2011-01-31 2016-05-24 Marvell World Trade Ltd. Systems and methods for performing color adjustment of pixels on a color display
CN103327323A (zh) * 2012-03-14 2013-09-25 杜比实验室特许公司 高比特深度视频到低比特深度显示器的高效色调映射

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114663548A (zh) * 2022-02-16 2022-06-24 广东时谛智能科技有限公司 一种图像或图像区域改色方法、系统、设备及存储介质

Also Published As

Publication number Publication date
CN111615714A (zh) 2020-09-01
CN111615714B (zh) 2023-12-15

Similar Documents

Publication Publication Date Title
US8654141B2 (en) Techniques for adapting a color gamut
KR100925315B1 (ko) 화상 표시 장치 및 전자기기
RU2670774C9 (ru) Способ установки значений уровня серого для жидкокристаллической панели и жидкокристаллического дисплея
WO2019238071A1 (zh) 色域转换方法、色域转换器、显示装置、图像信号转换方法、计算机设备和非暂时性存储介质
KR101138852B1 (ko) 모바일 디스플레이를 위한 스마트 클리퍼
CN108053797B (zh) 一种显示装置的驱动方法及驱动装置
CN107978289B (zh) 一种显示装置的驱动方法及驱动装置
CN107705264B (zh) 一种图像处理方法、电子设备以及具有存储功能的装置
CN107564493B (zh) 一种色域压缩方法、装置及显示设备
RU2668392C2 (ru) Способ и система отображения изображения
US9355603B2 (en) Method for adjusting saturation degree and color adjusting system
CN107784993B (zh) 一种色域压缩方法、装置及显示设备
US20210335183A1 (en) Display control method and device for n-primary-color display panel, and display device
CN112292851B (zh) 色域校正方法及装置
CN101729913A (zh) 影像饱和度的调整方法与系统
WO2020000255A1 (zh) 一种rgb数据的色彩调整方法
TW201413687A (zh) 用於控制有機發光二極體顯示器之操作的方法及裝置
WO2019080446A1 (zh) 显示装置的驱动方法及显示装置
CN107635122B (zh) 对在设备屏幕色域内重映射的图像进行处理的方法及装置
CN110277076B (zh) 一种颜色映射方法及装置、显示设备、介质
WO2022166819A1 (zh) 图像处理方法、装置和电子设备
US20240161452A1 (en) Image enhancement method, device, and computer program
WO2019179059A1 (zh) 基于模糊控制的饱和度增强方法及装置
JP2014093617A (ja) カラー映像信号処理装置、処理方法及び処理プログラム
WO2018035691A1 (zh) 用于图像处理的方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18924822

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18924822

Country of ref document: EP

Kind code of ref document: A1