<A HREF="COL_.htm"><img align=center src="contents.gif" ALT="Contents"></A> Up Previous Next


HSI: Hue Saturation Intensity.

RGB to HSI (Gonzalez and Woods)

  I = 1/3(R+G+B)

  S = 1 - ( 3/(R+G+B))*a    where a is the minimum of R, G and B

  H = cos^(-1) ( (0.5*((R-G)+(R-B))) / ((R-G)^2 + (R-B)*(G-B))^(0.5) )

  If S = 0, H is meaningless.
    
  If (B/I) > (G/I) then H = 360 - H since H is an angle in degrees we
    then normalise to 0,1 with H=H/360

HSI to RGB (Gonzalez and Woods)

First we restore H to degrees with H = 360*H

  If 0 < H <= 120 then
    
      B = 1/3(1-S)
      R = 1/3(1+ [(S cos H) / (cos(60 - H))] )
      G = 1 - (B+R)

  If 120 < H <= 240 then

      H = H - 120
      R = 1/3(1-S)
      G = 1/3(1+ [(S cos H) / (cos(60 - H))] )
      B = 1 - (R+G)

  If 240 < H <= 360 then

      H = H - 240
      G = 1/3(1-S)
      B = 1/3(1+ [(S cos H) / (cos(60 - H))] )
      R = 1 - (G+B)