Cv2.cvtColor
lastmod 2023-01-10created 2023-01-103 edits
Color space codes
| Property | Meaning | Notes |
| BGR | Blue, Green, Red channels | - |
| BGRA | Blue, Green, Red, Alpha channels | - |
| RGB | Red, Green, Blue channels | - |
| RGBA | Red, Green, Blue, Alpha channels | - |
| GRAY | Single channel | Grayscale |
| BGR565 | Blue, Green, Red channels | 16-bit image |
| XYZ | X, Y, Z channels | CIE 1931 color space |
| YCrCb | Y, Cr, Cb channels | YCC (chroma) |
| HSV | Hue, Saturation, Value channels | Hue, saturation, value |
| Lab | L, a, b channels | Reflectance, chromaticity 1, chromaticity 2 |
| Luv | L, u, v channels | CIE Luv |
| HLS | Hue, Lightness, Saturation channels | Hue, lightness, saturation |
| YUV | Y, U, V channels | Luminance, chrominance 1, chrominance 2 |
| BG, GB, RG | Demosaicing | Convert to a single color space |
| _EA | Demosaicing | Edge-aware |
| _VNG | Demosaicing | Uses gradients |
HSV caveats
When converting to HSV, the color ranges are as follows:
- hue range is [0,179]
- saturation range is [0,255]
- value range is [0,255]
Different software use different scales. So if you are comparing OpenCV values with them, you need to normalize these ranges.