aest 0.1.0
Collection of C++ utility libraries
Loading...
Searching...
No Matches
Gamut.cppm File Reference

Partition aest.colors:gamut: RGB gamuts, the BasicRGB color spaces built from a gamut and a transfer function, and their matrices to CIE XYZ, derived at compile time from chromaticities. More...

#include <array>
#include <concepts>
#include <cstdint>
#include <string_view>
#include <type_traits>
import aest.colors:transfer;
import aest.blas;

Go to the source code of this file.

Classes

struct  aest::colors::gamut::SRGB
 The sRGB and Rec. 709 primaries, D65 white, from IEC 61966-2-1. More...
struct  aest::colors::gamut::DisplayP3
 The DCI-P3 primaries with D65 white, from SMPTE EG 432-1. More...
struct  aest::colors::gamut::Rec2020
 The Rec. 2020 / Rec. 2100 primaries, D65 white, from ITU-R BT.2020. More...
struct  aest::colors::gamut::AP1
 The ACES AP1 primaries with the ACES white point (about D60), from SMPTE ST 2065-1, the gamut of ACEScg. More...
struct  aest::colors::RGBName< Gamut, Transfer >
 Name of the BasicRGB space of a gamut and a transfer function, printed by std::format. More...
struct  aest::colors::RGBName< gamut::AP1, tf::Linear >
 Linear AP1 goes by the name of its ACES working space. More...
struct  aest::colors::RGBName< gamut::SRGB, tf::Rec709 >
 The sRGB primaries with the Rec. 709 OETF are the space of Rec. 709. More...
struct  aest::colors::RGBName< gamut::Rec2020, tf::Rec709 >
 Rec. 2020 with the Rec. 709 OETF is the SDR space of Rec. 2020. More...
struct  aest::colors::RGBName< gamut::Rec2020, tf::PQ >
 Rec. 2020 with PQ is the PQ space of Rec. 2100. More...
struct  aest::colors::RGBName< gamut::Rec2020, tf::HLG >
 Rec. 2020 with HLG is the HLG space of Rec. 2100. More...
struct  aest::colors::NoArithmetic
 Empty base standing in for ColorArithmetic in encoded RGB spaces. More...
class  aest::colors::BasicRGB< Gamut, Transfer >
 A color in an RGB color space: the primaries and white point of Gamut, with channels encoded by Transfer. More...
struct  aest::colors::RGBParts< T >
 The gamut and transfer function of a BasicRGB space; empty for other types. More...
struct  aest::colors::RGBParts< BasicRGB< Gamut, Transfer > >
 The gamut and transfer function of BasicRGB<Gamut, Transfer>. More...

Namespaces

namespace  aest::colors::gamut
 Gamut tags, the first parameter of BasicRGB.

Concepts

concept  aest::colors::RGBGamut
 A gamut tag, the first parameter of BasicRGB.
concept  aest::colors::RGBSpace
 Any BasicRGB color space.
concept  aest::colors::LinearRGBSpace
 A BasicRGB space with linear channels, tf::Linear.
concept  aest::colors::BoundedRGBSpace
 A BasicRGB space with an SDR encoding: channels in the 0-1 range, relative to the display's white. Linear spaces and HDR signals such as PQ are left out.

Typedefs

using aest::colors::Chromaticity = std::array<double, 2>
 CIE 1931 xy chromaticity coordinates of a primary or white point.
using aest::colors::Vector3 = blas::Vector<double, 3>
 A column of three values, such as XYZ or linear RGB channels.
using aest::colors::Matrix3 = blas::Matrix<double, 3, 3>
 A 3x3 matrix, stored as three rows.
using aest::colors::SRGB = BasicRGB<gamut::SRGB, tf::SRGB>
 sRGB with gamma-encoded channels: the encoding of hex codes, 8-bit channels and CSS colors.
using aest::colors::LinSRGB = BasicRGB<gamut::SRGB, tf::Linear>
 Linear sRGB: the sRGB primaries without the gamma encoding, so channels are proportional to light and can exceed 1 for HDR values.
using aest::colors::DisplayP3 = BasicRGB<gamut::DisplayP3, tf::SRGB>
 Display P3: the P3 primaries with the sRGB transfer function, as on Apple displays and in CSS.
using aest::colors::LinDisplayP3 = BasicRGB<gamut::DisplayP3, tf::Linear>
 Linear Display P3.
using aest::colors::Rec709 = BasicRGB<gamut::SRGB, tf::Rec709>
 Rec. 709: the sRGB primaries with the Rec. 709 OETF, the encoding of HD video.
using aest::colors::Rec2020 = BasicRGB<gamut::Rec2020, tf::Rec709>
 Rec. 2020: the Rec. 2020 primaries with the Rec. 709 OETF, the encoding of SDR UHD video.
using aest::colors::LinRec2020 = BasicRGB<gamut::Rec2020, tf::Linear>
 Linear Rec. 2020, the gamut of UHD and HDR video.
using aest::colors::ACEScg = BasicRGB<gamut::AP1, tf::Linear>
 ACEScg: linear AP1, the working space of ACES rendering and compositing.
using aest::colors::Rec2100PQ = BasicRGB<gamut::Rec2020, tf::PQ>
 Rec.2100 PQ: Rec. 2020 primaries with the PQ signal of HDR10, linear 1.0 at 203 cd/m²
using aest::colors::Rec2100HLG = BasicRGB<gamut::Rec2020, tf::HLG>
 Rec.2100 HLG: Rec. 2020 primaries with the HLG signal, linear 1.0 at 75%.

Functions

constexpr Vector3 aest::colors::xyz_of (const Chromaticity &chromaticity)
 The XYZ of a chromaticity at luminance Y = 1.
constexpr Matrix3 aest::colors::rgb_to_xyz (const Chromaticity &red, const Chromaticity &green, const Chromaticity &blue, const Chromaticity &white)
 Derives the matrix from linear RGB to XYZ for a set of primaries.
constexpr Matrix3 aest::colors::bradford_to_d65 (const Chromaticity &white)
 Derives the Bradford matrix that adapts XYZ colors from a white point to D65.
template<RGBGamut Gamut>
constexpr Matrix3 aest::colors::gamut_to_xyz ()
 Derives the matrix from linear RGB of a gamut to XYZ relative to D65.

Variables

constexpr Chromaticity aest::colors::D65 = {0.3127, 0.3290}
 Chromaticity of the D65 white point, as sRGB defines it: the white of XYZ.
constexpr Chromaticity aest::colors::D50 = {0.3457, 0.3585}
 Chromaticity of the D50 white point, as CSS Color 4 and the ICC profile connection space define it: the white of CIELab.
constexpr Matrix3 aest::colors::BRADFORD
 The Bradford cone response matrix, used to adapt a white point.
template<RGBGamut Gamut>
constexpr Matrix3 aest::colors::RGB_TO_XYZ = gamut_to_xyz<Gamut>()
 Matrix from linear RGB of Gamut to XYZ, D65.
template<RGBGamut Gamut>
constexpr Matrix3 aest::colors::XYZ_TO_RGB = blas::inverse(RGB_TO_XYZ<Gamut>)
 Matrix from XYZ, D65, to linear RGB of Gamut.
template<RGBGamut Gamut, TransferFunction Transfer>
constexpr auto aest::colors::RGB_NAME_CHARS
 The characters of the default BasicRGB name: the transfer prefix, then the gamut name.

Detailed Description

Partition aest.colors:gamut: RGB gamuts, the BasicRGB color spaces built from a gamut and a transfer function, and their matrices to CIE XYZ, derived at compile time from chromaticities.

Author
Davide Pierotti

Definition in file Gamut.cppm.

Typedef Documentation

◆ ACEScg

using aest::colors::ACEScg = BasicRGB<gamut::AP1, tf::Linear>
export

ACEScg: linear AP1, the working space of ACES rendering and compositing.

Definition at line 394 of file Gamut.cppm.

◆ Chromaticity

using aest::colors::Chromaticity = std::array<double, 2>
export

CIE 1931 xy chromaticity coordinates of a primary or white point.

Definition at line 24 of file Gamut.cppm.

◆ DisplayP3

using aest::colors::DisplayP3 = BasicRGB<gamut::DisplayP3, tf::SRGB>
export

Display P3: the P3 primaries with the sRGB transfer function, as on Apple displays and in CSS.

Definition at line 379 of file Gamut.cppm.

◆ LinDisplayP3

using aest::colors::LinDisplayP3 = BasicRGB<gamut::DisplayP3, tf::Linear>
export

Linear Display P3.

Definition at line 382 of file Gamut.cppm.

◆ LinRec2020

using aest::colors::LinRec2020 = BasicRGB<gamut::Rec2020, tf::Linear>
export

Linear Rec. 2020, the gamut of UHD and HDR video.

Definition at line 391 of file Gamut.cppm.

◆ LinSRGB

using aest::colors::LinSRGB = BasicRGB<gamut::SRGB, tf::Linear>
export

Linear sRGB: the sRGB primaries without the gamma encoding, so channels are proportional to light and can exceed 1 for HDR values.

Definition at line 376 of file Gamut.cppm.

◆ Matrix3

using aest::colors::Matrix3 = blas::Matrix<double, 3, 3>

A 3x3 matrix, stored as three rows.

Definition at line 116 of file Gamut.cppm.

◆ Rec2020

using aest::colors::Rec2020 = BasicRGB<gamut::Rec2020, tf::Rec709>
export

Rec. 2020: the Rec. 2020 primaries with the Rec. 709 OETF, the encoding of SDR UHD video.

Definition at line 388 of file Gamut.cppm.

◆ Rec2100HLG

using aest::colors::Rec2100HLG = BasicRGB<gamut::Rec2020, tf::HLG>
export

Rec.2100 HLG: Rec. 2020 primaries with the HLG signal, linear 1.0 at 75%.

Definition at line 400 of file Gamut.cppm.

◆ Rec2100PQ

using aest::colors::Rec2100PQ = BasicRGB<gamut::Rec2020, tf::PQ>
export

Rec.2100 PQ: Rec. 2020 primaries with the PQ signal of HDR10, linear 1.0 at 203 cd/m²

Definition at line 397 of file Gamut.cppm.

◆ Rec709

using aest::colors::Rec709 = BasicRGB<gamut::SRGB, tf::Rec709>
export

Rec. 709: the sRGB primaries with the Rec. 709 OETF, the encoding of HD video.

Definition at line 385 of file Gamut.cppm.

◆ SRGB

using aest::colors::SRGB = BasicRGB<gamut::SRGB, tf::SRGB>
export

sRGB with gamma-encoded channels: the encoding of hex codes, 8-bit channels and CSS colors.

Convert it to LinSRGB with convert() before blending or other color math.

Definition at line 370 of file Gamut.cppm.

◆ Vector3

using aest::colors::Vector3 = blas::Vector<double, 3>

A column of three values, such as XYZ or linear RGB channels.

Definition at line 113 of file Gamut.cppm.

Function Documentation

◆ bradford_to_d65()

Matrix3 aest::colors::bradford_to_d65 ( const Chromaticity & white)
constexpr

Derives the Bradford matrix that adapts XYZ colors from a white point to D65.

Parameters
[in]whiteChromaticity of the source white point
Returns
The matrix taking XYZ relative to white to XYZ relative to D65.

Definition at line 166 of file Gamut.cppm.

◆ gamut_to_xyz()

template<RGBGamut Gamut>
Matrix3 aest::colors::gamut_to_xyz ( )
constexpr

Derives the matrix from linear RGB of a gamut to XYZ relative to D65.

Template Parameters
GamutThe gamut tag
Returns
The matrix of Gamut, adapted to D65 when its white point differs.

Definition at line 182 of file Gamut.cppm.

◆ rgb_to_xyz()

Matrix3 aest::colors::rgb_to_xyz ( const Chromaticity & red,
const Chromaticity & green,
const Chromaticity & blue,
const Chromaticity & white )
constexpr

Derives the matrix from linear RGB to XYZ for a set of primaries.

Each primary contributes the XYZ of its chromaticity, scaled so that equal channels of 1 give the white point at luminance Y = 1.

Parameters
[in]redChromaticity of the red primary
[in]greenChromaticity of the green primary
[in]blueChromaticity of the blue primary
[in]whiteChromaticity of the white point
Returns
The matrix taking linear (r, g, b) to (X, Y, Z), relative to white.

Definition at line 149 of file Gamut.cppm.

◆ xyz_of()

Vector3 aest::colors::xyz_of ( const Chromaticity & chromaticity)
constexpr

The XYZ of a chromaticity at luminance Y = 1.

Parameters
[in]chromaticityThe xy coordinates
Returns
The XYZ coordinates, (x / y, 1, (1 - x - y) / y).

Definition at line 130 of file Gamut.cppm.

Variable Documentation

◆ BRADFORD

Matrix3 aest::colors::BRADFORD
constexpr
Initial value:
= {{
{0.8951, 0.2664, -0.1614},
{-0.7502, 1.7135, 0.0367},
{0.0389, -0.0685, 1.0296},
}}

The Bradford cone response matrix, used to adapt a white point.

Definition at line 119 of file Gamut.cppm.

◆ D50

Chromaticity aest::colors::D50 = {0.3457, 0.3585}
inlineconstexprexport

Chromaticity of the D50 white point, as CSS Color 4 and the ICC profile connection space define it: the white of CIELab.

Definition at line 33 of file Gamut.cppm.

◆ D65

Chromaticity aest::colors::D65 = {0.3127, 0.3290}
inlineconstexprexport

Chromaticity of the D65 white point, as sRGB defines it: the white of XYZ.

Definition at line 27 of file Gamut.cppm.

◆ RGB_NAME_CHARS

template<RGBGamut Gamut, TransferFunction Transfer>
auto aest::colors::RGB_NAME_CHARS
inlineconstexpr
Initial value:
=
join_names<Transfer::PREFIX.size() + Gamut::NAME.size()>({Transfer::PREFIX, Gamut::NAME})
constexpr std::array< char, Size > join_names(const std::initializer_list< std::string_view > parts)
Concatenate names into a character array, for a color space name built at compile time.
Definition Color.cppm:100

The characters of the default BasicRGB name: the transfer prefix, then the gamut name.

Template Parameters
GamutThe gamut tag
TransferThe transfer function tag

Definition at line 210 of file Gamut.cppm.

◆ RGB_TO_XYZ

template<RGBGamut Gamut>
Matrix3 aest::colors::RGB_TO_XYZ = gamut_to_xyz<Gamut>()
inlineconstexpr

Matrix from linear RGB of Gamut to XYZ, D65.

Template Parameters
GamutThe gamut tag

Definition at line 194 of file Gamut.cppm.

◆ XYZ_TO_RGB

template<RGBGamut Gamut>
Matrix3 aest::colors::XYZ_TO_RGB = blas::inverse(RGB_TO_XYZ<Gamut>)
inlineconstexpr

Matrix from XYZ, D65, to linear RGB of Gamut.

Template Parameters
GamutThe gamut tag

Definition at line 201 of file Gamut.cppm.