Image Processing Reference
In-Depth Information
RGB values, then we can easily find the remaining value, or in other words, we can
represent a normalized RGB color using just two of the values. Say we choose r and
g , then this corresponds to representing the triangle in Fig. 3.10 (a) by the triangle
to the right, see Fig. 3.10 (b). This triangle is denoted the chromaticity plane and the
colors along the edges of the triangle are the so-called pure colors. The further away
from the edges the less pure the color and ultimately the center of the triangle has
no color at all and is a shade of gray. It can be stated that the closer to the center a
color is, the more “polluted” a pure color is by white light.
Summing up we can now re-represent an RGB value by its “ true ” color, r and g ,
and the amount of light (intensity or energy or illumination) in the pixel. That is,
(R,G,B)
(r,g,I)
(3.6)
3 . In Table 3.3 the rgI values of some RGB values are shown. 3
Separating the color and the intensity like this can be a powerful notion in many
applications. In Sect. 4.4.1 one will be presented.
In terms of programming the conversion from (R,G,B) to (r,g,I) can be im-
plemented in C-Code as illustrated below:
R
+
G
+
B
where I
=
for
(y = 0;
y < M;
y = y+1)
{
for
(x = 0;
x < N;
x = x+1)
{
temp =
GetPixel ( input ,
x ,
y ,
R)
+
GetPixel ( input ,
x ,
y , G)
+
GetPixel ( input ,
x ,
y ,
B);
value
=
GetPixel ( input ,
x ,
y ,
R)
/
temp ;
SetPixel ( output ,
x,
y,
r ,
value );
value
=
GetPixel ( input ,
x ,
y , G)
/
temp ;
SetPixel ( output ,
x,
y,
g,
value );
value = temp / 3;
SetPixel ( output ,
x,
y,
I ,
value );
}
}
where M is the height of the image, N is the width of the image, input is the RGB
image, and output is the rgI image. The programming example primarily consists
of two FOR-loops which go through the image, pixel-by-pixel, and convert from an
input image (RGB) to an output image (rgI). The opposite conversion from (r,g,I)
to (R,G,B) can be implemented as
3 If r and g need to be represented using one byte for each color we can simply multiply each with
255 and the new values will be in the interval
[
]
0 , 255
.
Search WWH ::

Custom Search