CN116939182A - GPGPU-based color temperature adjusting method - Google Patents

GPGPU-based color temperature adjusting method Download PDF

Info

Publication number
CN116939182A
CN116939182A CN202310814950.7A CN202310814950A CN116939182A CN 116939182 A CN116939182 A CN 116939182A CN 202310814950 A CN202310814950 A CN 202310814950A CN 116939182 A CN116939182 A CN 116939182A
Authority
CN
China
Prior art keywords
color
color components
components
gpgpu
data table
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
Application number
CN202310814950.7A
Other languages
Chinese (zh)
Inventor
董华锋
陈杰坪
吴福根
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong University of Technology
Original Assignee
Guangdong University of Technology
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 Guangdong University of Technology filed Critical Guangdong University of Technology
Priority to CN202310814950.7A priority Critical patent/CN116939182A/en
Publication of CN116939182A publication Critical patent/CN116939182A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/73Colour balance circuits, e.g. white balance circuits or colour temperature control

Abstract

The invention relates to the field of image color processing, in particular to a color temperature adjusting method based on a GPGPU; the excellent LUT interpolation is obtained by adopting a sampling and interpolation algorithm, the pressure of a storage space is reduced, a good balance is obtained in accuracy and space availability, and finally, the extracted interpolation is fitted with a standard gamma curve and a standard color temperature curve to obtain a smoother actual color temperature curve, so that a better screen color temperature adjusting and presenting effect is realized.

Description

GPGPU-based color temperature adjusting method
Technical Field
The invention relates to the field of image color processing, in particular to a color temperature adjusting method based on a GPGPU.
Background
In computers, it is known that images are recorded, processed and saved in digital form, and the types of images are roughly divided into two types: the existing types of the vector type image and the bitmap type image in the general GPU belong to the bitmap type image, so that the image with gorgeous colors and rich hues can be rendered, and a natural scene can be realistically presented to a user;
bitmap images are composed of a number of dots called pixels (pixels) which when combined together form a complete image, the bitmap image is stored in computer with "bits" as the basic unit, the color depth of an image is also often called bit depth, i.e. the number of colors in an image, the maximum number of colors that a pixel can allocate is also called "color volume", according to this definition we can know that the number of colors that a pixel in RGB mode (common color format, with three color channels, whose color depth is 24) may express is 16777216 colors, which is about 1678 thousands colors; in color temperature adjustment, a general-purpose GPU on the market generally adopts a 1D LUT method for correcting color data, the bit depth of the LUT data table is 10 bits, the processing method changes a certain color input value to affect the output value of the color, RBG data are independent of each other, which means that 1D LUTs can only control gamma value, RGB balance (gray scale) and white point (white point), in order to overcome the limitation of 1D LUT, the general practice in the industry generally applies a 3 x 3 matrix to control color saturation and brightness, and performs linear scaling in the complete color space, although the method can make an acceptable calibration result, all nonlinear properties in the display effect still can not be corrected, the color correction accuracy effect is very general, so that finally, when actual color temperature adjustment is performed, situations such as color rendering abnormality may occur, and meanwhile, due to the fact that gamma value and color temperature value group are more, pressure may occur to the storage space, and certain probability of blocking occurs under the condition of continuous correction.
Disclosure of Invention
In order to overcome the limitation of the prior art 1D LUT, the common practice in the industry is to apply a 3×3 matrix to control color saturation and brightness, and perform linear scaling in a complete color space, and although the method can make an acceptable calibration result, all nonlinear properties in the display effect can not be corrected, and the color correction precision effect is very general, so that situations such as color rendering abnormality may occur when actual color temperature adjustment is performed, and meanwhile, due to the large number of gamma values and color temperature value groups, stress may be caused to a storage space, and a certain probability of occurrence of clamping may occur under the condition of continuous correction, the color temperature adjustment method based on the GPGPU is provided.
In order to achieve the above purpose, the present invention provides the following technical solutions:
a color temperature adjusting method based on GPGPU comprises the following steps:
s1: obtaining an LUT data table;
s2: processing the LUT data table to obtain a processed color component;
s3: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
s4: and configuring gamma values corresponding to the values on the curve into a GPGPU hardware register.
Further, in step S2, the LUT data table is processed to obtain color components, which specifically includes:
s2.1: sampling operation is carried out on the obtained LUT data table;
s2.2: and carrying out interpolation operation on the numerical value after the sampling operation.
Further, in step S2.1, the sampling operation specifically includes:
all color components (r, g, b) passing one by one through the formula n=r+n+n+n+b, calculating N, constructing a new color space, the nth row of the new color space is the mapped color component (r, g, b), r is the red component, g is the green component, b is the blue component, and N is the sample size.
Further, the interpolation operation specifically includes:
s2.21: normalizing the color components (r, g, b) of the new color space to obtain (r ', g', b ') so that the r', g ', b' components are in the range of (0, 1);
s2.22: simultaneously rounding r '128, g' 128, and b '128 components of the color components (r' 128, g '128, b' 128) up and down according to the fractional part inclination at 0.51 to obtain two groups of color components;
s2.23: obtaining line numbers of color components of two N-th lines through the formula n=r+n+g+n+n;
s2.24: finding two color components corresponding to the line numbers in the new color space according to the obtained line numbers of the two groups of color components, and marking the two color components as color and color:
s2.25: interpolation calculation is carried out by using fractional parts of color and color;
s2.26: and performing interpolation operation on the three color components of the color and the color L to obtain the color components after the interpolation operation.
Further, in step S2.22, r×128, g×128 and b×128 of the pair of color components (r×128, g×128, b×128) are rounded up and down simultaneously according to the fractional part, so as to obtain two sets of color components, specifically: 6 values were obtained, recorded as: redH, redL, greenH, greenL, blue, wherein:
redH is a value by which the red color component is rounded up;
the renl is the value by which the red color component is rounded down;
greenH is a numerical value obtained by rounding up green color components;
greenL is a value obtained by rounding down green color components;
blue is a numerical value obtained by rounding up blue color components;
blue is a value where blue color components are rounded down.
Further, the two sets of color components are obtained by the formula n=r+n×g+n×n×b, specifically: the line numbers of the two groups of color components are index h and index l, respectively, N is the sample size,
indexH=redH+N*greenH+N*N*blueH
indexL=redL+N*greenL+N*N*blueL。
further, finding two corresponding color components in the LUT data table according to the line numbers index h and index l, and marking the two color components as color h and color l:
colorH=table[indexH]
colorL=table[indexL]
table [ x ] is the x-th row in the LUT data table.
Further, the interpolation is performed by using fractional parts of color components color and color, and the fractional parts are calculated:
dec(number)=number-floor(number)
floor (number) is an integer part, and dec (number) is a fractional part.
Further, the interpolation operation is performed on the three color components to obtain R, G and B components, which are specifically:
R=(redH-redL)*dec(red)+redL
G=(greenH-greenL)*dec(green)+greenL
B=(blueH-blueL)*dec(blue)+blueL。
further, a color temperature adjusting system based on a GPGPU includes:
the initial module is used for acquiring an LUT data table;
the processing module is used for: processing the LUT data table to obtain a processed color component;
fitting module: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
and (3) a configuration module: and configuring gamma values corresponding to the values on the curve into a GPGPU hardware register. Compared with the prior art, the technical scheme of the invention has the beneficial effects that:
the invention provides a color temperature adjusting device and a color temperature adjusting method based on a GPGPU (graphics processing Unit) on a linux system, wherein the method comprises the following steps: the LUT data is mapped by adopting a 3DLUT method, so that any displayed nonlinear data can be processed, the problems of sudden and large change of color and the like are solved, and meanwhile, the color bit depth adopts 12 bits, so that the number of the color can be expressed is much more abundant, and the color rendering effect is finer and softer; according to the invention, a sampling and interpolation algorithm is selected on the processing of a large amount of data, the pressure of a storage space is reduced, meanwhile, the color precision is reserved as much as possible, and finally, the GPGPU can obtain an excellent display effect on screen color temperature adjustment in a linux environment, and 3DLUT can describe the accurate behaviors of all color points in a three-dimensional color space, so that the three-dimensional color space can process any nonlinear attribute of display, and also can accurately process the problems of sudden and large change of color and the like. The bit depth of the LUT table adopts 12 bits, the number of the colors which can be represented is finer and richer, the processing precision of the color data is improved, meanwhile, the sampling and interpolation algorithm is adopted to obtain excellent LUT interpolation, the pressure of a storage space is reduced, a good balance is obtained on the precision and the space availability, finally, the extracted interpolation is fitted with a standard gamma curve and a standard color temperature curve, a smoother actual color temperature curve is obtained, and a better screen color temperature adjusting and presenting effect is realized.
Drawings
FIG. 1 is a flow chart of a color temperature adjusting method based on a GPGPU;
fig. 2 is a flowchart of a color temperature adjusting method based on a GPGPU according to an embodiment of the present invention;
fig. 3 is a LUT data table provided in an embodiment of the present invention.
Detailed Description
The drawings are for illustrative purposes only and are not to be construed as limiting the present patent;
for the purpose of better illustrating the embodiments, certain elements of the drawings may be omitted, enlarged or reduced and do not represent the actual product dimensions;
it will be appreciated by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The technical scheme of the invention is further described below with reference to the accompanying drawings and examples.
Example 1
A color temperature adjusting method based on GPGPU, as shown in figure 1, comprises the following steps:
s1: obtaining an LUT data table;
s2: processing the LUT data table to obtain a processed color component;
s3: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
s4: and configuring gamma values corresponding to the values on the curve into a GPGPU hardware register.
In the implementation process, in a desktop operating system, a user slides a color temperature adjusting slider through a color temperature adjusting function of a display setting interface, LUT data with gamma_size of 256 is sent to an Xserver by an application layer, and then enters a kernel layer through an iocrtl interface of a libdrm layer, and the LUT data is processed in the kernel layer.
In most cases, as shown in fig. 3, the range of color values is (0, 0) to (255, 255, 255), but since our LUT data table uses bit depth of 12 bits, its range of values is (0, 0) to (4095, 4095, 4095), if this mapping is to be stored completely, we need 4095×4095 pieces of color information to correspond to this, this data size is definitely huge and is not beneficial for practical application, and for this case we use the sampling+interpolation method, using 128×128 to sample the mapping information, and then restore intermediate and exact information by interpolation at run time.
Example 2
The present embodiment continues to disclose the following on the basis of embodiment 1:
in step S2, the LUT data table is processed to obtain color components, which specifically includes:
s2.1: sampling operation is carried out on the obtained LUT data table;
s2.2: and carrying out interpolation operation on the numerical value after the sampling operation.
In step S2.1, the sampling operation specifically includes:
all color components (r, g, b) passing one by one through the formula n=r+n+n+n+b, calculating N, constructing a new color space, the nth row of the new color space is the mapped color component (r, g, b), r is the red component, g is the green component, b is the blue component, and N is the sample size.
The interpolation operation specifically comprises the following steps:
s2.21: normalizing the color components (r, g, b) of the new color space to obtain (r ', g', b ') so that the r', g ', b' components are in the range of (0, 1);
s2.22: simultaneously rounding r '128, g' 128, and b '128 components of the color components (r' 128, g '128, b' 128) up and down according to a degree of inclination of the fractional portion at 0.51 to obtain two sets of color components;
s2.23: obtaining line numbers of color components of two N-th lines through the formula n=r+n+g+n+n;
s2.24: finding two color components corresponding to the line numbers in the new color space according to the obtained line numbers of the two groups of color components, and marking the two color components as color and color:
s2.25: interpolation calculation is carried out by using fractional parts of color and color;
s2.26: and performing interpolation operation on the three color components of the color and the color L to obtain the color components after the interpolation operation.
In step S2.22, r×128, g×128 and b×128 of the pair of color components (r×128, g×128, b×128) are rounded up and down simultaneously according to the fractional part, so as to obtain two sets of color components, specifically: 6 values were obtained, recorded as: redH, redL, greenH, greenL, blue, wherein:
redH is a value by which the red color component is rounded up;
the renl is the value by which the red color component is rounded down;
greenH is a numerical value obtained by rounding up green color components;
greenL is a value obtained by rounding down green color components;
blue is a numerical value obtained by rounding up blue color components;
blue is a value where blue color components are rounded down.
The two sets of color components are obtained by the formula n=r+n+g+n+n+b, specifically: the line numbers of the two groups of color components are index h and index l, respectively, N is the sample size,
indexH=redH+N*greenH+N*N*blueH
indexL=redL+N*greenL+N*N*blueL。
finding two corresponding color components in the LUT data table according to the line numbers index H and index L, and marking the color components as color H and color L:
colorH=table[indexH]
colorL=table[indexL]
table [ x ] is the x-th row in the LUT data table.
The interpolation calculation is carried out by using the decimal parts of the color components color and color, and the calculation of the decimal parts is carried out:
dec(number)=number-floor(number)
floor (number) is an integer part, and dec (number) is a fractional part.
And performing interpolation operation on the three color components to obtain R, G and B components, wherein the specific steps are as follows:
R=(redH-redL)*dec(red)+redL
G=(greenH-greenL)*dec(green)+greenL
B=(blueH-blueL)*dec(blue)+blueL。
in a specific implementation process, in a sampling process, color_min designates a minimum value of a COLOR space, color_max designates a maximum value of the COLOR space, two numbers are added together to determine a range of the COLOR space, in the COLOR space, each row of 3 numbers respectively represents components of R, G and B, each row is a COLOR value, 128 x 128 COLOR values are defined, and assuming that we have any COLOR formula, we need to convert the COLOR components between formulas first, the nth row is a COLOR to be taken by us, and n=r+n×g+n×b;
in the interpolation process, when any color (r, g, b) is converted to 0< r, g, b <1 through normalization operation, the upper bound and the lower bound of the color (r=0.21, for example, r=128=26.88, then 26.88 is rounded up and down simultaneously to obtain 26 and 27, and similarly, green and blue are processed equally to obtain 6 numbers respectively, which are marked as: redH, redL, greenH, greenL, blue, H representing an upper bound, L representing a lower bound, then, two index are obtained through a formula n=r+n+g+n+n+b;
example 3
This example continues to disclose the following on the basis of examples 1 and 2:
as shown in fig. 2, a GPGPU-based color temperature adjustment system includes:
the initial module is used for acquiring an LUT data table;
the processing module is used for: processing the LUT data table to obtain a processed color component;
fitting module: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
and (3) a configuration module: configuring gamma values corresponding to the values on the curve into a GPGPU hardware register; and converting the numerical value on the smooth curve into a corresponding gamma coefficient table, and finally, directly configuring the coefficients into a GPGPU hardware register, so that an excellent screen color temperature adjustment realization effect can be realized.
The same or similar reference numerals correspond to the same or similar components;
the terms describing the positional relationship in the drawings are merely illustrative, and are not to be construed as limiting the present patent;
it is to be understood that the above examples of the present invention are provided by way of illustration only and not by way of limitation of the embodiments of the present invention. Other variations or modifications of the above teachings will be apparent to those of ordinary skill in the art. It is not necessary here nor is it exhaustive of all embodiments. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the invention are desired to be protected by the following claims.

Claims (10)

1. The color temperature adjusting method based on the GPGPU is characterized by comprising the following steps of:
s1: obtaining an LUT data table;
s2: processing the LUT data table to obtain a processed color component;
s3: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
s4: and configuring gamma values corresponding to the values on the curve into a GPGPU hardware register.
2. The color temperature adjusting method based on the GPGPU according to claim 1, wherein in step S2, the LUT data table is processed to obtain color components, specifically:
s2.1: sampling operation is carried out on the obtained LUT data table;
s2.2: and carrying out interpolation operation on the numerical value after the sampling operation.
3. The color temperature adjusting method based on the GPGPU according to claim 2, wherein in step S2.1, the sampling operation specifically comprises:
all color components (r, g, b) passing one by one through the formula n=r+n+n+n+b, calculating N, constructing a new color space, the nth row of the new color space is the mapped color component (r, g, b), r is the red component, g is the green component, b is the blue component, and N is the sample size.
4. A color temperature adjusting method based on a GPGPU according to claim 3, wherein the interpolation operation is specifically:
s2.21: normalizing the color components (r, g, b) of the new color space to obtain (r ', g', b ') so that the r', g ', b' components are in the range of (0, 1);
s2.22: simultaneously rounding r '128, g' 128, and b '128 components of the color components (r' 128, g '128, b' 128) up and down according to the fractional portion to obtain two sets of color components;
s2.23: obtaining line numbers of color components of two N-th lines through the formula n=r+n+g+n+n;
s2.24: finding two color components corresponding to the line numbers in the new color space according to the obtained line numbers of the two groups of color components, and marking the two color components as color and color:
s2.25: interpolation calculation is carried out by using fractional parts of color and color;
s2.26: and performing interpolation operation on the three color components of the color and the color L to obtain the color components after the interpolation operation.
5. The method of claim 4, wherein in step S2.22, r×128, g×128 and b×128 of the pair of color components (r×128, g×128, b×128) are rounded up and down simultaneously according to fractional parts to obtain two sets of color components, specifically: 6 values were obtained, recorded as: redH, redL, greenH, greenL, blue, wherein:
redH is a value by which the red color component is rounded up;
the renl is the value by which the red color component is rounded down;
greenH is a numerical value obtained by rounding up green color components;
greenL is a value obtained by rounding down green color components;
blue is a numerical value obtained by rounding up blue color components;
blue is a value where blue color components are rounded down.
6. The method for color temperature adjustment based on GPGPU according to claim 5, wherein the two sets of color components are obtained by the formula n=r+n+g+n+n, specifically: the line numbers of the two groups of color components are index h and index l, respectively, N is the sample size,
indexH=redH+N*greenH+N*N*blueH
indexL=redL+N*greenL+N*N*blueL。
7. the method of claim 6, wherein finding two corresponding color components in the LUT data table according to the line numbers index h and index l is referred to as color h and color l:
colorH=table[indexH]
colorL=table[indexL]
table [ x ] is the x-th row in the LUT data table.
8. The method of claim 7, wherein the interpolating is performed by using fractional parts of color components colorH and colorL, and the calculating of the fractional parts:
dec(number)=number-floor(number)
floor (number) is an integer part, and dec (number) is a fractional part.
9. The color temperature adjusting method based on the GPGPU according to claim 8, wherein the interpolating operation is performed on the three color components to obtain R, G, and B components, specifically:
R=(redH-redL)*dec(red)+redL
G=(greenH-greenL)*dec(green)+greenL
B=(blueH-blueL)*dec(blue)+blueL。
10. a GPGPU-based color temperature adjustment system, comprising:
the initial module is used for acquiring an LUT data table;
the processing module is used for: processing the LUT data table to obtain a processed color component;
fitting module: fitting the processed color components with a standard gamma curve and a color temperature curve to obtain a smooth curve;
and (3) a configuration module: and configuring gamma values corresponding to the values on the curve into a GPGPU hardware register.
CN202310814950.7A 2023-07-04 2023-07-04 GPGPU-based color temperature adjusting method Pending CN116939182A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310814950.7A CN116939182A (en) 2023-07-04 2023-07-04 GPGPU-based color temperature adjusting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310814950.7A CN116939182A (en) 2023-07-04 2023-07-04 GPGPU-based color temperature adjusting method

Publications (1)

Publication Number Publication Date
CN116939182A true CN116939182A (en) 2023-10-24

Family

ID=88381906

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310814950.7A Pending CN116939182A (en) 2023-07-04 2023-07-04 GPGPU-based color temperature adjusting method

Country Status (1)

Country Link
CN (1) CN116939182A (en)

Similar Documents

Publication Publication Date Title
US6724507B1 (en) Image processing method and image processing apparatus
JP5296889B2 (en) Image processing apparatus and image processing method
US8493619B2 (en) Hardware-accelerated color data processing
TWI459820B (en) Color and geometry distortion correction system and method
KR101041882B1 (en) Transforming three color input signals to more color signals
US7554557B2 (en) Device and method for image compression and decompression
US11115563B2 (en) Method and apparatus for nonlinear interpolation color conversion using look up tables
KR101183456B1 (en) Method and system for extending color gamut
EP3262630B1 (en) Steady color presentation manager
CN111429827A (en) Display screen color calibration method and device, electronic equipment and readable storage medium
CN111179370B (en) Picture generation method and device, electronic equipment and storage medium
AU2018233015A1 (en) System and method for image processing
EP3961551B1 (en) Gamut conversion method and apparatus, and medium
AU2010257408B2 (en) Colour encoding clustering
US8861850B2 (en) Digital image color correction
US8111423B2 (en) Image processing device and image processing method
WO2022120799A9 (en) Image processing method and apparatus, electronic device, and storage medium
CN116939182A (en) GPGPU-based color temperature adjusting method
CN116092423A (en) Color correction method and device for display panel
US11361476B2 (en) Efficient color mapping systems and methods
WO2024000473A1 (en) Color correction model generation method, correction method and apparatus, and medium and device
WO2022103117A1 (en) Perceptual color enhancement based on properties of responses of human vision system to color stimulus
US20220400187A1 (en) Updating a color profile
CN107492365B (en) Method and device for obtaining color gamut mapping fitting function
JP2898569B2 (en) Video accelerator board for computer game development

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