Color Manipulation
[Utilities]
Detailed Description
- Functions to convert from one color space to another, and color gammut utilities.
- See im_color.h
Some Color Science
- Y is luminance, a linear-light quantity. It is directly proportional to physical intensity weighted by the spectral sensitivity of human vision.
- L* is lightness, a nonlinear luminance that aproximates the perception of brightness. It is nearly perceptual uniform. It has a range of 0 to 100.
- Y' is luma, a nonlinear luminance that aproximates lightness.
- Brightness is a visual sensation according to which an area apears to exhibit more or less light. It is a subjective quantity and can not be measured.
- One unit of euclidian distante in CIE L*u*v* or CIE L*a*b* corresponds roughly to a just-noticeable difference (JND) of color.
ChromaUV = sqrt(u*u + v*v) HueUV = atan2(v, u) SaturationUV = ChromaUV / L (called psychometric saturation) (the same can be calculated for Lab)
- IEC 61966-2.1 Default RGB colour space - sRGB
- ITU-R Recommendation BT.709 (D65 white point).
- D65 White Point (X,Y,Z) = (0.9505 1.0000 1.0890)
- Documentation extracted from Charles Poynton - Digital Video and HDTV - Morgan Kaufmann - 2003.
Links
- www.color.org - ICC
- www.srgb.com - sRGB
- www.poynton.com - Charles Poynton
- www.littlecms.com - A free Color Management System (use this if you need precise color conversions)
Color Component Intervals
- All the color components are stored in the 0-max interval, even the signed ones.
Here are the pre-defined intervals for each data type. These values are used for standard color conversion. You should normalize data before converting betwwen color spaces.
byte [0,255] or [-128,+127] (1 byte) ushort [0,65535] or [-32768,+32767] (2 bytes) int [0,16777215] or [-8388608,+8388607] (3 bytes) float [0,1] or [-0.5,+0.5] (4 bytes)
Modules | |
HSI Color Coordinate System Conversions | |
Functions | |
float | imColorZero (int data_type) |
int | imColorMax (int data_type) |
template<class T> | |
T | imColorQuantize (const float &value, const T &max) |
template<class T> | |
float | imColorReconstruct (const T &value, const T &max) |
template<class T> | |
void | imColorYCbCr2RGB (const T Y, const T Cb, const T Cr, T &R, T &G, T &B, const T &zero, const T &max) |
template<class T> | |
void | imColorRGB2YCbCr (const T R, const T G, const T B, T &Y, T &Cb, T &Cr, const T &zero) |
template<class T> | |
void | imColorCMYK2RGB (const T C, const T M, const T Y, const T K, T &R, T &G, T &B, const T &max) |
template<class T> | |
void | imColorXYZ2RGB (const T X, const T Y, const T Z, T &R, T &G, T &B, const T &max) |
template<class T> | |
void | imColorRGB2XYZ (const T R, const T G, const T B, T &X, T &Y, T &Z) |
void | imColorXYZ2Lab (const float X, const float Y, const float Z, float &L, float &a, float &b) |
void | imColorLab2XYZ (const float L, const float a, const float b, float &X, float &Y, float &Z) |
void | imColorXYZ2Luv (const float X, const float Y, const float Z, float &L, float &u, float &v) |
void | imColorLuv2XYZ (const float L, const float u, const float v, float &X, float &Y, float &Z) |
float | imColorTransfer2Linear (const float &nonlinear_value) |
float | imColorTransfer2Nonlinear (const float &value) |
void | imColorRGB2RGBNonlinear (const float RL, const float GL, const float BL, float &R, float &G, float &B) |
template<class T> | |
T | imColorRGB2Luma (const T R, const T G, const T B) |
float | imColorLuminance2Lightness (const float &Y) |
float | imColorLightness2Luminance (const float &L) |
Function Documentation
|
|
Returns the maximum value for color conversion porpouses.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Converts RGB (linear) to R'G'B' (nonlinear). 00405 { 00406 R = imColorTransfer2Nonlinear(RL); 00407 G = imColorTransfer2Nonlinear(GL); 00408 B = imColorTransfer2Nonlinear(BL); 00409 }
|
|
Converts R'G'B' to Y' (all nonlinear). Y' = 0.299 *R' + 0.587 *G' + 0.114 *B'
|
|
Converts Luminance (CIE Y) to Lightness (CIE L*) (all linear). 0 <= Y <= 1 ; 0 <= L* <= 1 Y = Y / 1.0 (for D65) if (Y > 0.008856) fY = pow(Y, 1/3) else fY = 7.787 * Y + 0.16/1.16 L = 1.16 * fY - 0.16
|
|
Converts Lightness (CIE L*) to Luminance (CIE Y) (all linear). 0 <= Y <= 1 ; 0 <= L* <= 1 fY = (L + 0.16)/1.16 if (fY > 0.20689) Y = pow(fY, 3) else Y = 0.1284 * (fY - 0.16/1.16) Y = Y * 1.0 (for D65)
|