Lumiverse  2.5
A framework for creating lighting control applications
Functions
Lumiverse::ColorUtils Namespace Reference

Utility functions for color calculations that aren't essential to LumiverseColor. More...

Functions

double blackbodySPD (unsigned int nm, unsigned int temp)
 Returns the value of a blackbody spectral power distribution at the given wavelength at the given color temperature. More...
 
Eigen::Vector3d getApproxColor (string gel, float intens=1.0f)
 Gets the XYZ coordinates of a gel color at a specified intensity. More...
 
Eigen::Vector3d getXYZTemp (unsigned int temp)
 Returns the Y-normalized XYZ coordinates of a blackbody radiator with the specified temperature.
 
Eigen::Vector3d getScaledColor (string gel, float intens=1.0f)
 Gets the Y-normalized XYZ coordinates of a gel color at a specified intensity. More...
 
Eigen::Vector3d convXYZtoRGB (Eigen::Vector3d color, RGBColorSpace cs=sRGB)
 Converts an XYZ value to a RGB value using the specified color space. More...
 
Eigen::Vector3d convRGBtoXYZ (Eigen::Vector3d rgb, RGBColorSpace cs=sRGB)
 Converts RGB to XYZ using the specified color space.
 
Eigen::Vector3d convRGBtoXYZ (double r, double g, double b, RGBColorSpace cs)
 
Eigen::Vector3d convXYZtoxyY (Eigen::Vector3d color)
 Converts an XYZ color to an xyY color.
 
Eigen::Vector3d convXYZtoLab (Eigen::Vector3d xyz, ReferenceWhite rw=D65)
 Convert XYZ to Lab with given reference white.
 
Eigen::Vector3d convXYZtoLab (Eigen::Vector3d xyz, Eigen::Vector3d rw)
 
double labf (double val)
 Lab helper function.
 
Eigen::Vector2d convxytouv (Eigen::Vector3d xyY)
 Converts an xy(Y) color to a u', v' pair. More...
 
Eigen::Vector2d convuvtoxy (Eigen::Vector2d uv)
 Converts (u',v') to (x, y) coordinates.
 
Eigen::Vector3d convXYZtoLUV (Eigen::Vector3d XYZ, ReferenceWhite rw=D50)
 Converts XYZ to L*u*v*. More...
 
Eigen::Vector3d convXYZtoLUV (Eigen::Vector3d XYZ, Eigen::Vector3d rw)
 Converts XYZ to L*u*v* using an arbitrary reference white.
 
Eigen::Vector3d convLUVtoXYZ (Eigen::Vector3d LUV, ReferenceWhite rw=D50)
 Converts L*u*v* to XYZ. More...
 
Eigen::Vector3d convLUVtoXYZ (Eigen::Vector3d LUV, Eigen::Vector3d rw)
 Converts L*u*v* to XYZ using an arbitrary reference white.
 
Eigen::Vector3d normalizeRGB (Eigen::Vector3d rgb)
 Takes an RGB value and normalizes it to the range [0,1]. More...
 
double clamp (double val, double min, double max)
 Clamps a value between a min and a max.
 
double sRGBtoXYZCompand (double val)
 sRGB value companding function for RGB to XYZ
 
double XYZtosRGBCompand (double val)
 sRGB value companding cuntion for XYZ to RGB
 
double getTotalTrans (string gel)
 Gets the total transparency of a gel or multiple gels.
 

Detailed Description

Utility functions for color calculations that aren't essential to LumiverseColor.

Function Documentation

double Lumiverse::ColorUtils::blackbodySPD ( unsigned int  nm,
unsigned int  temp 
)

Returns the value of a blackbody spectral power distribution at the given wavelength at the given color temperature.

Uses formula from http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_Lab.html

Parameters
nmWavelength in nanometers
tempTemperature in Kelvin
Returns
SPD at the given wavelength
Eigen::Vector3d Lumiverse::ColorUtils::convLUVtoXYZ ( Eigen::Vector3d  LUV,
ReferenceWhite  rw = D50 
)

Converts L*u*v* to XYZ.

Default refernce white is D50

Eigen::Vector2d Lumiverse::ColorUtils::convxytouv ( Eigen::Vector3d  xyY)

Converts an xy(Y) color to a u', v' pair.

Note that the Y parameter of the input is thrown out.

Eigen::Vector3d Lumiverse::ColorUtils::convXYZtoLUV ( Eigen::Vector3d  XYZ,
ReferenceWhite  rw = D50 
)

Converts XYZ to L*u*v*.

Default reference white is D50 for this function. http://en.wikipedia.org/wiki/CIELUV

Eigen::Vector3d Lumiverse::ColorUtils::convXYZtoRGB ( Eigen::Vector3d  color,
RGBColorSpace  cs = sRGB 
)

Converts an XYZ value to a RGB value using the specified color space.

Parameters
colorXYZ value to convert. This function assumes that the color is normalized such that Y = 100 and will do equations accordingly. Other normalizations may result in unusual results.
csColorspace to convert to.
Returns
Raw RGB value. Note that this value may be out of the normal [0, 1] range.
Eigen::Vector3d Lumiverse::ColorUtils::getApproxColor ( string  gel,
float  intens = 1.0f 
)

Gets the XYZ coordinates of a gel color at a specified intensity.

This function assumes an incandescent source and makes a simple approximation to simulate ambershift (see code for details). Uses the CIE1964 CMF.

Returns
Unscaled XYZ value from blackbody calcuation (can be huge) or CIE Illuminant A ref white if gel isn't in the Lumiverse color library.
Eigen::Vector3d Lumiverse::ColorUtils::getScaledColor ( string  gel,
float  intens = 1.0f 
)

Gets the Y-normalized XYZ coordinates of a gel color at a specified intensity.

Y-normalized means that Y = 100 and X and Z are scaled relative to Y = 100.

Eigen::Vector3d Lumiverse::ColorUtils::normalizeRGB ( Eigen::Vector3d  rgb)

Takes an RGB value and normalizes it to the range [0,1].

Note that this function is likely a terrible hack and is temporary while we figure out how to use color appearance models.