Skip to content

Conversation

@tomcur
Copy link
Member

@tomcur tomcur commented Feb 4, 2025

This adds absolute color conversions and chromatic adaptation, and is, more or less, a prerequisite for #137.

Conversion methods are added to ColorSpace, ColorSpaceTag, and DynamicColor, 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 a chromatically_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 is const 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.

@tomcur tomcur force-pushed the chromatic-adaptation branch from e6cd13f to bbdfdca Compare February 4, 2025 14:20
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! I tried to find a nit just to prove I actually read it, but failed to do so.

@tomcur tomcur added this pull request to the merge queue Feb 13, 2025
Merged via the queue into linebender:main with commit e8115af Feb 13, 2025
16 checks passed
@tomcur tomcur deleted the chromatic-adaptation branch February 13, 2025 09:32
@waywardmonkeys waywardmonkeys added this to the 0.3.0 milestone Mar 26, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 17, 2025
This is useful to test the current implementation of absolute
conversions (added in #139), but
the main motivation is to have tests in place as preparation for manual
implementations of `ColorSpace::{to_linear_srgb_absolute,
from_linear_srgb_absolute}` for the non-D65 color spaces.
github-merge-queue bot pushed a commit that referenced this pull request Apr 24, 2025
This builds on #139, which added
absolute color conversions (conversions without chromatic adaptation).
The default method implementations added there use the
chromatically-adapting methods and undo adaptation through additional
matrix multiplies. For efficiency, we can do the absolute conversions
using matrices that do not include adaptation in the first place.

This PR does that for ProPhoto RGB. More to follow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants