How RGB to HSV conversion works
HSV reads RGB as a position on a colour-picker: value is the strongest channel, saturation is how much weaker the weakest channel is (relative to the strongest), and hue comes from the channel order. Because value only depends on one channel, HSV is quick to compute and popular in graphics code.
- R′, G′, B′ = channel ÷ 255.
- V = max(R′, G′, B′).
- S = (V − min(R′, G′, B′)) ÷ V, or 0 when V = 0.
- H as for HSL: based on which channel equals V.
- Report H in degrees, S and V in percent.
Worked example: rgb(0, 144, 255) to HSV
Here is the converter's own calculation for rgb(0, 144, 255), step by step. The result, hsv(206, 100%, 100%), is exactly what the tool above shows for this input.
- R′ = 0 ÷ 255 = 0, G′ = 0.565, B′ = 1.
- Cmax = 1, Cmin = 0, Δ = 1.
- V = Cmax = 1.
- S = Δ ÷ V = 1.
- Blue is largest: H = 60° × ((0 − 0.565) ÷ 1 + 4) = 206.1°.
- Rounded:
hsv(206, 100%, 100%).
Radix Colors, step 9 in RGB and HSV
Step 9 (the solid background step) of each Radix Colors scale in light mode.
| Colour | RGB | HSV |
|---|---|---|
| amber | rgb(255, 197, 61) | hsv(42, 76%, 100%) |
| blue | rgb(0, 144, 255) | hsv(206, 100%, 100%) |
| brown | rgb(173, 127, 88) | hsv(28, 49%, 68%) |
| crimson | rgb(233, 61, 130) | hsv(336, 74%, 91%) |
| cyan | rgb(0, 162, 199) | hsv(191, 100%, 78%) |
| grass | rgb(70, 167, 88) | hsv(131, 58%, 65%) |
| gray | rgb(141, 141, 141) | hsv(0, 0%, 55%) |
| green | rgb(48, 164, 108) | hsv(151, 71%, 64%) |
| indigo | rgb(62, 99, 221) | hsv(226, 72%, 87%) |
| iris | rgb(91, 91, 214) | hsv(240, 57%, 84%) |
| jade | rgb(41, 163, 131) | hsv(164, 75%, 64%) |
| lime | rgb(189, 238, 99) | hsv(81, 58%, 93%) |
| mint | rgb(134, 234, 212) | hsv(167, 43%, 92%) |
| orange | rgb(247, 107, 21) | hsv(23, 91%, 97%) |
| pink | rgb(214, 64, 159) | hsv(322, 70%, 84%) |
| plum | rgb(171, 74, 186) | hsv(292, 60%, 73%) |
| purple | rgb(142, 78, 198) | hsv(272, 61%, 78%) |
| red | rgb(229, 72, 77) | hsv(358, 69%, 90%) |
| ruby | rgb(229, 70, 102) | hsv(348, 69%, 90%) |
| sky | rgb(124, 226, 254) | hsv(193, 51%, 100%) |
| teal | rgb(18, 165, 148) | hsv(173, 89%, 65%) |
| tomato | rgb(229, 77, 46) | hsv(10, 80%, 90%) |
| violet | rgb(110, 86, 207) | hsv(252, 58%, 81%) |
| yellow | rgb(255, 230, 41) | hsv(53, 84%, 100%) |
Source: Radix Colors 3.0
Precision test: every RGB value through the converter
Over all 16,777,216 RGB colours the converter produced 2,475,339 distinct HSV values; 12.188% of colours came back exactly after RGB → HSV → RGB, the worst 3 levels off (#0073FB → #0070FA), the average 0.9896.
Method: every whole-number RGB value, through the converter's own code and back, compared on the 0–255 scale (how we test).
| Measure | Result |
|---|---|
| RGB values tested | 16,777,216 |
| Distinct HSV results | 2,475,339 |
| Came back exactly | 12.188% |
| Largest change (0–255 levels) | 3 |
| Average change | 0.9896 |
Last updated · Source: Pixohub exhaustive test of lib/color-math.ts
Where you'll use RGB to HSV
Colour pickers and sliders
Most picker widgets (including the browser's own <input type=color> on many platforms) present an HSV square. Converting a known RGB tells you where to put the handles.
Image processing
OpenCV's cv2.cvtColor(img, cv2.COLOR_BGR2HSV) is the standard first step for colour-based masking, such as picking out a green screen. Note OpenCV stores H as 0–179 and S, V as 0–255 for 8-bit images.
Shaders and game engines
Unity's Color.RGBToHSV and many shader snippets use HSV to shift hue or desaturate without changing brightness.
Common mistakes
- Comparing OpenCV HSV values with this page: OpenCV halves hue (0–179) and scales S and V to 0–255.
- Thinking V = 100% means white. rgb(0, 144, 255) has V = 100% because blue is at full strength.
- Using HSV saturation in CSS
hsl(): the formulas differ, so the colour will change. - Calculating with 0–255 values and forgetting to divide by 255 first, which gives V above 1.