0% found this document useful (0 votes)
267 views3 pages

RGB To HSI

The document describes the process to convert between RGB and HSI color spaces. It involves first normalizing RGB values between 0-1, then calculating Hue (H), Saturation (S) and Intensity (I) components. Hue is calculated using inverse cosine functions of normalized color differences. Saturation is calculated as 1 minus the minimum normalized value. Intensity is the average of normalized R, G, B. The HSI values are then converted to ranges of 0-360 for Hue, 0-100 for Saturation and 0-255 for Intensity. The reverse conversion calculates normalized x, y, z components from HSI and assigns them to R, G, B based on the Hue value.

Uploaded by

Ghurucharan Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
267 views3 pages

RGB To HSI

The document describes the process to convert between RGB and HSI color spaces. It involves first normalizing RGB values between 0-1, then calculating Hue (H), Saturation (S) and Intensity (I) components. Hue is calculated using inverse cosine functions of normalized color differences. Saturation is calculated as 1 minus the minimum normalized value. Intensity is the average of normalized R, G, B. The HSI values are then converted to ranges of 0-360 for Hue, 0-100 for Saturation and 0-255 for Intensity. The reverse conversion calculates normalized x, y, z components from HSI and assigns them to R, G, B based on the Hue value.

Uploaded by

Ghurucharan Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

FORMULAE

RGB to HSI Conversion:


First, we convert RGB color space image to HSI space beginning with normalizing RGB values:
r=

B
R
G
,g =
, b=
.
R+G+ B
R+G + B
R+G+ B

Each normalized H, S and I components are then obtained by,

0.5 ( r g ) + ( r b )
h = cos
1
( r g ) 2 + ( r b )( g b ) 2

h [0, ] for b g

0.5 ( r g ) + ( r b )
h = 2 cos1
1
( r g )2 + ( r b )( g b ) 2

s = 1 3 min( r , g , b ) ;

h [ , 2 ] for b > g

s [0,1]

i = ( R + G + B ) /(3 255) ;

i [0,1] .

For convenience, h, s and i values are converted in the ranges of [0,360], [0,100], [0, 255], respectively ,
by:

H = h 180 / ;

I = i 255 .

S = s 100 and

HSI to RGB Conversion:


h = H /180 ;

s = S / 100 ;

i = I / 255

x = i (1 s )

s cos( h )
y = i 1 +
cos ( / 3 h )

z = 3i ( x + y );
when h < 2 / 3 , b = x ; r = y and g = z.
when 2 / 3 h < 4 / 3 , h = h 2 / 3 , and r = x ; g = y and b = z.
when 4 / 3 h < 2 , h = h 4 / 3 , and g = x ; b = y and r = z.
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:


(150, 0, 0)
(0,150, 0)
(100,100,100)

(255, 255, 255)


(0, 0, 0)
(255, 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:
r=

B
R
G
= 0.444
= 0.222 , g =
= 0.333 , b =
R+G+ B
R+G+ B
R+G+ B

2. Here b > g, so we compute H value by equation:

0.5 ( r g ) + ( r b )
h = 2 cos
= 1.167
1
( r g )2 + ( r b )( g b ) 2

Compute S value by:

s = 1 3 min( r , g , b ) = 0.333

3. Represent H,S,I values in the ranges of [0,360], [0,100] and [0, 255]:
4.
H = h 180 / = 210
S = s 100 = 33.3

I = ( R + G + B ) / 3 = 150
HSI to RGB Conversion

5. h = H / 1 8 0 = 7 / 6 ; s = S / 100 = 0.333 ; i = I / 255 = 0.588

6. When 2 / 3 h < 4 / 3 , we use following formulae


h = h 2 / 3 = / 2 ,

r = x = i (1 s ) = 0.392

s cos(h)
g = y = i 1 +
= 0.588
cos ( / 3 h )
b = z = 3i ( x + y)
7. To represent R,G,B values in the ranges of [0,255], [0,255] and [0, 255]:
8.
R = 255 r = 100
G = 255 g = 150
B = 255 b = 200

You might also like