RGB to Lab color space conversion

- Oct 19, 2018-

RGB to Lab color space conversion

We are a big printing company in Shenzhen China . We offer all book publications, hardcover book printing, papercover book printing, hardcover notebook, sprial book printing, saddle stiching book printing, booklet printing,packaging box, calendars, all kinds of PVC, product brochures, notes, Children's book, stickers, all kinds of special paper color printing products, game cardand so on.

For more information please visit 

http://www.joyful-printing.com.   ENG only    

http://www.joyful-printing.net 

http://www.joyful-printing.org

email: info@joyful-printing.net


First,  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. In order to achieve color uniformity and device independence in the process of image processing, it is necessary to implement standardized and standardized color management.


The so-called color management is to solve the problem of image conversion between colors, so that the color of the image is minimized during the entire copying process. The basic idea is to 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 between the transitions. While it's impossible to have all the colors on different devices exactly the same, you can use color management to ensure that most colors are the same or similar to achieve a consistent color copying effect.


Second, 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 the data in different color spaces to represent the same color. In this paper, the device-dependent RGB color space is converted to a device-independent CIELab color space. Any color space associated with the device can be measured and calibrated in the CIELab color space. If different device-related colors correspond to the same point in the CIELab color space, then the transition between them must be accurate.


There are many ways to convert color space. This paper mainly introduces 3D table interpolation and polynomial regression.


1. Three-dimensional table look-up interpolation

The three-dimensional lookup table method is currently 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 a regular cube. The data of the eight vertices of each cube is known, and the known points of all source spaces form a three-dimensional. Lookup table. When any point in the source space is given, the eight data points adjacent to it can be found to form a node of a small cube lattice, and the eight vertices of the small cube are interpolated to obtain data corresponding to the target space.


The general lookup table method is used in combination with the interpolation method and becomes a three-dimensional lookup table method with an interpolation algorithm. This method can be divided into three steps:

1 segmentation: partition the source color space at a certain sampling interval to establish a three-dimensional lookup table;

2 Find: For a known input point, search the source space and find the cube consisting of eight grid points containing it;

3 Interpolation: Calculate the color values on non-grid points in a grid of cubes.

According to different segmentation methods of source space, common interpolation algorithms are: trilinear interpolation, triangular prism interpolation, pyramid interpolation and tetrahedral interpolation.


2. Polynomial regression

The polynomial regression algorithm is based on the assumption that the association of color spaces 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 items 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.


There are many different forms of polynomial. In this paper, a polynomial with a number of items of 6 is used. The specific expression is shown in formula (1).

The coefficient of this polynomial can be obtained from equation (2).

The expressions in the formula (2) are respectively the transposition of the matrix as shown in the formulas (3) and (4), and the specific expression is as shown in the formula (5). The number of terms representing the polynomial in formula (3) is taken in this topic; it indicates the number of points of the selected source space. In this problem, 216 points are obtained after six levels of segmentation of the source space (ie, RGB color space). So take it. In fact, for a polynomial with a term number of 6, the coefficient of the polynomial can be obtained by taking it.

In the formula (3), () is the three color values of the source space, and () in the formula (4) is any one of the three values representing the color in the target space.

Polynomial regression algorithm is simple, easy to implement, and has a good conversion effect; but the accuracy is low when the number of items is small, when the number of items is too large, the calculation amount is large, and the precision 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 a print, it is often necessary to calculate the color difference of the color to achieve the purpose of controlling the color. At present, the CIE 1976 Lab uniform color space and its corresponding color difference formula are commonly used in the printing industry. The specific expression is shown in formula (6).


Third, the realization process


Firstly, the operation platform of this topic is briefly introduced, and the method of obtaining the data used in this topic and the detailed steps of realizing the color space conversion are explained in detail.


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. Data acquisition

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 all in Adobe Photoshop. Collected.


2.1 acquisition of modeling data. This topic uses six levels of uniform segmentation to collect modeling points, and R, G, and B take 0, 51, 102, 153, 204, and 255, respectively. Input the values of R, G, and B in the color picker of PhotoShop, and record the values of L, a, and b corresponding to the set of values, and record them in the text, as shown in Figure 1. A total of 63 = 216 sets of values were obtained.

Figure 1 Obtaining data from the color picker


2.2 Acquisition of test data This topic uses eight-level non-uniform segmentation to collect test points. R, G, and B respectively take 0, 36, 72, 108, 144, 180, 216, 255. The acquisition method is the same as above, and a total of 83=512 group values are obtained.


3. Specific implementation steps

The flow chart of the specific implementation of this topic is shown in Figure 2.


Figure 2 Frame flow chart

As shown in Figure 2, the specific steps of the program implementation are as follows:

3.1 Start Visual C++ 6.0 first, and set the OpenCV runtime environment in MFC.

3.2 Read the modeling data.

3.3 Completion of the calculation of the polynomial coefficients: according to formulas (3), (4), (5), respectively. The coefficients of the polynomial are obtained by sequentially obtaining , , and .

3.4 Read the test data.

3.5 Draw a three-dimensional color view of the corresponding Lab model after eight-level segmentation of the RGB model.

3.6 Bring the RGB values of each point obtained by the eight-stage segmentation into the three polynomials obtained in step 3, and calculate the L, a, and b values of each point (hereinafter referred to as the calculated value), thereby Convert RGB color space to Lab color space by polynomial regression.

3.7 In order to judge the merits of this color space conversion method, it is necessary to judge by calculating the color difference. For each color, the measured value obtained in step 4 is obtained by subtracting the calculated value obtained in step 6, and then the color difference is obtained according to formula 6, the histogram of the excellent difference distribution is drawn, and the difference is in the range of different color differences. proportion.


Fourth, the results display and analysis


According to the specific steps in the previous section, VC++6.0 is used to realize the conversion of RGB to Lab color space in PhotoShop. This section mainly displays the running results of the program and performs a brief analysis.


1. Results display

In this paper, the conversion relationship is established by six-level uniform segmentation, and the accuracy of this method is tested by using eight-level non-uniform segmentation. The histogram of the color difference distribution is drawn and the color difference is counted. The main interface of the program implementation is shown in Figure 3.


Figure 3 RGB to CIELab color space conversion body interface

The histogram of the color difference distribution and related statistical data are shown in Figure 4.

Figure 4 Color difference statistics interface

The three-dimensional color view of the corresponding Lab model after eight-level segmentation of the RGB model is shown in Figure 5. After the RGB model is divided into eight levels, the polynomial regression method is used to convert to the three-dimensional color view of the Lab color space model, as shown in Figure 6.

Figure 5 Three-dimensional color view of the Lab color space after the eight-level split RGB color space

Figure 6 Three-dimensional color view converted to Lab color space after splitting RGB color space in eight levels


2. Analysis and summary of results

As shown in FIG. 4, the maximum color difference after color space conversion of 512 colors is 28, and the color difference distribution is not uniform as a whole.


According to statistics, there are 74 colors in the range of 0~5, accounting for 14.45% of the total; 264 colors in the range of 5-10, accounting for 51.56% of the total; the color difference range is between 10 and 15. 157 colors, accounting for 30.66% of the total; chromatic aberration ranged from 15 to 20 with 13 colors, accounting for 2.54% of the total; color difference greater than 20 for 4 colors, accounting for 0.78% of the total, and the data showed that the color difference Among the four colors greater than 20, the pure blue (0,0,255) and the pure green (0,255,0) have the largest color difference, and the other two colors have a color difference of less than 21. For these 512 colors, the color difference is at most 28, the minimum is 0, and the average color difference is 9. In general, the range of chromatic aberrations is mostly concentrated between 5 and 15.


Comparing Figure 5 with Figure 6, we can find that the RGB color space is converted to the Lab color space model by polynomial regression method, which is similar to the shape of the Lab color space model obtained by the test, indicating that the results obtained by this topic are ideal. 


V. Summary


It can be seen that the use of polynomial regression to perform color space conversion is relatively accurate. The polynomial of different item numbers can be used to compare the conversion results of the same source space to the same target space; thereby finding out the optimal number of polynomials in the process of converting the source space into the target space. Therefore, further research is needed on this topic.

You Might Also Like