RGB to HSV Color Converter

R
G
B
Hue (H)
Saturation (S)
Value (V)

RGB to HSV Color Converter

What is RGB to HSV Conversion?

RGB to HSV conversion is the process of transforming color representations from the RGB (Red, Green, Blue) color model to the HSV (Hue, Saturation, Value) color model. This conversion is useful for color manipulation and analysis, as HSV provides a more intuitive representation of color properties.

RGB Color Model

The RGB color model represents colors using three components:

  • Red (R): Amount of red, from 0 to 255.
  • Green (G): Amount of green, from 0 to 255.
  • Blue (B): Amount of blue, from 0 to 255.

HSV Color Model

The HSV color model represents colors using three components:

  • Hue (H): The color itself, represented as an angle from 0° to 360°.
  • Saturation (S): The intensity of the color, from 0% (gray) to 100% (full color).
  • Value (V): The brightness of the color, from 0% (black) to 100% (full brightness).

Conversion Formula

The conversion from RGB to HSV involves these steps:

1. Normalize RGB values:

\[ R' = R / 255, G' = G / 255, B' = B / 255 \]

2. Calculate Cmax, Cmin, and Δ:

\[ C_{max} = \max(R', G', B') \]

\[ C_{min} = \min(R', G', B') \]

\[ \Delta = C_{max} - C_{min} \]

3. Calculate Hue:

\[ H = \begin{cases} 0°, & \text{if } \Delta = 0 \\ 60° \times (\frac{G' - B'}{\Delta} \mod 6), & \text{if } C_{max} = R' \\ 60° \times (\frac{B' - R'}{\Delta} + 2), & \text{if } C_{max} = G' \\ 60° \times (\frac{R' - G'}{\Delta} + 4), & \text{if } C_{max} = B' \end{cases} \]

4. Calculate Saturation:

\[ S = \begin{cases} 0, & \text{if } C_{max} = 0 \\ \frac{\Delta}{C_{max}}, & \text{otherwise} \end{cases} \]

5. Calculate Value:

\[ V = C_{max} \]

Usage Example

Let's convert a vibrant blue color from RGB to HSV:

  • RGB: (0, 127, 255)
  • HSV: (210°, 100%, 100%)

Visual Representation

RGB HSV

This diagram shows the vibrant blue color represented in both RGB and HSV formats. The HSV representation provides a more intuitive understanding of the color's properties, with full saturation and value.