On this page
RGB and HSV RGB to HSV C references chroma.
V = m a x ( R , G , B ) C = V − m i n ( R , G , B ) S = { 0 if V = 0 C V otherwise H = { 0 if V = 0 G − B C if V = R B − R C if V = G R − G C if V = B \begin{align*} V &= max(R,G,B) \\ \:\\ C &= V - min(R,G,B) \\ \:\\ S &= \begin{cases} 0 & \text{ if } V = 0 \\ \frac{C}{V} & \text{ otherwise } \end{cases} \\ \:\\ H &= \begin{cases} 0 & \text{ if } V = 0 \\ \frac{G - B}{C} & \text{ if } V = R \\ \frac{B - R}{C} & \text{ if } V = G \\ \frac{R - G}{C} & \text{ if } V = B \\ \end{cases} \end{align*} V C S H = ma x ( R , G , B ) = V − min ( R , G , B ) = { 0 V C if V = 0 otherwise = ⎩ ⎨ ⎧ 0 C G − B C B − R C R − G if V = 0 if V = R if V = G if V = B HSV to RGB p = V ⋅ ( 1 − S ) q = V ⋅ ( 1 − S ⋅ H ) t = V ⋅ ( 1 − S ⋅ ( 1 − H ) ) ( R , G , B ) = { ( V , V , V ) if S = 0 ( V , t , p ) if H < 1 ( q , V , p ) if 1 < H ≤ 2 ( p , V , t ) if 2 < H ≤ 3 ( p , q , V ) if 3 < H ≤ 4 ( t , p , V ) if 4 < H ≤ 5 ( V , p , q ) otherwise \begin{align*} p &= V \cdot (1 - S) \\ q &= V \cdot (1 - S \cdot H) \\ t &= V \cdot (1 - S \cdot (1 - H)) \\ \:\\ (R,G,B) &= \begin{cases} (V,V,V) & \text{ if } S = 0 \\ (V,t,p) & \text{ if } H < 1 \\ (q,V,p) & \text{ if } 1 < H \leq 2 \\ (p,V,t) & \text{ if } 2 < H \leq 3 \\ (p,q,V) & \text{ if } 3 < H \leq 4 \\ (t,p,V) & \text{ if } 4 < H \leq 5 \\ (V,p,q) & \text{ otherwise } \\ \end{cases} \end{align*} p q t ( R , G , B ) = V ⋅ ( 1 − S ) = V ⋅ ( 1 − S ⋅ H ) = V ⋅ ( 1 − S ⋅ ( 1 − H )) = ⎩ ⎨ ⎧ ( V , V , V ) ( V , t , p ) ( q , V , p ) ( p , V , t ) ( p , q , V ) ( t , p , V ) ( V , p , q ) if S = 0 if H < 1 if 1 < H ≤ 2 if 2 < H ≤ 3 if 3 < H ≤ 4 if 4 < H ≤ 5 otherwise