Vous êtes sur la page 1sur 9

RGB Color Spaces

Pesal Koirala
Department of Computer Science and Statistics
University of Joensuu

Submitted to
Prof. Jussi Parkkinen
4-4-2007

Introduction
The color which we see is the continuous signal of wavelength of electromagnetic
radiations. The visible range lies within the 380 to 780 nm. However, most of the display
system uses the three channels to render the color image; these three channels are Red,
Green and Blue in RGB color spaces. There exist different types of RGB color spaces
depending on the particular type of application and technical specification. In this report I
have described the RGB color calculation from spectral image. The gamma correction
method has been studied since the RGB color space is device dependent. Different types of
existing color spaces have been studied. The color produced by display device is represented
in RGB color space, the color distribution of RGB image is rendered in xyY system and
RGB color cube. Finally the color difference formula has been presented

RGB Color Calculation


Mathematically color has been represented in different color model (such as RGB, LAB
etc.) based on different factors such as chroma, saturation, intensity. Most of the existing
display devices visualize three dimensional color space based on Red, Green and Blue
channels generally called the RGB color space. So the color in other color spaces should be
converted to RGB color space to visualize the real object. The color spaces expressed in
HSV, YIQ, YCbCr and Ohtas [3] space are linearly transformed to RGB space and vice
versa.
The transformation from L a b to RGB color coordinate system is obtained from the
nonlinear transformation from L a b to the tristimulus values X, Y and Z, and then linear
transformation from XYZ coordinate system to RGB coordinate system. The full spectral
calculations of color produces the perfect rendering and supports the post illumination
process since the spectral power distribution of light source and color matching functions
x ( ), y ( ) and z ( ) are used. In the full spectral calculation three dimensional tristimulus

values X, Y and Z is derived as shown in equation 1 and then RGB is calculated from linear
transformation from XYZ coordinate system to RGB coordinate system.
X = k S ( ) ( ) x ( ) d ( )

Y = k S ( ) ( ) y ( ) d ( )

(1)

Z = k S ( ) ( ) z ( ) d ( )

Where,
K=

100

S ( ) y ( )d

S ( ) Spectrum of Illumination
( ) Reflectance or transmittance of an object

x ( ), y ( ) and z ( ) represent the color matching functions.

The color matching functions also known as standard observer should be defined to whether
1931 CIE standard observer ( 2 observer) or 1964 standard observer ( 10 observer). Fig.1
and Fig.2 shows the standard observer.

Fig.1 A set of color matching functions to define a CIE 1931 Standard


observer

Fig.2 A set of color matching functions to define a CIE 1964 standard observer

The transformation from RGB to XYZ is obtained by following linear equation in the case
of 1931 standard observer

X 0.489989 0.310008 0.2 R




Y = 0.176962 0.81240 0.010 G
Z 0.0
0.01
0.99 B

(2)

By reversing above equation, the transformation from XYZ to RGB is obtained


0.89658 0.468083 X
R 2.3647


G = 0.515155 1.426409 0.088746 Y
B 0.005203 0.014407
1.0092 Z

(3)

As shown in equation 3, the transformation from XYZ to RGB is linear transformation but
the luminance generated by a computer monitor generally is not a linear function of the
applied signal so the correction is needed in the calculated RGB values this process is called
gamma correction.
Gamma Correction

Gamma correction for RGB Values is represented by the following equations


I = A( K1D + K 2 )

(4)

Where K1 and K 2 are gain and offset of device A is the maximum value of the system, D is
the original pixel value R,G and B and I is the gamma corrected pixel value. The gamma
correction of the most of the display device lies within 2.35 to 2.55. The gamma correction
is applied for camera and display system.
The gamma value of the monitors is calculated by using the grey patches of known
reflection properties of calibration object called the GretagMacbethColorChecker. The

GretagMacbethColorChecker as shown in Fig.3 consists of 24 matte color patches


including six grey patches. .

Fig.3 MacbethColorChecker
3

The six grey patches have constant reflectance factor over the visible wavelength interval of
light. The reflectance factor gives the amount of light reflected from the surface of the object
and it is represented in percentage. The constant reflectance factor of six grey patches of
color checker are 90%, 59.1%, 36.2%, 19.8%, 9% and 3.1% and these values are properties
of patches and are independent from the illumination and camera . The relationship between
the reflectance factor of grey patches and the image irradiances describes directly the camera
behavior with respect to linearity. The gamma value is calculated, as the nonlinear behavior
of the camera is known. [4]

The different RGB color spaces

There is existence of different types of RGB spaces depending on the technical reasons,
professional requirements, and display device. Depending on the different RGB color
spaces transformation matrix from XYZ to RGB differs as a result produce the different size
of color gamut. The commonly known RGB spaces are adobe RGB, apple RGB, CIE RGB.
Nevertheless there are also many equally important and known RGB spaces depending on
the different criterion. The detail description and transformation matrix from RGB to XYZ
space and vice versa and color gamut representation in xy-chromatictiy diagram of different
RGB color spaces has been presented in reference [1].

Chromaticity coordinates

The chromaticity coordinates is used to plot the color distribution and is used to evaluate
the color gamut of different RGB color spaces. The chromaticity coordinates x, y and z is
defined by the following equation.

X
X + Y + Z
Y
y =
X + Y + Z
Z
z =
X + Y + Z
x =

(5)

From the above equation it has been seen that x + y + z = 1 . So by knowing the value of x
and y remaining value z can be calculated.

The chromaticity diagram for the 1931 and 1964 CIE observers [2] are slightly different as
shown in Fig.4 but their basic features are the very much same. The colors having same hue
and saturation lies at the same point on the chromaticity diagram but the coincided point
may have the different luminance. The interior and the boundary of the chromaticity
diagram represent all the chromaticity values of the visible spectrum.

Fig.4 Chromaticity diagrams for x vs. y, the dotted boundary and solid line boundary are the
boundary of chromaticity diagram for standard 10 and 2-degree observer respectively (Left
figure). x, y and Y coordinate systems in 2 degree observer and D50 light source and its
distribution of Image shown in Figure. 6

The outer border of the horseshoe shaped structure, which denotes the monochromatic, or
the 100 percents saturated colors is the chromaticity calculated by using standard observer as
shown below

x =

x ( )
x ( ) + y ( ) + z ( )

y =

y ( )
x ( ) + y ( ) + z ( )

The interior region denotes the unsaturated colors. The luminosity cant be represented in
the chromaticity diagram only the hue and saturation is represented so the point with
coordinates
x=0.333 and y=0.333 represents not only the white color, but also the black and all grey
colors [3]. The color can be completely specified by using x, y and luminosity Y. The bigger
5

the color gamut of RGB space can produce the more colors , The color gamut of any color
spaces represents that only the color inside the color gamut is possible to be produced by
this particular color spaces. Fig. 5 represents the color gamut of different RGB spaces.

Fig.5 CIE 1931 Chromatictiy diagram, the color gamut of different color spaces,
Figure taken from reference [1]
RGB Color Cube

The colors produced by CRT displays are often shown as a cube in which each point
represents the combination of the maximum and minimum emission of each primary [2].
When the amounts of three primaries (Red, Green and Blue) are in minimum levels the
black color is produced; when the amounts of three primaries are in maximum levels, the
white color is produced. The basic rule of mixing in RGB color cube is following
R+G+B=White
R+G=Yellow
R+B=Magenta
G+B=Cyan
The above mentioned cases are for the weights of each color is 100%. The result of mixing
of primaries with different weights is calculated by using the interpolation inside the RGB
color cube. The more general formula in additive color mixing is represented as
w1 R + w2 G + w3 B = Color mixture
Where w1,w2 and w3 are concentration of primaries.

Figure 6 shows the RGB image, its color distribution in RGB color cube.

Fig.6 RGB image taken from RGB camera (Left Image), its color distribution in RGB color
cube from different sides (Middle and right image)
Color Difference Calculation

The color difference calculation gives the similarity or dissimilarity measure of the colors.
The CIE LAB color difference E is commonly used in industrial application. These color
difference method resembles with human visual perception.
E = ( L*1 L*2 ) 2 + (a1* a 2* ) 2 + (b1* b2* ) 2

Where; subscript 1 and 2 represents different two colors. L* represents the luminance and
a * and b * represents the chrominance. The value of L* is maximum for the brightest point
and ideally the maximum value is L* = 100 and it is minimum for dark point and ideally the
minimum value is L* = 0 . L* , a * and b * depict the difference between light and dark, green
and red, and yellow and blue respectively.
Nevertheless CIE LAB color difference is not suitable in the case of metamerism since the
two different colors produce the same tristimulus values in certain light source.

References:
[1] Danny Pascale, A Review of RGB Color Spaces from xyYto RGB,
http://www.babelcolor.com/download/A%20review%20of%20RGB%20color%20spaces.pd
f 2-4-2007

[2] R. S. Berns, Principle of Color Technology, Wiley, USA, 2000


[3] Ju-Ichi Ohta, Takeo Kanade and Joshi Yuki Sakai Color information for Region
Segmentation, Computer Graphics and Image Processing 13, 222-241 (1980).
[4] R. Klette ,K. Schluns and A. Koschan, Computer Vision Three-Dimensional Data from
Images, Springer Singapore, 1998.

Vous aimerez peut-être aussi