Implement absolute color conversions and chromatic adaptation #139
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is adds absolute color conversions and chromatic adaptation, and is, more or less, a prerequisite for #137.
Conversion methods are added to
ColorSpace
,ColorSpaceTag
, andDynamicColor
, that convert between color spaces while keeping the same absolute color (i.e., if that color were to be reproduced, it would be the same physical color, but a perceptually different color under the intended reference white of the color space). These methods are suffixed_absolute
. This also adds achromatically_adapt
method for manual chromatic adaptation (useful for, e.g., "white balancing" pictures).The white points are represented as CIE
xy
chromaticities. Calculation of chromatic adaptation matrices isconst
where possible.A follow-up to this would be to manually implement
ColorSpace::{to_linear_srgb_absolute, from_linear_srgb_absolute, convert}
for the color spaces we provide. Those can in most cases just lift directly from their non-_absolute
counterparts, with the exceptions being XYZ-D50, ACEScg and ACES2065-1. Those methods will get somewhat simpler matrices, as the{D50, ACES}<->D65
adaptation transforms can be dropped.