#include <color.h>
Public Member Functions | |
ColorSystem (float xR, float yR, float xG, float yG, float xB, float yB, float xW, float yW, float lum=1.) | |
RGBColor | ToRGBConstrained (const XYZColor &color) const |
XYZColor | ToXYZ (const RGBColor &color) const |
bool | Constrain (float lum, RGBColor &rgb) const |
RGBColor | Limit (const RGBColor &rgb, int method) const |
Public Attributes | |
float | xRed |
float | yRed |
Red coordinates. | |
float | xGreen |
float | yGreen |
Green coordinates. | |
float | xBlue |
float | yBlue |
Blue coordinates. | |
float | xWhite |
float | yWhite |
White coordinates. | |
float | luminance |
White intensity. | |
float | XYZToRGB [3][3] |
Corresponding conversion matrix from XYZ to RGB. | |
float | RGBToXYZ [3][3] |
Corresponding conversion matrix from RGB to XYZ. |
A colour system is defined by the CIE x and y coordinates of its three primary illuminants and the x and y coordinates of the white point. The additional definition of the white point intensity allow for intensity adaptation
Definition at line 246 of file color.h.
lux::ColorSystem::ColorSystem | ( | float | xR, | |
float | yR, | |||
float | xG, | |||
float | yG, | |||
float | xB, | |||
float | yB, | |||
float | xW, | |||
float | yW, | |||
float | lum = 1. | |||
) |
[in] | xR | x value of red in xyY space |
[in] | yR | y value of red in xyY space |
[in] | xG | x value of green in xyY space |
[in] | yG | y value of green in xyY space |
[in] | xB | x value of blue in xyY space |
[in] | yB | y value of blue in xyY space |
[in] | xW | x value of white in xyY space |
[in] | yW | y value of white in xyY space |
[in] | lum | Y (intensity) value of white in xyY space |
Initialize a colorspace conversion instance by providing reference values of red, green, blue and white point. This functions computes the corresponding convertion matrix from XYZ space to RGB space.
Definition at line 53 of file color.cpp.
References lux::dot(), lux::Invert3x3(), luminance, cimg_library::matrix(), lux::Multiply3x3(), RGBToXYZ, lux::Transform3x3(), xBlue, xGreen, xRed, xWhite, XYZToRGB, yBlue, yGreen, yRed, and yWhite.
bool lux::ColorSystem::Constrain | ( | float | lum, | |
RGBColor & | rgb | |||
) | const |
[in] | xyz | The color in XYZ space |
[in,out] | rgb | The same color in RGB space |
true | The color has been modified | |
false | The color was inside the representable gamut: no modification occured |
If the requested RGB shade contains a negative weight for one of the primaries, it lies outside the colour gamut accessible from the given triple of primaries. Desaturate it by mixing with the white point of the colour system so as to reduce the primary with the negative weight to zero. This is equivalent to finding the intersection on the CIE diagram of a line drawn between the white point and the requested colour with the edge of the Maxwell triangle formed by the three primaries. This function tries not to change the overall intensity, only the tint is shifted to be inside the representable gamut.
Definition at line 133 of file color.cpp.
References lux::Color::c, Lerp(), lux::LowGamut(), and luminance.
Referenced by ToRGBConstrained().
Definition at line 164 of file color.cpp.
References lux::Color::c, lux::Color::Clamp(), lux::HighGamut(), Lerp(), luminance, and RGBToXYZ.
Referenced by lux::FlexImageFilm::WriteImage2().
[in] | color | A color in XYZ space |
Determine the contribution of each primary in a linear combination which sums to the desired chromaticity. If the requested chromaticity falls outside the Maxwell triangle (colour gamut) formed by the three primaries, one of the R, G, or B weights will be negative. Use Constrain() to desaturate an outside-gamut colour to the closest representation within the available gamut.
Definition at line 263 of file color.h.
References lux::Color::c, Constrain(), XYZToRGB, and lux::XYZColor::Y().
Referenced by lux::FlexImageFilm::WriteImage2().
[in] | color | A color in RGB space |
Definition at line 277 of file color.h.
References lux::Color::c, and RGBToXYZ.
Referenced by lux::FlexImageFilm::ComputeGroupScale().
White intensity.
Definition at line 291 of file color.h.
Referenced by ColorSystem(), Constrain(), and Limit().
float lux::ColorSystem::RGBToXYZ[3][3] |
Corresponding conversion matrix from RGB to XYZ.
Definition at line 293 of file color.h.
Referenced by ColorSystem(), Limit(), and ToXYZ().
float lux::ColorSystem::xBlue |
Definition at line 289 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::xGreen |
Definition at line 288 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::xRed |
Definition at line 287 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::xWhite |
Definition at line 290 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::XYZToRGB[3][3] |
Corresponding conversion matrix from XYZ to RGB.
Definition at line 292 of file color.h.
Referenced by ColorSystem(), and ToRGBConstrained().
float lux::ColorSystem::yBlue |
Blue coordinates.
Definition at line 289 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::yGreen |
Green coordinates.
Definition at line 288 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::yRed |
Red coordinates.
Definition at line 287 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().
float lux::ColorSystem::yWhite |
White coordinates.
Definition at line 290 of file color.h.
Referenced by ColorSystem(), and lux::lux_png_error().