Volume 4, No.
1, January 2013
Journal of Global Research in Computer Science
REVIEW ARTICLE
Available Online at www.jgrcs.info
VARIOUS COLOUR SPACES AND COLOUR SPACE CONVERSION
ALGORITHMS
Nishad PM*1 and Dr. R.Manicka Chezian2
*1
Ph.D Scholar, Department Of Computer Science NGM College, Pollachi, India
[email protected] 2
Associate professor, Department of computer science NGM College Pollachi, Coimbatore, India
[email protected]Abstract: A color model is an abstract mathematical model describing the way colors can be represented as tuples of numbers, typically as three
or four values or color components (e.g. RGB and CMYK are color models). However, a color model with no associated mapping function to an
absolute color space is a more or less arbitrary color system with no connection to any globally understood system of color interpretation. This
paper mainly discusses about various colour spaces and the how they organized and the colour conversion algorithms like CMYK to RGB, RGB
to CMYK, HSL to RGB, RGB to HSL , HSV to RGB , RGB To HSV , YUV to RGB And RGB to YUV.
Keywords: Colour spaces, colour conversion algorithms, CMYK, RGB, HSL, HSV and YUV
INTRODUCTION RGB COLOR SPACE
A color space is all possible colors that can be made from a An RGB color space is all possible colors that can be made
group of colourants, Imagine, for example, shining three from three colourants for red, green and blue.
lights together onto a white wall: one red light, one green
light, and one blue light, each with dimmer switches. If only The color which we see is the continuous signal of
the red light is on, the wall will look red. If only the green wavelength of electromagnetic radiations. The visible range
light is on, the wall will look green. If the red and green lies within the 380 to 780 nm. However, most of the display
lights are on together, the wall will look yellow. Dim the red system uses the three channels to render the color image;
light some and the wall will become more of a yellow-green. these three channels are Red, Green and Blue in RGB color
Dim the green light instead, and the wall will become more spaces [1].
orange. Bringing up the blue light a bit will cause the orange
to become less saturated and more whitish. In all, each All color spaces can be derived from the RGB information
setting of the three dimmer switches will produce a different supplied by devices such as cameras and scanners. Different
result, either in color or in brightness or both. This colour color spaces have historically evolved for different
mixer is also possible with the other colour spaces like applications. In each case, a color space was chosen for
CMYK, HSL, etc. application-specific reasons.
Digital cameras and scanners and create images using
combinations of just three colors: Red, Green and Blue
(RGB). These are the primary colors of visible light and this
how computers and televisions display images on their
screens. RGB colors often appear brighter and more vivid
specifically because the light is being projected directly into
the eyes of the viewer.
The CMYK color model (process color, four color) is a
subtractive color model, used in color printing, and is also
used to describe the printing process itself. CMYK refers to
the four inks used in some color printing: cyan, magenta,
yellow, and key black. Though it varies by print house,
press operator and press manufacturer
At some stages one colour spaces must be translated in to
other colour space. For example there is a need of printing
an image in a printing press it is best if you do the RGB to
CMYK Conversion of your images. You will have more
control over the appearance of your printed piece if you
convert all of the images from RGB to CMYK before
sending them to us. This concept of converting one space to
other spaces is also discussed in this paper
© JGRCS 2010, All Rights Reserved 44
Nishad PM et al, Journal of Global Research in Computer Science, 4 (1), January 2013, 44-48
The red, green and blue (RGB) color space is widely used
throughout computer graphics. Red, green and blue are three
primary additive colors: each color normally ranges from 0
to 255[3] that is R= {0, 1, 2 ….. 255}, G= {0, 1, 2 ….. 255}
and B= {0, 1, 2 ….. 255} shown in table-1, individual
components are added together to form a desired color, and
are represented by a three dimensional, RGB colour cube is
shown in Figure -1 and Chart -1. Figure -2 represents the
RGB Additive Colures.
Table -1 100% RGB Colour bar
CMYK COLOR SPACE
A CMYK color space is all possible colors that can be made
from four colourants for cyan, magenta, yellow, and key
black.
The “K” in CMYK stands for key since in four-color
printing cyan, magenta, and yellow printing plates are
In RGB Color cube each point represents the combination of carefully keyed or aligned with the key of the black key
the maximum and minimum emission of each primary. plate. Some sources suggest that the “K” in CMYK comes
When the amounts of three primaries (Red, Green and Blue) from the last letter in "black" and were chosen because B
are in minimum levels the black color is produced; when the already means blue.
amounts of three primaries are in maximum levels, the white
color is produced [1]. The basic rule of mixing in RGB color In the CMYK color system equal proportions of Yellow plus
cube is following Cyan produces Green, Yellow plus Magenta produces Red,
and Cyan ink plus Magenta produces Blue (actually more
R+G+B=White like purple to most eyes). Various color shades and values
R+G=Yellow are achieved by varying the relative amounts of the four
R+B=Magenta colors. Black is added to improve the quality of images. The
G+B=Cyan basic rule of mixing in RGB color cube is following
Using Red and Green and Blue in computer Graphics Can
create desired colors. However, RGB is not very efficient
when dealing with real-world images. All three components
need equal bandwidth to generate arbitrary colors within the
RGB color cube. Also, processing an image in the RGB
color space is usually not the most efficient method. For
example, to modify the intensity or color of a given pixel, all
three RGB values must be read, modified and written back
to the frame buffer. If the system had access to the image
stored in the intensity and color format, the process would
be faster. The equation-1 is used to find the color of a pixel.
Where C + Y = Green
W1= 1 C + M = Blue
W2= 256 M + Y =Red
W3= 65536 C+M+Y = Black
The CMYK color space is widely used in printing. Cyan,
Magenta and Yellow are three primary additive colors: each
color normally ranges from 0 to 255 that is M= {0, 1, 2 …..
255}, C= {0, 1, 2 ….. 255} and Y= {0, 1, 2 ….. 255} shown
in table-2, individual components are added together to form
a desired color, and are represented by a three dimensional,
RGB colour cube is shown in Figure -4 and Chart -2. Figure
-3 represents the CMYK Subtractive Colour
© JGRCS 2010, All Rights Reserved 45
Nishad PM et al, Journal of Global Research in Computer Science, 4 (1), January 2013, 44-48
Table -2 100% CMYK Colour Bars colorimetric purity. The lower the saturation of a color, the
more "grayness" is present and the more faded the color will
appear, thus useful to define de-saturations the qualitative
inverse of saturation
Brightness-The brightness of a color identifies how light or
dark the color is. Any color whose brightness is zero is
black, regardless of its hue or saturation. There are different
schemes for specifying a color's brightness and depending
on which one is used; the results of lightening a color can
vary considerably [4]. Ranges from 0-100%
This color space is based on a so-called hex-cone model
which can be visualized as a prism with a hexagon on one
end that tapers down to a single point at the other. The
hexagonal face of the prism is derived by looking at the
RGB cube centered on its white corner. The cube, when
viewed from this angle, looks like a hexagon with white in
the center and the primary and secondary colors making up
the six vertices of the hexagon. This color hexagon is the
one Picture Window uses in its color picker to display the
brightest possible versions of all possible colors based on
their hue and saturation. Successive cross sections of the
HSV hex-cone as it narrows to its vertex are illustrated
below showing how the colors get darker and darker,
eventually reaching black [3] [4].
HSL COLOR SPACE
The HSL color space, also called HLS or HIS or HSB. HSI
stands for Hue, Saturation, Lightness (also Luminance or
Luminosity) / Intensity/ Brightness.
Luminance- The luminance of a color is a measure of its
HSV COLOR SPACE perceived brightness. The computation of luminance takes
into account the fact that the human eye is far more sensitive
The HSV color space attempts to characterize colors to certain colors (like yellow-green) than to others (like
according to their hue, saturation, and value (brightness) blue) [4].
shown in Figure -4.
This color space is based on a double hexagon model which
Hue- The hue of a color identifies what is commonly called consists of a hexagon in the middle that converges down to a
“color”. For example, all reds have a similar hue value point at each end. Like the HSV color space, the HSL space
whether they are light, dark, intense, or pastel [4]. Ranges goes to black at one end, but unlike HSV, it tends toward
from 0-360 (but normalized to 0-100% in some white at the opposite end. The most saturated colors appear
applications). in the middle. Note that unlike in the HSL color space; this
central cross-section has 50% gray in the center and not
Saturation-The saturation of a color identifies how pure or white [4] [5].
intense the color is. A fully saturated color is deep and
brilliant as the saturation decreases, the color gets paler and YUV COLOR SPACE
more washed out until it eventually fades to neutral[4].
Ranges from 0-100%.Also sometimes called the "purity" by There are some drawbacks with this representation. For
analogy to the colorimetric quantities excitation purity and example, the brightness of a pixel may not be changed
© JGRCS 2010, All Rights Reserved 46
Nishad PM et al, Journal of Global Research in Computer Science, 4 (1), January 2013, 44-48
easily, as it must be computed from the RGB components. R = V0
These components must then be recalculated with the new H0 = H
intensity in order to obtain the same color, brighter. do Calc
Standard video signals like Phase Alternation Line [PAL], G = V0
National Television System Committee [NTSC] or H0 = H - 256/3
Sequential couleur avec memoire [SECAM] hence uses an do Calc
alternative colour scheme, YUV. The Y component B = V0
represents luminance, or intensity, which is suitable for end
black and white display devices. With the introduction of end
colour TV two additional signals, U and V were added to Calc routine
represent colour [6]. if H0 < 0
H0 += 255
COLOUR SPACE CONVERSIONS [6]. elsif H0 > 255
H0 -= 255
RGB to CMY: end
C = 255 − R if H0 < 255/6
M = 255 − G V0 = V1 + ((V2-V1)*H0 + 255/12)/(255/6)
Y = 255 − B elsif H0 < 128
V0 = V2
RGB to CMYK: elsif H0 < 255*2/3
C = 255 - Red V0 = V1 + ((V2-V1)*(255*2/3 - H0) + 255/12)/(255/6)
M = 255 - Green else
Y = 255 – Blue V0 = V1
K = Minimum (C, M, Y) end
CMY to CMYK: RGB to HSL:
K = Minimum (C, M, Y) Max = Maximum (R, G, B)
C = (C − K)/ (255 − K) Min = Minimum (R, G, B)
M = (M − K)/ (255 − K) if Max = Min
Y = (Y − K)/ (255 − K) H=0
S=0
CMYK to CMY: else
C = Minimum (255, C *(255 − K) + K) A1 = Max/255 + Min/255
M = Minimum (255, M * (255 − K) + K) S1 = Max/255 - Min/255
Y = Minimum (255, Y *(255 − K) + K) L = (Max + Min) / 2
if L < 128
RGB to YUV: S = (S1 / A1) * 255
K = 0.299 * R + 0.587 * G + 0.114 * B else
Y = Round (0.859 * K) + 16 S = (S1 / (2-S1) ) * 255
U = Round (0.496 * (B - K)) + 128 end
V = Round (0.627 * (R - K)) + 128 case Max
of R
YUV to RGB: H = ( (G - B)/255 / S1 ) * 60
R = Round (1.164383 * (Y-16) + 1.596027 * (V-128)) of G
G = Round (1.164383 * (Y-16) + 2.017232 * (U-128)) H = ( (2 + (B - R)/255) / S1 ) * 60
B= Round (1.164383 * (Y-16) - (0.391762 * (U-128)) - of B
(0.812968 * (V-128))) H = ( (4 + (R - G)/255) / S1 ) * 60
end
HSL to RGB: if H < 0
if L <> 0 H += 255
if S = 0 end
R=L end
G=L HSV to RGB:
B=L
else If S = 0 ! Shades of gray
if L <= 128 R= V
V2 = L * (255 + S) / 255 G=V
else B= V
V2= L + S - (L*S)/255 else ! color
end F0 = H/255*6 - int(H/255*6)
V1 = 2*L - V2 VS = V * S / 255
H0 = H + 256/3 P0 = V - int(VS)
do Calc Q0 = V - int(VS * F0)
© JGRCS 2010, All Rights Reserved 47
Nishad PM et al, Journal of Global Research in Computer Science, 4 (1), January 2013, 44-48
T0 = V - int(VS * (1-F0)) space conversion algorithms used to convert one space to
case int(H/255*6) other space.
of 0
R=V REFERENCES
G = T0
B = P0 [1]. Pesal Koirala Department of Computer Science and
of 1 Statistics University of Joensuu.- “RGB Color Spaces”
R = Q0 [2]. Danny Pascale -“A Review of RGB Color Spaces From
G = V0 xyY to RGB” (2000-2003)
B = P0
[3]. Darrin Cardani- “Adventures in HSV Space”
of 2
R = P0 [4]. Jonathan Sachs -“Digital Image Basics”
G=V [5]. Adrian Ford and Alan Roberts “Colour Space conversions”
B = T0 August 11, 1998
of 3 [6]. Etienne Dupuis -“Optimizing YUV-RGB Color Space
R = P0
Conversion Using Intel’s SIMD Technology”- August
G = Q0
2003
B=V
of 4 [7]. William David Wright, 50 years of the 1931 CIE Standard
R = T0 Observer. Die Farbe, 29:4/6 (1981).
G = P0 [8]. Dean Anderson. "Color Spaces in Frame Grabbers: RGB
B=V vs. YUV". Retrieved 2008-04-08.
of 5
R=V
Short Bio Data for the Author
G = P0
B = Q0
Nishad PM M.Sc., M.Phil. Seven months Worked
end
as a project trainee in Wipro in 2005, five years
end
experience in teaching, one and half year in JNASC and
RGB to HSV: Three and half year in MES Mampad College. He has
published eight papers national level/international
V = Maximum(R,G, B)
conference and journals. He has presented three seminars at
Delta = V - Minimum(R, G, B)
national Level. Now he is pursuing Ph.D Computer Science
S = choose(V=0, 0, Delta * 255 / V) in Dr. Mahalingam center for research and development at
if S = 0
NGM College Pollachi.
H=0
else Dr. R.Manicka chezian received his M.Sc., degree
if Red = V
in Applied Science from P.S.G College of
H0 = (Green - Blue) / Delta
Technology, Coimbatore, India in 1987. He completed his
elsif Green = V M.S. degree in Software Systems from Birla Institute of
H0 = 2 + (Blue-Red) / Delta
Technology and Science, Pilani, Rajasthan, India and Ph D
else degree in Computer Science from School of Computer
H0 = 4 + (Red-Green) / Delta Science and Engineering, Bharathiar University,
end
Coimbatore, India. He served as a Faculty of Maths and
If H0 < 0 Computer Applications at P.S.G College of Technology,
H0 += 6
Coimbatore from 1987 to 1989. Presently, he has been
end
working as an Associate Professor of Computer Science in
H = H0 * 255/6 N G M College (Autonomous), Pollachi under Bharathiar
End University, Coimbatore, India since 1989. He has published
thirty papers in international/national journal and
conferences: He is a recipient of many awards like Desha
CONCLUSION Mithra Award and Best Paper Award. His research focuses
A color space is all possible colors that can be made from a on Network Databases, Data Mining, Distributed
group of colorants. In this paper discussed about varies Computing, Data Compression, Mobile Computing, Real
colour spaces and how can produce different colours using Time Systems and Bio-Informatics.
different colour spaces. Also discussed the various colour
© JGRCS 2010, All Rights Reserved 48