Plotting Colors on Color Circle: Interconversion between XYZ Values and RGB Color System

Color is generated by optical properties of the pigments. Colors can be calculated by using color matching functions. Color-measuring apparatus such as colorimeters and digital cameras also provide convenient ways to analyze object colors. Color values are given in three dimensions, as a result of these measurements. Such preliminary color values are then converted to the other values such as hue, saturation, lightness, and coordinates in two-dimensional color plates. Interestingly, two different but mutually correlated color systems (color coordinates) are used in colorimetry: XYZ colors and RGB colors. XYZ colors have been mainly used to calculate colors, whereas we recently succeeded to plot colors on color circle based on the measurement of RGB colors.


Introduction
We will recognize objects only by two factors in principle: shape and color; for example, 'green leaves' and 'red flowers'. As such, color of objects potentially has profound effects in both basic analytical studies and applications. Despite this significant importance of the analysis of colors (colorimetry), methods and theories in colorimetry are not fully understood, utilized, or developed by researchers. We will introduce the standard methods to measure and calculate colors first. Figure 1 summarizes the ways how colors of objects are measured and calculated. Formally, colors are measured from surface reflectance spectra of opaque objects or transmittance spectra of transparent objects, R(λ). R(λ) spectra is measured by spectrophotometer such as UV-2450 (Shimadzu, Kyoto, Japan). Scientific definition of the range of 'visible light' is from 380 nm to 780 nm [1]. Then, R(λ) is measured from 380 nm to 780 nm at 5-nm intervals. Spectra (spectral power distribution) of incident lights (L(λ)) also should be taken in account. Their spectra are measured by spectroradiometer such as MS-720 (EKO Instruments, Kyoto, Japan). Thus, the spectra of light reflected/transmitted at the object and coming into our eyes (Spec(λ)) is the multiplication be-tween R(λ) and L(λ) [2]: Transmittance of transparent objects are often measured as the absorbance values (Asb(λ)). Transmittance is calculated from absorbance as follows [2]: Now we have the input data, Spec(λ), for color calculations.
In the history of colorimetry, RGB color space was originally generated, then XYZ color space was later derived from RGB color space. Thus, R, G, and B values are converted to X, Y, and Z values in a three-dimensional matrix [1]: XYZ color space is now more popular than RGB color space, but RGB color space is directly connected to our sense of colors: the three primary colors, i.e. red, green, and blue.
The most usual method of measuring object colors is not performed by color calculation with color matching functions, but by direct acquisition of X, Y, and Z values with colorimetric instruments. These instruments, such as CR-20 (Konica Minolta, Tokyo, Japan) measure X, Y, and Z values in a moment, and automatically calculate XYZ-related coordinates such as L * a * b * coordinates. Here, 'L * a * b * ' is also a color space, modified from XYZ color space so that the coordinates fit better with our sense of colors. The L * a * b * color space is usually adopted to plot the measured object colors. It seems that the L * a * b * color space is often considered to be a perfect color space, plotting all colors on a color circle at the even hue angles. Here, 'hue' represents the type of colors like red, green, and blue. There are also two other factors in colors: lightness (brightness) and saturation (vividness). Saturation is expressed as the distance from the origin, in color circle. Lightness is not expressed in color circle. With the lightness expressed as the third factor, color circle forms a color cylinder. Then, a * -b * color plate of the L * a * b * color space is not actually a circle. Its shape is largely distorted from the circle, and the hues are not evenly placed around the origin. Accordingly, it is quite difficult to describe, on the a * -b * color plate, which hue angles correspond to specific colors such as red, orange, yellow, green, cyan, blue, and magenta. This inconsistency between the popular color measurements and the expected output data was found in our previous report [4].
Certainly, it is quite convenient to use colorimetric instruments to quickly and automatically obtain color co-respectively. These color matching functions are not defined by formulae. Instead, values of the functions are given at 5-nm intervals, from 380 nm to 780 nm (Table 1) [1]. We also devised a standardized version of the RGB color matching functions (FR(λ), FG(λ), and FB(λ); (Table 1) [3]. Summation of the standardized RGB color matching functions along the whole range (380 nm -780 nm) sums to unity (approximately 1). I R , I G , and I B values are obtained by the standardized RGB color matching functions. These calculations are summarized as follows:  ally used L * a * b * color space (or a * -b * color plate) is much distorted from the color circle, as described above.
An effective solution to these problems are direct calculation of object colors from reflectance/transmittance values, and going way back to the original RGB color system, from the modified XYZ color system [1-3]. In the RGB-based color coordinates, standardized values (I R , I G , and I B ) are directly calculated as in the formulae (3), or they are calculated from R, G, and B values: ordinates, but there will be problems in these XYZ-based methodologies, when it comes to scientific description of object colors, and the compatibility of the obtained data with our sense of colors. For instance, response curves of colorimetric instruments manufactured by private companies are company secrets and never open to the public. It is easily imaginable that the response curves of these instruments are much different from the color matching functions, or otherwise resolution of light wave length may be greatly rough. Another problem is that the usu- The RGB values recovered from digital photographs do not have negative values, then this calculation with ASSCC will not be necessary for such data.
To summarize, S RGB2 , H RGB , and L RGB values represent evenly distributed colors on the color circle (or in the color cylinder), which perfectly fit with our sense of colors. Color coordinates on the color circle (r-d coordinates on the round color diagram) are as follows (Figure 2): As shown in the Figure 1, several steps of mathematical conversions are necessary to calculate each colorimetric value. These mathematical conversions have been one-directional: the upstream values such as RGB and XYZ are calculated to obtain downstream values such as L * a * b * and r-d coordinates. The formulae for calculations in reverse directions are not described in previous literatures. In the present study, we will derive the formulae  Table 1). It is not a strict measurement of colors, but RGB values which correspond to I R , I G , and I B can be also easily recovered from digital photographs, by using the software like Adobe Photoshop. The RGB lightness (L RGB ) is calculated as follows: Relative proportions of I R , I G , and I B ρ γ , , and β are also calculated: The RGB hue (H RGB ) is calculated from these values:
Calculation of the saturation values is not simple, because this is the biggest reason that causes distorted shapes of color plates. A preliminary value of the RGB saturation (S RGB ) is calculated from ρ γ , and β values: The maximum values of S RGB are almost unity between the hue angels of 0° and 120°, and between 240° and 360°, but they greatly exceed unity between 120° and 240°. This phenomenon is caused by the negative R values in highly saturated cyanic colors. The S RGB values between 120° and 240° are approximated with the following formula (ASSCC; approximated saturation of saturated cyanic colors) [2]: Second, the H RGB is an arctangent value calculated in the formula (8). Then, its back calculation is as follows: This formula is transformed as: Third, S RGB was calculated from the minimum value among ρ γ , , and β in the formula (9). The minimum value among these three values is determined by the hue angles. Thus, the back calculation of the formula (9) is:

Example of color calculation
An example of the calculation of the RGB-based colorimetric values from an XYZ data set will be demonstrated here, for better understanding of the calculations.
An XYZ data set was measured with a colorimeter, on a leaf of cherry blossom tree (Figure 3). These values were (X, Y, Z) = (5.420, 7.965, 2.077). This data set was converted to RGB data set by using the formulae (13), obtaining the values (R, G, B) = (0.8322, 1.5492, 0.3556). By using the formulae (5), these values were standard-to calculate in reverse directions. These formulae enable interconversion between RGB values, XYZ values, and r-d coordinates (i.e. plots on the color circle).

Calculation of the inverse 3 × 3 matrix
Inverse 3 × 3 matrices can be calculated by a formula. Instead of using the formula, we input data into a website [5] which automatically calculated the inverse 3 × 3 matrix.

Measurement of the leaf color
Leaves were excised from cherry blossom tree (Prunus sp. cultivar 'Taoyame') in spring. The XYZ values of five leaves were measured with CD100 colorimeter (Yokogawa Meters & Instruments Corp, Tokyo, Japan), and the median value (third largest value of the five measurements) was used for calculations.

Interconversion between XYZ and RGB values
The X, Y, and Z values are calculated from R, G, and B values as in the formulae (4). Formulae (4) form a 3 × 3 matrix, then the inverse matrix of the formulae (4) immediately derives the following formulae: By using these formulae, now it is possible to convert XYZ values, which were measured in colorimetric instruments, to RGB values. Interconversion between XYZ values and L * a * b * coordinates is not the target of this study, but this interconversion will be also possible.

Reverse calculation of H RGB and S RGB2 from r-d coordinates
The r-d coordinates are the positions on the color circle, and calculated from H RGB and S RGB2 by the formulae (12). The back calculations of H RGB and S RGB2 from the r-d coordinates are simple, just following the standard trigonometric functions. H RGB is the angle of the line connecting between r-d coordinates and the origin. S RGB2 is the distance of the r-d coordinates from the origin: The lightness value is not reflected in the plots on the color circle, so the value of L RGB cannot be calculated from the r-d coordinates. The lightness values should be prepared separately, or alternatively, the colors are simply calculated without lightness values. strength green light, and 9% strength blue light. At this point, we can deduce that this color is greenish, but a bit yellowish. L RGB value was 0.72. Considering that the maximum value of L RGB is 3, the leaf is not so much blight. These speculations would be consistent with the true color of this leaf (Figure 3).
The color profile is completely clear with the H RGB and the S RGB2 values. The H RGB value was 97°. This hue angle is a bit more greenish that the lawn color (L; yellow-green; 90°). S RGB2 value was 0.61, representing that the color is 61% vivid compared with the full saturation value. With the r-d coordinate of (-0.07, 0.61), the color of this leaf is plotted at this position on the unit color circle (Figure 2).

Interconversion between colorimetric values
In this study, we calculated the formulae to convert XYZ values to RGB values. This important calculation is not mentioned for the first time in this study. The formulae to convert XYZ values to RGB values have been reported in past publications [6,7], but these formulae are different from each other. This is probably because different versions of XYZ and/or RGB color matching functions were used to derive these formulae. We then re-calculated the formulae, based on seemingly the most standard XYZ and RGB color matching functions, by showing their values in Table 1. The resulting formulae (13) were quite similar to the ones on a website [7]. Thus, it was confirmed that the formulae (13) and the formulae on the website are suitable for conversion of the standard XYZ values to the standard RGB values.
Because object colors are usually measured as XYZ colors, such colorimetric data has been almost always plotted onto the XYZ-related color plates, such as the a *b * color plate [8,9]. Our formulae for conversion of the XYZ values to the RGB values connected these color systems each other, and enabled to calculate the coordinates on the color circle, even from the XYZ values. Unlike the largely distorted XYZ-based color plates, the RGB-based color circle and the colorimetric values can be readily interpreted to color names, such as orange and purple [10]. From now on, researchers calculating object colors by either XYZ values or RGB values are recommended to calculate RGB-based colorimetric values, and plot colors on the color circle.
We also derived a series of formulae to back calculate RGB values from the coordinates on the color circle. These calculations are relatively complicated, but possible. By using these formulae, for example, the proportions of three primary colors (red, green, and blue) can be identified for any part of the color circle. This will help generating specific colors by mixture of lamps with different visible light spectra. As we reported in previous ized, so that (I R , I G , I B ) = (0.2200, 0.4096, 0.0940). Sum of these values represents the RGB lightness, according to the formula (6), then (L RGB ) = (0.7237). Following the formulae (7), ratios of I R , I G , and I B are: I R , I G , and I B = (0.3041, 0.5660, 0.1299).
The H RGB and S RGB values are calculated with formulae (8) and formulae (9)

RGB-based color of the cherry leaf
As an example of color calculation, we measure and calculated the color of a cherry leaf. Here, how are the RGB-based colorimetric values estimated, in the terms of colorimetry? Let us check the meaning of each colorimetric value one by one.
To begin with, the values of I R , I G , and I B were approximately 0.22, 0.41, and 0.09, respectively. Because these values have been standardized so that the maximum value is 1, these values mean that the color of this leaf is interpreted as the mixture of 22% strength red light, 41% papers, colorimetric effects such as 'dichromatism' and 'alexandrite effect' can be also analyzed by following rigid spectral calculations [2,3]. These are just examples of possible applications, and the relationship between the whole colorimetric values, clarified in this study, potentially contributes to any aspect of colorimetric analyses.