CN118429446A - Hue adjustment method and device, electronic equipment and medium - Google Patents
Hue adjustment method and device, electronic equipment and medium Download PDFInfo
- Publication number
- CN118429446A CN118429446A CN202410665774.XA CN202410665774A CN118429446A CN 118429446 A CN118429446 A CN 118429446A CN 202410665774 A CN202410665774 A CN 202410665774A CN 118429446 A CN118429446 A CN 118429446A
- Authority
- CN
- China
- Prior art keywords
- hue
- hue adjustment
- image data
- function
- rgb image
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 37
- 230000006870 function Effects 0.000 claims description 63
- 238000004364 calculation method Methods 0.000 claims description 12
- 238000004590 computer program Methods 0.000 claims description 7
- 238000006243 chemical reaction Methods 0.000 abstract description 8
- 238000010276 construction Methods 0.000 abstract description 2
- 230000008569 process Effects 0.000 description 11
- 239000003086 colorant Substances 0.000 description 6
- 238000010586 diagram Methods 0.000 description 4
- 239000011159 matrix material Substances 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000000295 complement effect Effects 0.000 description 1
- 238000010668 complexation reaction Methods 0.000 description 1
- 230000007423 decrease Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003595 spectral effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
- 230000016776 visual perception Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Color Image Communication Systems (AREA)
- Image Processing (AREA)
Abstract
The invention provides a hue adjustment method, a hue adjustment device, electronic equipment and a medium, wherein the method comprises the following steps: acquiring RGB image data; constructing a hue adjustment function based on the RGB image data; the hue adjustment function is a function between a hue angle and a gray value; the target hue angle θ is input, and adjusted RGB image data is obtained based on the hue adjustment function f (x). The invention starts from the construction principle of RGB color space and hue circle, constructs hue adjustment function based on the interrelation between (r, g, b), realizes hue adjustment of RGB image data, and meets the requirement of high-requirement application scene. The hue adjusting method of the invention does not relate to any related content of space conversion, has no complex operation, has high adjusting speed, small required storage space and small occupied resource, and is suitable for hardware realization.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and apparatus for hue adjustment, an electronic device, and a medium.
Background
In image processing, by adjusting the hue, the overall hue in the image can be changed, thereby affecting the visual perception and color appearance of the image.
An image processor (IMAGE SIGNAL Processing, ISP) is generally used to perform hue adjustment, the ISP firstly converts the RGB color space into a color space with separated brightness and color, such as a YUV color space or an HSV color space, then adjusts the hue, and then converts the color space back to the RGB color space after the adjustment is completed. In the hue adjustment process, each pixel point performs color space conversion twice at a hardware end, processing logic is complex, and calculation complexity and hardware resource consumption are high. For example, in the patents CN 112599093B, CN 115358935A, TW200808072, etc., the conversion process of the color space involves complex operations such as evolution, trigonometry, etc., and increases the consumption of hardware resources.
In order to simplify the color space conversion calculation, for example, patent CN 105706434B, CN 115088253A, a lookup table or a comparison table is constructed in advance, which is used to accelerate the color space conversion process and reduce the hardware resource consumption. However, the color phase adjustment process still needs to perform two color space conversions, and the hardware end needs to store at least two data tables for realizing the color phase adjustment. Based on color space conversion, the constructed/obtained multiple data tables have complex and tedious calculation in the acquisition process, and cannot realize hue adjustment rapidly.
To avoid the operation of space transformation, patent CN 117201950A provides a hue adjustment method, apparatus and readable storage medium. By processing the original RGB data of the image using the target correction matrix, the processing logic of the hue adjustment operation is simplified, and the computational complexity and the cost of the hue adjustment device are reduced. However, the hardware resources required by the matrix calculation process are not low, which is unfavorable for the hardware realization.
Disclosure of Invention
The invention provides a hue adjustment method, a hue adjustment device, electronic equipment and a medium, which can at least solve one of the technical problems.
In order to achieve the above object, the present invention provides a hue adjustment method, comprising:
Acquiring RGB image data;
Constructing a hue adjustment function based on the RGB image data; the hue adjustment function is a function between a hue angle and a gray value;
The target hue angle θ is input, and adjusted RGB image data is obtained based on the hue adjustment function f (x).
Further, the hue angle in the hue adjustment function has a value range of [0,360 ].
Further, f (0) =f (360).
Further, the constructing a hue adjustment function based on the RGB image data includes: and fitting a hue adjustment function of any pixel point based on RGB image data (R, G, B) of the pixel point by taking the position of the R channel as 0 degree, the position of the B channel as 120 degrees and the position of the G channel as 240 degrees.
Further, an interpolation calculation method is adopted to fit the hue adjustment function of the pixel point.
Further, the adjusted RGB image data includes: the gray value of the R channel after adjustment is f [ mod (theta, 360) ], the gray value of the B channel after adjustment is f [ mod (120-theta, 360) ], and the gray value of the G channel after adjustment is f [ mod (240-theta, 360) ]; where mod represents modulo.
Based on the same inventive concept, the invention also provides a hue adjustment device, comprising:
the acquisition module acquires RGB image data;
A function module for constructing a hue adjustment function based on the RGB image data; the hue adjusting function is a function between a hue angle and a gray value, and the function is a piecewise function;
and the hue adjustment module inputs the target hue angle and obtains adjusted RGB image data based on the hue adjustment function.
Based on the same inventive concept, the invention also proposes an electronic device comprising a processor, a memory, wherein the memory is for storing a computer program comprising program instructions, the processor being configured to invoke the program instructions for performing the method as described above.
In yet another aspect, the present invention also proposes a computer readable storage medium storing a computer program which, when executed by a processor, implements a hue adjustment method as described above.
The beneficial effects of the invention are as follows:
the invention starts from the construction principle of RGB color space and hue circle, constructs hue adjustment function based on the interrelation between (r, g, b), realizes hue adjustment of RGB image data, and meets the requirement of high-requirement application scene. The hue adjusting method of the invention does not relate to any related content of space conversion, has no complex operation, has high adjusting speed, small required storage space and small occupied resource, and is suitable for hardware realization.
Drawings
FIG. 1 is a schematic diagram of the RGB color space;
FIG. 2 is a schematic diagram of the HSI color space;
FIG. 3 is a schematic diagram of a hue circle;
fig. 4 is a flowchart of the hue adjustment method in the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention.
First, a number of terms related to the embodiments of the present application will be briefly described:
RGB color space: is a color standard for defining colors by acquiring a superposition of luminance values of three color channels, namely, a Red (Red, R) channel, a Green (G) channel, and a Blue (B) channel.
R, G, B three dots represent three primary colors, red (R) and blue (B) combined to form Magenta (Magenta, M), red (R) and green (G) combined to form Yellow (Y), blue (B) and green (G) combined to form Cyan (Cyan, C), and the six color changes constitute the primary hue change.
Fig. 1a shows a schematic diagram of an RGB color space, which can describe all colors in (r, g, b), with six vertices of red, yellow, green, cyan, blue, magenta dividing six areas in a hue circle.
The RGB color space is typically used to construct a space rectangular coordinate system XYZ, where all the colors that can be displayed in the computer can find the corresponding point in the space.
Taking an 8bit image as an example, each color channel in the RGB color space comprises 256 levels of luminance values. The brightness is the lowest when the brightness value is 0, and the brightness is the highest when the brightness value is 255; when the brightness value of the red channel is 0, the brightness value of the green channel is 0, and the brightness value of the blue channel is 0, the corresponding color is black; when the brightness value of the red channel is 255, the brightness value of the green channel is 255, and the brightness value of the blue channel is 255, the corresponding color is white; when the brightness value of the red channel is 255 and the brightness value of the green channel is 0, the corresponding color is red when the brightness value of the blue channel is 0.
As shown in fig. 1a, the gray scale value represented by the origin is (0, 0), the gray scale value of the brightest point is (255 ), the two points are connected (i.e. the spatial diagonal of the cube), and the cube is rotated such that the line is in a vertical state to obtain fig. 1b, and the brightness decreases sequentially from top to bottom (here, the gray scale average of three channels is taken to represent the brightness), which is the prototype of the HSI spatial cone model, and the axis is denoted as the brightness axis.
The HSI color space is a system that starts from the human visual system and describes colors in Hue (H), saturation (S) and brightness (I). As shown in fig. 2, the HSI color space can be described by a conical space model. The upper vertex of the conical space model corresponds to i=1, i.e. white; the lower vertex corresponds to i=0, i.e. black. Hue is represented by angle, 0 ° represents red, and complementary colors differ by 180 °. The saturation ranges from 0 to 1,0 corresponds to the center line of the vertical axis (that is, there is no color on this line, only gray scale), the saturation of red is 1 when i=0.5, and the distance from the point in the color space to the I axis is its saturation.
Hue (Hue): is the corresponding spectral color of light with different wavelengths. By way of example, hue may be defined by a hue circle. As shown in fig. 3, the hue circle takes the angle as a unit, the value range is [0 °,360 ° ], red corresponds to 0 °, blue corresponds to 120 ° and green corresponds to 240 ° in clockwise order from red.
As shown in fig. 4, the present invention provides a hue adjustment method, which includes:
Acquiring RGB image data;
Constructing a hue adjustment function based on the RGB image data; the hue adjustment function is a function between a hue angle and a gray value;
The target hue angle θ is input, and adjusted RGB image data is obtained based on the hue adjustment function f (x).
Wherein, the value range of the hue angle is [0,360 ], and the hue adjustment function f (x) exists: f (0) =f (360).
In this embodiment, a specific description is given of a calculation process of the hue adjustment function, as follows:
Based on the acquired RGB image data (R, G, B), and the angle settings in the hue circle, red corresponds to 0 °, blue corresponds to 120 °, and green corresponds to 240 °, i.e., the R channel is located at 0 °, the B channel is located at 120 °, and the G channel is located at 240 °, in a clockwise order from red.
Based on the RGB image data (r, g, b) of any pixel, a hue adjustment function of the pixel is fitted.
In this embodiment, the hue adjustment function is fitted by interpolation calculation.
In this embodiment, the fitting process is: let f (0) =r, f (120) =b, f (240) =g, f (360) =r, fitting the hue adjustment function in segments to obtain a hue adjustment function。
In this embodiment, linear interpolation is taken as an example only, to explain the fitting of the hue adjustment function. Further, the interpolation calculation method may be a linear interpolation, a nonlinear interpolation, or other interpolation methods.
Further, let f (0) =r, f (120) =b, f (240) =g, f (360) =r, and the hue adjustment function f (x) is obtained by fitting the hue adjustment function by polynomial interpolation. Or interpolating and fitting the hue adjustment function by using other forms of functions to obtain a hue adjustment function f (x).
Acquiring a hue adjustment function based on the interpolation calculation process; and adjusting the RGB image data by using the hue adjustment function to obtain a hue adjustment target.
The target hue angle θ is input, and adjusted RGB image data is obtained based on the hue adjustment function f (x). Wherein, the gray value of the R channel after adjustment is f [ mod (theta, 360) ], the gray value of the B channel after adjustment is f [ mod (120-theta, 360) ], and the gray value of the G channel after adjustment is f [ mod (240-theta, 360) ]. Where mod represents modulo.
Since the hue angle x in the hue adjustment function has a constraint, it is necessary to analyze whether θ is suitable for the hue adjustment function currently fitted, that is, to modulo the hue angle calculated by the gray value of any channel, before calculating the adjusted RGB image data.
The target hue angle is θ, the adjustment angle of the R channel is θ R =θ, the adjustment angle of the B channel is θ B =120- θ, the adjustment angle of the G channel is θ G =240- θ, and whether θ R、θB、θG is within the range of the hue angle in the hue adjustment function, namely, whether θ R、θB、θG is [0,360 ] is sequentially determined.
If θ R、θB、θG all belong to [0,360 ], gray value calculation is performed using the hue adjustment function. Wherein, the gray value R' =f (θ R) of the R channel after adjustment; the gray value G' =f (θ G) of the G channel after adjustment; the adjusted gray value B' =f (θ B) of the B channel.
Taking red as an example to illustrate the adjustment process, the adjustment process is specifically as follows:
knowing RGB image data (255, 0) of red pixels, let f (0) =255, f (120) =0, f (240) =0, f (360) =255, fitting the hue adjustment function in segments, the hue adjustment function is obtained as follows:
The red pixel is adjusted by 120 degrees, and based on the above function, the adjusted RGB image data is as follows:
the adjusted R-channel gray value is f [ mod (120,360) ]=f (120) =0;
The adjusted G channel gray value is f [ mod (240-120, 360) ]=f (120) =0;
the adjusted B-channel gray value is f [ mod (120-120, 360) ]=f (0) =255.
I.e., the adjusted RGB image data is (0,0,255).
According to the color distribution rule in the hue circle, the red pixel point is adjusted by 120 degrees to obtain a blue pixel point, and the gray value of the blue pixel point is (0,0,255). In conclusion, the calculation result of the hue adjustment function accords with the color distribution rule in the hue circle.
Based on the same inventive concept, the invention also provides a hue adjusting device, which is suitable for the hue adjusting method, and specifically comprises the following steps:
the acquisition module acquires RGB image data;
A function module for constructing a hue adjustment function based on the RGB image data; the hue adjustment function is a function between a hue angle and a gray value;
and the hue adjustment module inputs the target hue angle and obtains adjusted RGB image data based on the hue adjustment function.
Based on the same inventive concept, the invention also proposes an electronic device comprising a processor, a memory, wherein the memory is for storing a computer program comprising program instructions, the processor being configured to invoke the program instructions for performing the method as described above.
In yet another aspect, the present invention also proposes a computer readable storage medium storing a computer program which, when executed by a processor, implements a hue adjustment method as described above.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (9)
1. A hue adjustment method, comprising:
Acquiring RGB image data;
Constructing a hue adjustment function based on the RGB image data; the hue adjustment function is a function between a hue angle and a gray value;
The target hue angle θ is input, and adjusted RGB image data is obtained based on the hue adjustment function f (x).
2. The hue adjustment method according to claim 1, wherein the hue angle in the hue adjustment function has a value in the range of [0,360 ].
3. The hue adjustment method according to claim 1, characterized in that f (0) =f (360).
4. The hue adjustment method of claim 3, wherein the constructing a hue adjustment function based on RGB image data comprises: and fitting a hue adjustment function of any pixel point based on RGB image data (R, G, B) of the pixel point by taking the position of the R channel as 0 degree, the position of the B channel as 120 degrees and the position of the G channel as 240 degrees.
5. The hue adjustment method of claim 4 wherein the hue adjustment function of the pixel point is fitted by interpolation calculation.
6. The hue adjustment method of claim 1, wherein the adjusted RGB image data comprises: the gray value of the R channel after adjustment is f [ mod (theta, 360) ], the gray value of the B channel after adjustment is f [ mod (120-theta, 360) ], and the gray value of the G channel after adjustment is f [ mod (240-theta, 360) ]; where mod represents modulo.
7. A hue adjustment device comprising:
the acquisition module acquires RGB image data;
A function module for constructing a hue adjustment function based on the RGB image data; the hue adjusting function is a function between a hue angle and a gray value, and the function is a piecewise function;
and the hue adjustment module inputs the target hue angle and obtains adjusted RGB image data based on the hue adjustment function.
8. An electronic device comprising a processor, a memory, wherein the memory is for storing a computer program, the computer program comprising program instructions, the processor being configured to invoke the program instructions to perform the method of any of claims 1-6.
9. A computer readable storage medium storing a computer program which, when executed by a processor, implements the hue adjustment method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410665774.XA CN118429446A (en) | 2024-05-27 | 2024-05-27 | Hue adjustment method and device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202410665774.XA CN118429446A (en) | 2024-05-27 | 2024-05-27 | Hue adjustment method and device, electronic equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118429446A true CN118429446A (en) | 2024-08-02 |
Family
ID=92337116
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202410665774.XA Pending CN118429446A (en) | 2024-05-27 | 2024-05-27 | Hue adjustment method and device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118429446A (en) |
-
2024
- 2024-05-27 CN CN202410665774.XA patent/CN118429446A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2887636B1 (en) | Method of mapping source colors from a source color gamut into a target color gamut | |
CN1867963B (en) | Color gamut conversion system and method | |
US11120725B2 (en) | Method and apparatus for color gamut mapping color gradient preservation | |
EP3087725B1 (en) | Method of mapping source colors of images of a video content into the target color gamut of a target color device | |
JP6288943B2 (en) | Video display device | |
JP2007528635A (en) | Method and apparatus for converting from a source color space to a target color space | |
US20240242319A1 (en) | Perceptually accurate image rendering | |
KR102617117B1 (en) | color change color gamut mapping | |
WO2022120799A1 (en) | Image processing method and apparatus, electronic device, and storage medium | |
CN118429446A (en) | Hue adjustment method and device, electronic equipment and medium | |
CN110490945B (en) | Image color adjusting method | |
US10979601B2 (en) | High precision gamut mapping | |
CN113556525B (en) | Color temperature adjustment method, device, computer equipment and storage medium | |
CN118537276B (en) | Color adjustment method and device based on hardware implementation and storage medium | |
CN109076142B (en) | High precision gamut mapping | |
JP2007124243A (en) | Color conversion method | |
JP5041538B2 (en) | System and method for adjusting color image quality | |
CN107492365B (en) | Method and device for obtaining color gamut mapping fitting function | |
JPH10191089A (en) | Color conversion device, color printing device, color image data output device, and recording medium | |
WO2024000473A1 (en) | Color correction model generation method, correction method and apparatus, and medium and device | |
JP4715545B2 (en) | Color difference signal correction device | |
CN119418629A (en) | Color correction method, device, equipment and medium | |
Dongil | A VLSI Implementation of Color Gamut Mapping Method for Real-Time Display Quality Enhancement |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |