next up previous
Next: Conversion from HSI to Up: ColorProcessing Previous: Color Models

Conversion from RGB to HSI

Given the intensities of the three primaries $R$, $G$, and $B$ of a color, we can find its HSV representation using different models. Here we use the RGB plane of the cube to find the corresponding HSV. The three vertices are represented by $P_r=(1,0,0)$, $P_g=(0,1,0)$ and $P_b=(0,0,1)$, and the three components of the given color is represented by a point ${\bf P}=(R,G,B)$ in the RGB 3-D space. Here we assume the intensities are normalized so that the $R$, $G$ and $B$ values are between 0 and 1, and point $P$ is inside or on the surface of the color cube.

RGB_model_2.gif

In summary, given the R, G, and B components of a color in the cubic color model, we can find the H, S, and I values by:

\begin{displaymath}I=(R+G+B)/3 \end{displaymath}


\begin{displaymath}H=\cos^{-1}\left(\frac{(R-G)+(R-B)}{2\sqrt{(R-G)^2+(R-B)(G-B)}}\right) \end{displaymath}


\begin{displaymath}S=1-3\;\min(R, G B)/I \end{displaymath}

RGB2HSIcode.gif

Note that before the RGB to HSI conversion, we need to normalize the R, G, and B components of a pixel in a color image from the range of $(0,\;255)$ to $(0,\;1)$.


next up previous
Next: Conversion from HSI to Up: ColorProcessing Previous: Color Models
Ruye Wang 2014-10-10