Image Processing Reference
In-Depth Information
for
(y = 0;
y < M;
y = y+1)
{
for
(x = 0;
x < N;
x = x+1)
{
temp
= 3
GetPixel ( input ,x ,y , I );
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
=
(1
GetPixel ( input ,
x ,
y ,
r )
GetPixel ( input ,
x ,
y ,
g ))
temp ;
SetPixel ( output ,
x,
y, B,
value );
}
}
where M is the height of the image, N is the width of the image, input is the rgI
image, and output is the RGB image.
3.3
Other Color Representations
From a human perception point of view the triangular representation in 3.10 (b) is
not intuitive. Instead humans rather use the notion of hue and saturation , when
perceiving colors. The hue is the dominant wavelength in the perceived light and
represents the pure color, i.e., the colors located on the edges of the triangle in
Fig. 3.10 (b). The saturation is the purity of the color and represents the amount of
white light mixed with the pure color. To understand these entities better, let us look
at Fig. 3.11 (a). First of all we see that the point C corresponds to the neutral point,
meaning the colorless center of the triangle where (r, g)
( 1 / 3 , 1 / 3 ) . Let us define
a random point in the triangle as P . The hue of this point is now defined as an angle,
θ , between the vectors −−→
=
C r = 1 and CP . So hue
=
0° means red and hue = 120° means
green.
If the point P is located on the edge of the triangle then we say the saturation
is 1, hence a pure color. As the point approaches C the saturation goes toward 0,
and ultimately becomes 0 when P
C . Since the distance from C to the three
edges of the triangle is not uniform, the saturation is defined as a relative distance.
That is, saturation is defined as the ratio between the distance from C to P , and
the distance from C to the point on the edge of the triangle in the direction of CP .
Mathematically we have
=
CP
−− CP
=
=
Saturation
,
Hue
θ
(3.7)
is the length of the vector CP . The representation of colors based
on hue and saturation results in a circle as opposed to the triangle in Fig. 3.10 (b).
In Fig. 3.11 (b) the hue-saturation representation is illustrated together with some of
CP
where
Search WWH ::




Custom Search