Qualpal
Repositories

qualpal::colors::Lab

C++ · cpp · 4.1.0

class qualpal::colors::Lab

Lab color space representation (CIE L*a*b*).

Perceptually uniform color space where Euclidean distance approximates perceived color difference.

  • L: Lightness [0, 100] (0 = black, 100 = white)

  • a: Green-red axis [-128, 127] (negative = green, positive = red)

  • b: Blue-yellow axis [-128, 127] (negative = blue, positive = yellow)

Provides conversion constructors for RGB, HSL, XYZ, and LCHab. Most conversions use the D65 reference white point by default.

See also

RGB, HSL, XYZ, LCHab for conversions.

Methods

Lab

Lab

Lab()

Default constructor initializes Lab to black (0,0,0).

Lab

Lab(const HSL & hsl)

Construct Lab from HSL color.

Parameters

hsl

HSL color to convert from

Lab

Lab(const LCHab & lch)

Construct Lab from LCHab color.

Parameters

lch

LCHab color to convert from

Lab

Lab(const RGB & rgb)

Construct Lab from RGB color.

Parameters

rgb

RGB color to convert from

Lab

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

Construct Lab from XYZ color.

Parameters

xyz

XYZ color to convert from

white_point

Reference white point (default: D65)

Lab

Lab(const double l, const double a, const double b)

Construct Lab from component values.

Parameters

l

Lightness [0,100]

a

Green-red axis [-128,127]

b

Blue-yellow axis [-128,127]

a

inline double a() const

Get green-red component.

b

inline double b() const

Get blue-yellow component.

l

inline double l() const

Get lightness [0,100].

operator==

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

Equality operator for Lab colors.

Parameters

other

Other Lab color to compare with

Returns

true if both Lab colors are equal, false otherwise