Qualpal
Repositories

qualpal::colors::XYZ

C++ · cpp · 4.1.0

class qualpal::colors::XYZ

XYZ color representation (CIE 1931 color space).

Represents a color in the device-independent CIE 1931 XYZ color space. Used as an intermediate for conversions between RGB and perceptually uniform spaces (Lab, LCHab, DIN99d).

  • X: [0, ~0.95] (roughly red-like)

  • Y: [0, 1] (luminance)

  • Z: [0, ~1.09] (roughly blue-like)

Most conversions use the D65 reference white point by default.

// Create XYZ from RGB
XYZ xyz_from_rgb(RGB(0.5, 0.2, 0.7));

// Modify whitepoint
XYZ xyz_custom_white(0.4, 0.5, 0.6, { 0.96422, 1.0, 0.82521 }); // D50

See also

RGB, Lab, LCHab, DIN99d for conversions.

Methods

XYZ

XYZ

XYZ()

Default constructor initializes XYZ to (0,0,0).

XYZ

XYZ(const HSL & hsl)

Construct XYZ from HSL color.

Parameters

hsl

HSL color to convert from

XYZ

XYZ(const LCHab & lch, const std::array<double, 3> & white_point = { 0.95047, 1, 1.08883 })

Construct XYZ from LCHab color.

Parameters

lch

LCHab color to convert from

white_point

Reference white point (default: D65)

XYZ

XYZ(const Lab & lab, const std::array<double, 3> & white_point = { 0.95047, 1, 1.08883 })

Construct XYZ from Lab color.

Parameters

lab

Lab color to convert from

white_point

Reference white point (default: D65)

XYZ

XYZ(const RGB & rgb)

Construct XYZ from RGB color.

Parameters

rgb

RGB color to convert from

XYZ

XYZ(const double x, const double y, const double z)

Construct XYZ from component values.

Parameters

x

X component (roughly red-like)

y

Y component (luminance)

z

Z component (roughly blue-like)

operator!=

inline bool operator!=(const XYZ & other) const

inequality operator for XYZ colors

Parameters

other

Other XYZ color to compare with

Returns

true if XYZ colors are not equal, false otherwise

operator==

inline bool operator==(const XYZ & other) const

equality operator for XYZ colors

Parameters

other

Other XYZ color to compare with

Returns

true if both XYZ colors are equal, false otherwise

x

inline double x() const

Get X component.

y

inline double y() const

Get Y component (luminance).

z

inline double z() const

Get Z component.