CGVIS Utils
Loading...
Searching...
No Matches
ColorConversion.h File Reference

Color space conversion helpers among RGB/HSV/HSL/CMY/CMYK/YUV. More...

#include "Vec3.h"
#include "Vec4.h"
#include "Mat4.h"
Include dependency graph for ColorConversion.h:

Go to the source code of this file.

Namespaces

namespace  ColorConversion

Functions

template<typename T>
Vec3t< T > ColorConversion::rgbToHsv (const Vec3t< T > &other)
 Convert linear RGB to HSV.
template<typename T>
Vec3t< T > ColorConversion::hsvToRgb (const Vec3t< T > &other)
 Convert HSV to linear RGB.
template<typename T>
Vec3t< T > ColorConversion::hslToHsv (const Vec3t< T > &other)
 Convert HSL to HSV.
template<typename T>
Vec3t< T > ColorConversion::hsvToHsl (const Vec3t< T > &other)
 Convert HSV to HSL.
template<typename T>
Vec3t< T > ColorConversion::rgbToCmy (const Vec3t< T > &other)
 Convert RGB to CMY.
template<typename T>
Vec4t< T > ColorConversion::rgbToCmyk (const Vec3t< T > &other)
 Convert RGB to CMYK.
template<typename T>
Vec3t< T > ColorConversion::cmyToRgb (const Vec3t< T > &other)
 Convert CMY to RGB.
template<typename T>
Vec3t< T > ColorConversion::cmykToRgb (const Vec4 &other)
 Convert CMYK to RGB.
template<typename T>
Vec3t< T > ColorConversion::rgbToYuv (const Vec3t< T > &other)
 Convert RGB to a simple YUV (luma/chroma) space via a linear matrix.
template<typename T>
Vec3t< T > ColorConversion::yuvToRgb (const Vec3t< T > &other)
 Convert the simple YUV (above) back to RGB.

Detailed Description

Color space conversion helpers among RGB/HSV/HSL/CMY/CMYK/YUV.

Header‑only collection of small, templated utilities for converting colors between common color spaces. The functions are written for generic scalar component types (e.g., float, double) and operate on the project's vector and matrix types (Vec3t/Vec4t/Mat4t).

Unless stated otherwise, inputs are expected in the following ranges:

  • RGB/CMY components in [0,1],
  • HSV/HSL use hue in degrees [0,360) and saturation/value/lightness in [0,1],
  • YUV components follow the simple linear transforms defined below (not BT.601).