Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement absolute color conversions and chromatic adaptation #139

Merged
merged 10 commits into from
Feb 13, 2025

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
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants