Conversion of color models
Equations to Convert RGB Values to HSI Values….
Suppose R, G, and B are the red, green, and blue values of a
color. The HSI intensity is given by the equation
I = (R + G + B)/3.
Now let m be the minimum value among R, G, and B. The HSI
saturation value of a color is given by the equation
S = 1 - m/I if I > 0, or
S=0 if I = 0.
To convert a color's overall hue, H, to an angle measure, use the
following equations:
ifG ≥ B
ifG ≥ B ifd ifG ≥ B
OR
if B>G
where the inverse cosine output is in degrees.
Convert RGB values to HSI…..
R=24 G=98 B=118
R= 24/255=0.09 G=98/255= 0.38 B=118/255 = 0.46
HSI
I :- 1/3(R+G+B) = 1/3 *(0.09+0.38+0.46)
I= 0.93/3 = 0.31
S = 1- 3/R+G+B min(R,G,B)
S = 1-3/0.09+0.38+0.46 min(0.09,0.38,0.46)
S = 1 – 0.09/0.31 = 1-0.29 = 0.71
θ , B<=G
H=
360- θ , B>G
H = 360- Cos -1
1/2 (R-G) + (R-B)
(R-B) 2
+ (R-B)(G-B)
1/2 (0.09-0.38) +(0.09-0.46)
Θ= Cos-1
(0.09 – 0.46) 2 +(0.09 -0.46)(0.38-0.46)
Θ = Cos-1 (-0.33/0.33)
Cos -1(-1) = 180°
H = 360° -θ = 360-180=180°
Equations to convert RGB values to HSI values..
To convert hue,saturation, and intensity to a set of red,green, and
blue values, you must first note the value of H. if H=0, then R,G
and B are given
R = I + 2IS
G = I - IS
B = I - IS.
If 0 < H < 120, then
R = I + IS*cos(H)/cos(60-H)
G = I + IS*[1 - cos(H)/cos(60-H)]
B = I - IS.
If H = 120, then the red, green, and blue values are
R = I - IS
G = I + 2IS
B = I - IS.
•If 120 < H < 240, then
R = I - IS
G = I + IS*cos(H-120)/cos(180-H)
B = I + IS*[1 - cos(H-120)/cos(180-H)].
If H = 240 then
R = I - IS
G = I - IS
B = I + 2IS.
And if 240 < H < 360, we have
R = I + IS*[1 - cos(H-240)/cos(300-H)]
G = I - IS
B = I + IS*cos(H-240)/cos(300-H)
Convert HSI into RGB………
If 120<H<240
•R= I-IS= 0.31-0.31*0.71=0.899
•G= I + IS*cos(H-120)/cos(180-H)=
0.31+0.31*0.71*cos(180-120)/cos(180-120)=0.530
•B= I + IS*[1 - cos(H-120)/cos(180-H)] =
0.31+(0.31*0.71)[1-cos(180-120)/cos(180-180)]= 0.82
RGB to CMYK conversion formula
R' = R/255
G' = G/255
B' = B/255
The black key (K) color is calculated from the red (R'), green (G') and
blue (B') colors:
K = 1-max(R', G', B')
The cyan color (C) is calculated from the red (R') and black (K)
colors:
C = (1-R'-K) / (1-K)
The magenta color (M) is calculated from the green (G') and black
(K) colors:
M = (1-G'-K) / (1-K)
The yellow color (Y) is calculated from the blue (B') and black (K)
colors:
Y = (1-B'-K) / (1-K)
CMYK to RGB conversion formula
The R,G,B values are given in the range of 0..255.
The red (R) color is calculated from the cyan (C) and black (K)
colors:
R = 255 × (1-C) × (1-K)
The green color (G) is calculated from the magenta (M) and
black (K) colors:
G = 255 × (1-M) × (1-K)
The blue color (B) is calculated from the yellow (Y) and black
(K) colors:
B = 255 × (1-Y) × (1-K)
Convert RGB values into CMY
R=29/255=0.113
G=98/255=0.384
B=128/255=0.501
Cyan= 1-0.113 = 0.887
Mangeta = 1-0.384 = 0.616
Yellow = 1-0.501= 0.499
RGB(0.113,0.384,0.501) CMY(0.98,0.616,0.499)
Convert CMY to RGB……
Cyan= 0.887
Mangeta = 0.616
Yellow = 0.499
R=1-0.887= 0.113
G=1-0.616= 0.384
B=1-0.499= 0.501
CMY(0.98,0.616,0.499) RGB(0.113,0.384,0.501