PCL
|
Colorimetrically defined RGB working color space. More...
#include <RGBColorSystem.h>
Public Types | |
using | sample = double |
Static Public Member Functions | |
static void | HSIToRGB (sample &R, sample &G, sample &B, sample H, sample S, sample I) |
static void | HSVToRGB (sample &R, sample &G, sample &B, sample H, sample S, sample V) |
static double | LinearToSRGB (double x) |
static void | RGBToHSI (sample &H, sample &S, sample &I, sample R, sample G, sample B) |
static void | RGBToHSV (sample &H, sample &S, sample &V, sample R, sample G, sample B) |
static double | SRGBToLinear (double x) |
Static Public Attributes | |
static const RGBColorSystem | sRGB |
static const float | sRGB_x [3] |
static const float | sRGB_y [3] |
static const float | sRGB_Y [3] |
Friends | |
bool | operator== (const RGBColorSystem &S1, const RGBColorSystem &S2) |
RGBColorSystem is a rigorous and efficient RGB working space (RGBWS) implementation. This class provides all conversions between the supported color spaces: RGB, CIE XYZ, CIE L*a*b*, CIE L*c*h* and grayscale, plus the HSV and HSI color ordering systems, which are also supported for convenience, although not linked to any particular RGBWS.
Color components and channel values are represented as real scalars using 64-bit floating point variables. Normalization of components and channel values to the standard real range [0,1] is ensured for all supported color spaces and color ordering systems. All internal transformations to and from native color space component ranges are performed transparently.
Chrominance coordinates and luminance coefficients are always relative to the D50 reference white in conformance with the ICC standard.
Definition at line 101 of file RGBColorSystem.h.
using pcl::RGBColorSystem::sample = double |
The type used to represent components and channel values for all supported color spaces and color ordering systems.
Definition at line 109 of file RGBColorSystem.h.
|
inline |
Constructs a RGBColorSystem object as a new instance of the default RGB working space. The default RGBWS is sRGB (adapted to D50) in current versions of the PixInsight platform.
Definition at line 116 of file RGBColorSystem.h.
|
inline |
Constructs a RGBColorSystem object as a copy of an existing instance.
Definition at line 128 of file RGBColorSystem.h.
|
inline |
Constructs a new RGBColorSystem instance by its RGB working space parameters.
gamma | Gamma parameter of the RGB working space. Ignored if issRGB is true. |
issRGB | If true, this space uses the sRGB gamma function. If this parameter is false, the space uses a standard raise gamma function with the specified gamma exponent. |
x,y | Vectors of chromaticity coordinates relative to the D50 reference white. |
Y | Vector of luminance coefficients relative to D50. If not specified, or if an empty vector is specified, luminance coefficients will be calculated internally from the specified color primaries and the D50 reference white components. |
Definition at line 154 of file RGBColorSystem.h.
|
inline |
Constructs a new RGBColorSystem instance by its RGB working space parameters.
gamma | Gamma parameter of the RGB working space. Ignored if issRGB is true. |
issRGB | If true, this space uses the sRGB gamma function. If this parameter is false, the space uses a standard raise gamma function with the specified gamma exponent. |
x,y | Arrays of chromaticity coordinates relative to the D50 reference white. |
Y | Array of luminance coefficients relative to D50. If not specified, or if a null pointer is specified, luminance coefficients will be calculated internally from the specified color primaries and the D50 reference white components. |
Definition at line 179 of file RGBColorSystem.h.
|
inlinevirtual |
Virtual destructor.
Definition at line 187 of file RGBColorSystem.h.
|
inline |
Causes this RGBColorSystem instance to reference the same RGB working space as another instance.
The reference count of the previously referenced space is decremented, and the previous space is deleted if it becomes unreferenced. The reference count of the new space is then incremented.
Definition at line 427 of file RGBColorSystem.h.
|
inline |
Returns a reference to the vector of X chromaticity coordinates in this RGB working space.
In the current PixInsight platform, chromaticity coordinates are always relative to the D50 reference white.
Definition at line 380 of file RGBColorSystem.h.
|
inline |
Returns a reference to the vector of Y chromaticity coordinates in this RGB working space.
In the current PixInsight platform, chromaticity coordinates are always relative to the D50 reference white.
Definition at line 392 of file RGBColorSystem.h.
Returns the normalized a* chrominance component of the CIE L*a*b* color space corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
Definition at line 882 of file RGBColorSystem.h.
|
inline |
Returns the scaling factor applied for normalization of CIE a* components.
Definition at line 341 of file RGBColorSystem.h.
|
inline |
Returns the additive constant applied for normalization of CIE a* components.
Definition at line 332 of file RGBColorSystem.h.
Returns the normalized b* chrominance component of the CIE L*a*b* color space corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
This function avoids the calculation of the L* and a* components, which saves time when only the b* chrominance component is required.
Definition at line 899 of file RGBColorSystem.h.
|
inline |
Returns the scaling factor applied for normalization of CIE b* components.
Definition at line 359 of file RGBColorSystem.h.
|
inline |
Returns the additive constant applied for normalization of CIE b* components.
Definition at line 350 of file RGBColorSystem.h.
Returns the normalized c* chrominance component of the CIE L*c*h* color space corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
This function avoids the calculation of the L* and h* components, which saves time when only the c* chrominance component is required.
Definition at line 916 of file RGBColorSystem.h.
|
inline |
Returns the scaling factor applied for normalization of CIE c* components.
Definition at line 368 of file RGBColorSystem.h.
Returns the normalized h* chrominance component of the CIE L*c*h* color space corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
This function avoids the calculation of the L* and c* components, which saves time when only the h* chrominance component is required.
The returned value is the hue angle normalized to the range [0,1), where 0 corresponds to a hue angle of zero degrees, and 1 to an angle of 360 degrees (2*pi radians).
Definition at line 939 of file RGBColorSystem.h.
Returns the normalized h* chrominance component of the CIE L*c*h* color space, expressed in radians, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
This function avoids the calculation of the L* and c* channels, which saves time when only the h* chrominance component is required.
The returned value is the hue angle in radians, in the range [0,2pi).
Definition at line 956 of file RGBColorSystem.h.
A synonym for Lightness().
Definition at line 468 of file RGBColorSystem.h.
|
inline |
Conversion from CIE L*a*b* to CIE L*c*h*.
[out] | L,c,h | References to the variables where output normalized CIE L*c*h* components will be stored. |
L0,a,b | Input normalized CIE L*a*b* components. |
Definition at line 1249 of file RGBColorSystem.h.
|
inline |
Conversion from CIE L*a*b* to CIE XYZ.
[out] | X,Y,Z | References to the variables where output normalized CIE XYZ components will be stored. |
L,a,b | Input normalized CIE L*a*b* components. |
Definition at line 1226 of file RGBColorSystem.h.
|
inline |
Conversion from CIE L*a*b* to RGB.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
L,a,b | Input normalized CIE L*a*b* components. |
Definition at line 1209 of file RGBColorSystem.h.
|
inline |
Conversion from CIE L*c*h* to CIE L*a*b*.
[out] | L,a,b | References to the variables where output normalized CIE L*a*b* components will be stored. |
L0,c,h | Input normalized CIE L*c*h* components. |
Definition at line 1294 of file RGBColorSystem.h.
|
inline |
Conversion from CIE L*c*h* to RGB.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
L,c,h | Input normalized CIE L*c*h* components. |
Definition at line 1268 of file RGBColorSystem.h.
CIE Y component from CIE L*.
L | Input CIE L* component. |
Definition at line 833 of file RGBColorSystem.h.
CIE X component from RGB components.
R,G,B | Input RGB components. |
Definition at line 792 of file RGBColorSystem.h.
|
inline |
Returns the scaling factor applied for normalization of CIE X components.
This normalization factor is the sum of the elements in the first row of the XYZ-to-RGB conversion matrix: M[0][0] + M[0][1] + M[0][2].
Normalization applies linear transformations to ensure that the values of all color space components are always represented in the [0,1] range, irrespective of RGBWS parameters.
Definition at line 308 of file RGBColorSystem.h.
|
inline |
Conversion from CIE XYZ to CIE L*a*b*.
[out] | L,a,b | References to the variables where output normalized CIE L*a*b* components will be stored. |
X,Y,Z | Input normalized CIE XYZ components. |
Definition at line 1193 of file RGBColorSystem.h.
|
inline |
Conversion from CIE XYZ to RGB.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
X,Y,Z | Input normalized CIE XYZ components. |
Definition at line 1180 of file RGBColorSystem.h.
CIE Y component from RGB components.
R,G,B | Input RGB components. |
Definition at line 802 of file RGBColorSystem.h.
CIE L* component from CIE Y.
Y | Input CIE Y component. |
Definition at line 822 of file RGBColorSystem.h.
CIE Z component from RGB components.
R,G,B | Input RGB components. |
Definition at line 812 of file RGBColorSystem.h.
|
inline |
Returns the scaling factor applied for normalization of CIE Z components.
This normalization factor is the sum of the elements in the third row of the XYZ-to-RGB conversion matrix: M[2][0] + M[2][1] + M[2][2].
Normalization applies linear transformations to ensure that the values of all color space components are always represented in the [0,1] range, irrespective of RGBWS parameters.
Definition at line 323 of file RGBColorSystem.h.
|
inline |
Ensures that this RGBColorSystem object uniquely references its RGB working space data.
If necessary, this member function generates a duplicate of the RGB working space data, references it, and decrements the reference counter of the original data.
Definition at line 225 of file RGBColorSystem.h.
|
inline |
Returns the gamma value of this RGB working space.
Definition at line 243 of file RGBColorSystem.h.
|
inline |
Transformation from separate HSI chrominance and normalized CIE L* components to the RGB color space.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
H,S,I | Input HSI channel values for chrominance. | |
L | Input normalized CIE L* component (lightness). |
The lightness implicitly defined by the input HSI values is discarded and replaced with the specified CIE L* component.
Strictly speaking, the resulting chrominance is not colorimetrically defined, since it derives from HSI channel values and hence is not defined in an RGB working space. However, the chrominance is supposed to be expressed in the RGB working space referenced by this RGBColorSystem object.
The input H value must be a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
The primary usefulness of this function is implementing accurate hue/saturation image transformations in the HSI system with complete preservation of the colorimetrically defined lightness component.
Definition at line 1161 of file RGBColorSystem.h.
Returns the Saturation channel value in the HSI color ordering system, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
Definition at line 587 of file RGBColorSystem.h.
|
inlinestatic |
Conversion from the HSI color ordering system to the RGB color space.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
H,S,I | Input HSI channel values. |
The input H value must be a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 1116 of file RGBColorSystem.h.
|
inline |
Conversion from separate HSV chrominance and CIE L* components to the RGB color space.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
H,S,V | Input HSV channel values for chrominance. | |
L | Input normalized CIE L* (lightness) component. |
The lightness implicitly defined by the input HSV values is discarded and replaced with the specified CIE L* component.
Strictly speaking, the resulting chrominance is not colorimetrically defined, since it derives from HSV channel values and hence is not defined in an RGB working space. However, the chrominance is supposed to be expressed in the RGB working space referenced by this RGBColorSystem object.
The input H value must be a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
The primary usefulness of this function is implementing accurate hue/saturation image transformations in the HSV system with complete preservation of the colorimetrically defined lightness component.
Definition at line 1087 of file RGBColorSystem.h.
Returns the Saturation channel value in the HSV color ordering system, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
Definition at line 568 of file RGBColorSystem.h.
|
inlinestatic |
Conversion from the HSV color ordering system to the RGB color space.
[out] | R,G,B | References to the variables where output normalized RGB components will be stored. |
H,S,V | Input HSV channel values. |
The input H value must be a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 1032 of file RGBColorSystem.h.
Returns the Hue channel value in the HSV and HSI color ordering systems, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
The returned value is a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of 1 corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 534 of file RGBColorSystem.h.
Returns the Intensity channel value in the HSI color ordering system, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
Definition at line 515 of file RGBColorSystem.h.
|
inline |
Returns true iff this RGBColorSystem object is an alias of another RGBColorSystem instance s.
Two instances of RGBColorSystem are aliases if both share the same RGB working space data.
Definition at line 212 of file RGBColorSystem.h.
|
inline |
Returns true iff this space uses a linear gamma function.
A linear RGB space has gamma=1 and doesn't use a sRGB gamma function.
Definition at line 261 of file RGBColorSystem.h.
|
inline |
Returns true iff this space uses a sRGB gamma function.
Definition at line 251 of file RGBColorSystem.h.
|
inline |
Returns true iff this RGBColorSystem object uniquely references its RGB working space data.
Definition at line 200 of file RGBColorSystem.h.
Returns the lightness component in the CIE L*a*b* space corresponding to a set of RGB components.
R,G,B | RGB components from which lightness will be calculated. |
Definition at line 453 of file RGBColorSystem.h.
|
inlinestatic |
The inverse sRGB gamma function. Returns a color sample value in the sRGB color space for the specified linear sample value x. x must be in the normalized [0,1] range.
Definition at line 1319 of file RGBColorSystem.h.
References pcl::Pow().
|
inline |
Returns a reference to the vector of luminance coefficients in this RGB working space.
In the current PixInsight platform, luminance coefficients are always relative to the D50 reference white.
Definition at line 404 of file RGBColorSystem.h.
|
inline |
Assignment iterator. Returns a reference to this object.
This operator calls Assign() with the specified source space rgbws.
Definition at line 439 of file RGBColorSystem.h.
|
inline |
Calculates the normalized chrominance components of the CIE L*a*b* color space corresponding to a specified set of RGB components.
[out] | a,b | References to the variables where output normalized CIE a* and CIE b* components will be stored. |
R,G,B | Input RGB components. |
Definition at line 867 of file RGBColorSystem.h.
|
inline |
Conversion from RGB to the CIE L*a*b* color space.
[out] | L,a,b | References to the variables where output normalized CIE L*a*b* components will be stored. |
R,G,B | Input RGB components. |
Definition at line 848 of file RGBColorSystem.h.
|
inline |
Conversion from the RGB color space to the CIE L*a*b* color space with optimized, on-the-fly calculation of the CIE c* component.
[out] | L,a,b | References to the variables where output normalized CIE L*a*b* components will be stored. |
[out] | c | Reference to a variable where the output normalized CIE c* component will be stored. |
R,G,B | Input RGB components. |
If only the CIE c* component is required besides CIE L*a*b* components, this function is much faster than performing two separate conversions to the CIE L*a*b* and L*c*h* color spaces.
Definition at line 1006 of file RGBColorSystem.h.
|
inline |
Conversion from the RGB color space to the CIE L*c*h* color space.
[out] | L,c,h | References to the variables where output normalized CIE L*c*h* components will be stored. |
R,G,B | Input RGB components. |
Definition at line 975 of file RGBColorSystem.h.
|
inline |
Conversion from the RGB color space to the CIE XYZ color space.
[out] | X,Y,Z | References to the variables where output CIE XYZ components will be stored. |
R,G,B | Input RGB components. |
Definition at line 765 of file RGBColorSystem.h.
|
inline |
Calculates the chrominance X, Z components in the CIE XYZ color space corresponding to a specified set of RGB components.
[out] | X,Z | References to the variables where output CIE X and Z components will be stored. |
R,G,B | Input RGB components. |
This function avoids the calculation of the CIE Y component, which saves time when only the chrominance components are required.
Definition at line 782 of file RGBColorSystem.h.
Calculates the lightness component in the CIE L*a*b* space corresponding to a set of RGB components and copies it to a variable.
[out] | K | Reference to an output variable for the calculated lightness component. |
R,G,B | Input RGB components. |
Definition at line 484 of file RGBColorSystem.h.
|
inlinestatic |
Converts a set of RGB components to the corresponding channel values in the HSI (Hue, Saturation, Intensity) color ordering system.
[out] | H,S,I | References to the variables where output HSI channel values will be stored. |
R,G,B | Input RGB components. |
The output H value is a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 676 of file RGBColorSystem.h.
|
inline |
Converts a set of RGB components to the corresponding channel values in the HSI (Hue, Saturation, Intensity) color ordering system, plus the L* component (lightness) in the CIE L*a*b* space.
[out] | H,S,I | References to the variables where output HSI channel values will be stored. |
[out] | L | Reference to a variable where the output CIE L* component will be stored. |
R,G,B | Input RGB components. |
The output H value is a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 751 of file RGBColorSystem.h.
|
inlinestatic |
Converts a set of RGB components to the corresponding channel values in the HSV (Hue, Saturation, Value) color ordering system.
[out] | H,S,V | References to the variables where output HSV channel values will be stored. |
R,G,B | Input RGB components. |
The output H value is a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 629 of file RGBColorSystem.h.
|
inline |
Converts a set of RGB components to the corresponding channel values in the HSV (Hue, Saturation, Value) color ordering system, plus the L* component (lightness) in the CIE L*a*b* space.
[out] | H,S,V | References to the variables where output HSV channel values will be stored. |
[out] | L | Reference to a variable where the output CIE L* component will be stored. |
R,G,B | Input RGB components. |
The output H value is a normalized hue, which is the hue angle rescaled to the normalized [0,1) range. A normalized hue value of one corresponds to a hue angle of 2*pi radians, or 360 degrees.
Definition at line 725 of file RGBColorSystem.h.
|
inline |
Returns a reference to a vector with the elements of the 3x3 matrix for conversion from RGB to CIE XYZ color spaces.
The RGB-to-XYZ conversion matrix is a function of the reference white (always D50 in this implementation) and the chromaticity coordinates that define this RGB working color space.
The nine matrix elements are stored contiguously in row order in the returned vector: M[0][0], M[0][1], ..., M[2][2].
Definition at line 277 of file RGBColorSystem.h.
Returns the Saturation channel value in the HSV color ordering system, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
This function is a synonym for HSVSaturation().
Definition at line 608 of file RGBColorSystem.h.
|
inlinestatic |
The sRGB gamma function. Returns a linear color sample value for the specified sample value x in the sRGB color space. x must be in the normalized [0,1] range.
Definition at line 1308 of file RGBColorSystem.h.
References pcl::Pow().
Returns the Value channel value in the HSV color ordering system, corresponding to a specified set of RGB components.
R,G,B | Input RGB components. |
Definition at line 498 of file RGBColorSystem.h.
|
inline |
Returns a reference to a vector with the elements of the 3x3 inverse matrix for conversion from CIE XYZ to RGB color spaces.
The XYZ-to-RGB inverse conversion matrix is a function of the reference white (always D50 in this implementation) and the chromaticity coordinates that define this RGB working color space.
The nine inverse matrix elements are stored contiguously in row order in the returned vector: M_[0][0], M_[0][1], ..., M_[2][2].
Definition at line 293 of file RGBColorSystem.h.
|
friend |
Returns true iff two RGBColorSystem instances define the same RGB working space. This happens when either both instances are aliases, or if they define exactly the same RGB space parameters.
Definition at line 414 of file RGBColorSystem.h.
|
static |
The sRGB (D50) working space.
Definition at line 1579 of file RGBColorSystem.h.
Referenced by pcl::ImageColor::ResetDefaultRGBWorkingSpace().
|
static |
sRGB x chromaticity coordinates (D50).
Definition at line 1564 of file RGBColorSystem.h.
|
static |
sRGB y chromaticity coordinates (D50).
Definition at line 1569 of file RGBColorSystem.h.
|
static |
sRGB luminance coefficients (D50).
Definition at line 1574 of file RGBColorSystem.h.