RGB to Lab color space conversion

I. Introduction

As the printing industry changes from analog to digital, the problem of accurate color reproduction has become critical. We need to use color management to ensure better, faster and more accurate color images. To achieve color uniformity in the image processing and other processes and have nothing to do with the equipment, it is necessary to implement standardized and standardized color management.

The so-called color management is to solve the problem of image conversion between various color spaces, so that the color of the image is minimized during the entire copy process. The basic idea is: first select a device-independent reference color space, then characterize the device, and finally establish a relationship between the color space of each device and the device-independent reference color space, so that the data file is in each device There is a clear relationship to be found when switching between. Although it is impossible to make all colors on different devices identical, you can use color management to ensure that most colors are the same or similar, so as to achieve a consistent color reproduction effect in a certain sense.

Second, the color space conversion

Color space conversion refers to converting or representing color data in one color space into corresponding data in another color space, that is, using data in different color spaces to represent the same color. In this article, the RGB color space related to the device is converted to the CIELab color space independent of the device. Any color space related to the device can be measured and calibrated in the CIELab color space. If different device-related colors can correspond to the same point in the CIELab color space, then the conversion between them must be accurate.

There are many methods of color space conversion. This article mainly introduces the three-dimensional look-up table interpolation method and polynomial regression method.

1. Three-dimensional look-up table interpolation method

The three-dimensional lookup table method is a commonly used algorithm for studying color space conversion. The core idea of ​​the 3D lookup table algorithm is to divide the source color space into regular cubes, and the data of the eight vertices of each cube is known, and all the known points in the source space form a three Lookup table. When any point in the source space is given, it is possible to find eight adjacent data points to form a node of a small cube grid, and interpolate through the eight vertices of this small cube to obtain the data corresponding to the target space.

The general look-up table method is used in combination with the interpolation method to become a three-dimensional look-up table method with an interpolation algorithm. This method can be divided into three steps:

â‘  Segmentation: partition the source color space at a certain sampling interval to establish a three-dimensional lookup table;
â‘¡ Find: For a known input point, search the source space to find a cube consisting of eight grid points containing it;
â‘¢ Interpolation: Calculate the color value on non-grid points in a cube grid.
According to the different segmentation methods of the source space, common interpolation algorithms include: trilinear interpolation, triangular prism interpolation, pyramid interpolation and tetrahedral interpolation methods.

2. Polynomial regression method

Polynomial regression algorithm refers to the assumption that the connection of color space can be estimated by a set of simultaneous equations. The only necessary condition for the polynomial regression algorithm is that the number of points in the source space should be greater than the number of terms in the selected polynomial. The focus of this algorithm is to calculate the coefficients of the polynomial, and then substitute the data of the source color space into the polynomial, and then the converted result can be obtained according to the equation.

The characteristics of polynomial regression algorithm are simple, more convenient to implement, and have a good conversion effect; but the accuracy is low when the number of items is small, and the calculation amount is large when the number of items is too large, and the accuracy is not necessarily high.

3. Color difference

When evaluating the color reproduction quality and controlling the color reproduction process, for example, when implementing color management and evaluating the color of the printed matter, it is often necessary to calculate the color difference of the color to achieve the purpose of controlling the color. At present, the printing industry generally uses the CIE 1976 Lab uniform color space and its corresponding color difference formula. [next]

Three, the realization process

First, it briefly introduces the operation platform of this topic, and then explains in detail the acquisition method of the data used in this topic, and the detailed steps to realize the color space conversion.

1. Operating platform

The operating system used in this topic is Microsoft Windows XP, the programming environment is Visual C ++ 6.0, the entire application is based on the MFC application framework, and OpenGL and OpenCV are also used.

2. Access to data

The data is divided into two parts: modeling data and test data. The modeling data is used to calculate the coefficients of the polynomial. The test data is used to analyze the accuracy of the algorithm. The modeling data and test data from the source space and the target space are in Adobe Photoshop. Collected.

① Acquisition of modeling data. This topic adopts six-level uniform segmentation to collect modeling points, and R, G, and B take 0, 51, 102, 153, 204, and 255, respectively. In the Color Picker of PhotoShop, input each group of values ​​of R, G, and B in sequence, and write down the values ​​of L, a, and b corresponding to this group of values, and record them in the text. A total of 63 = 216 sets of values ​​are obtained.

②Acquisition of test data In this question, eight levels of non-uniform segmentation are used to collect test points, and R, G, and B are respectively taken as 0, 36, 72, 108, 144, 180, 216, and 255. The collection method is the same as above, and a total of 83 = 512 sets of values ​​are obtained.

3. Specific steps

The specific steps of the program are as follows:

â‘  Start Visual C ++ 6.0 first, and set the operating environment of OpenCV in MFC.
â‘¡ Read modeling data.
â‘¢Complete the calculation of the polynomial coefficients: according to formulas (3), (4) and (5), respectively. Finding,,, and in turn, the coefficients of the polynomial are obtained.
â‘£ Read test data.
⑤Draw a three-dimensional color view of the corresponding Lab model after eight-level segmentation of the RGB model.
⑥ Bring the RGB value of each point obtained by the eight-level division into the three polynomials obtained in step ③, and calculate the L, a, and b values ​​of each point (hereinafter referred to as the calculated value) The RGB color space is converted to the Lab color space by polynomial regression.
⑦ In order to judge the advantages and disadvantages of this color space conversion method, it is necessary to judge by calculating the color difference. For each color, calculate the difference between the measured value obtained in step ④ and the calculated value obtained in step ⑥, and then calculate the difference according to formula ⑥, draw the difference distribution histogram, and count out the range of different color differences proportion.

4. Results display and analysis

According to the specific steps in the previous section, using VC ++ 6.0 programming to achieve RGB to Lab color space conversion in PhotoShop, this section mainly displays the program's running results and conducts a brief analysis.

V. Summary

It can be seen that the color space conversion using polynomial regression method is relatively accurate. Polynomials with different number of terms can be used to compare the conversion results from the same source space to the same target space; thus finding the optimal number of polynomials used in the conversion of this source space to the target space. Therefore, further research is needed on this subject.

Rectangle Folding Table

6Ft Folding Table,Folding Dining Table,Foldable Rectangular Table,Rectangular Banquet Table

Zhejiang Lifan Furniture.Co.,Ltd , https://www.lffoldingtable.com