Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
=
`
(
+
)
(
[0, ] h for b g
( ) ( )
( ) ( )( )
1
1
2 2
0.5
2 cos
r g r b
h
r g r b g b
=
(
+
)
(
`
[ , 2 ] h for b g >
) , , min( 3 1 b g r s = ; [0,1] s
( ) /(3 255) i R G B = + + ; i . [0,1]
For convenience, h, s and i values are converted in the ranges of [0,360], [0,100], [0, 255], respectively ,
by:
180 / H h = ; and 100 S s = 255 I i = .
HSI to RGB Conversion:
/ 1 8 0 h H = ; ; i 100 / S s = 255 / I =
) 1 ( s i x =
( )
(
+ =
h
h s
i y
3 / cos
) cos(
1
); ( 3 y x i z + =
when 3 / 2 < h , b x = ; y r = and . z g =
when 2 3 / 4 3 / < h , 3 / 2 = h h , and x r = ; y g = and . z b =
when 2 3 / < h 4 , 3 / 4 = h h , and x g = ; y b = and . z r =
The result r, g and b are normalized values, which are in the ranges of [0,1], therefore, they should be
multiplied by 255 for displaying.
Example: An image is shown here:
With RGB values as:
(100,100,100) (150, 0, 0) (0,150, 0)
(255, 0, 0) (255, 255, 255) (0, 0, 0)
(100,150, 200) (0, 0, 255) (100, 200,150)
| |
|
|
|
\ .
RGB to HSI Conversion:
To compute HSI value of pixel (100,150,200)
1. Normalize:
0.222
R
r
R G B
= =
+ +
,
0.333
G
g
R G B
= =
+ +
,
0.444
B
R G B
= =
+ +
b
2. Here b > g, so we compute H value by equation:
( ) ( )
( ) ( )( )
1
1
2 2
0.5
2 cos 1.167
r g r b
h
r g r b g b
+ (
= =
`
(
+
)
Compute S value by:
1 3 min( , , ) 0.333 s r g b = =
3. Represent H,S,I values in the ranges of [0,360], [0,100] and [0, 255]:
4.
180/ 210 H h = =
100 33.3 S s = =
( ) / 3 150 I R G B = + + =
HSI to RGB Conversion
5. / 1 8 0 7 / 6 h H = = ; / 100 0.333 s S = = ; / 255 0.588 i I = =
6. When 3 / 4 3 / 2 < h , we use following formulae
2 / 3 / 2 h h = = ,
(1 ) 0.392 r x i s = = =
( )
cos( )
1 0.588
cos / 3
s h
g y i
h
(
= = + =
(
3 ( b z i x y) = = +
7. To represent R,G,B values in the ranges of [0,255], [0,255] and [0, 255]:
8.
255 100 R r = =
255 150 G g = =
255 200 B b = =