-
-
Notifications
You must be signed in to change notification settings - Fork 283
PR: Enable *DIN99* method selection in colour.difference.delta_E_DIN99 definition.
#1393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
PR: Enable *DIN99* method selection in colour.difference.delta_E_DIN99 definition.
#1393
Conversation
|
Thanks @lassefschmidt, it is the first time we introduce this pattern, makes me wonder if we should not adopt the machinery that the convert(
sd,
"Spectral Distribution",
"sRGB",
sd_to_XYZ={"illuminant": SDS_ILLUMINANTS["FL2"]},
) |
|
So yeah something that we might be able to do: # Layer 1: filter direct kwargs by target function signature
filtered_kwargs = filter_kwargs(conversion_function, **kwargs)
# Layer 2: merge in function-name-keyed dict (overrides)
filtered_kwargs.update(kwargs.get(conversion_function_name, {}))delta_E(a, b, method="DIN99", delta_E_DIN99={"method": "DIN99b"})And def delta_E_DIN99(Lab_1, Lab_2, textiles=False, method="DIN99"):
... |
I had the same thought when writing this PR, but didn’t want to introduce too big of a change. This way, we would also get rid of all the « extra » parameters depending on the function (e.g. the textiles boolean or the l:c values) We could even allow users to provide ANY color space array for a and b (and a and b must not even have the same color space), the keyword dict for the conversion function to the desired target space and use the conversion graph. Which would create a super convenient delta E wrapper. But possibly overkill ! |
colour.difference.delta_E_DIN99 definition.
|
I tend to prefer API consistency over special cases (I know that we already have plenty!) so if you are happy with suggested changes, please roll! |
|
Happy to propose a new implementation then. Give me a few days max and I should push an update to this PR (probably rebased on most recent develop branch). One clarification : if we extend to arbitrary color space inputs a and b and pass the conversion args for the .convert function, do we also want to « improve » how we treat the different additional arguments of the delta E methods (such as textiles boolean or l:c) ? Can we introduce breaking changes here (e.g. via the keyword dict using the delta E method name as you proposed) or we keep supporting a direct pass of textiles and l:c in the delta E wrapper ? |
Can you clarify? |
Summary
A very small PR to enable selecting the Lab → DIN99 conversion variant when computing ΔE_DIN99.
Both colour.difference.delta_E and colour.models.Lab_to_DIN99 expose a method parameter, which makes it impossible to forward the conversion method via the existing **kwargs mechanism without a keyword collision.
To resolve this, a dedicated din99_method parameter is added to colour.difference.delta_E_DIN99. The parameter defaults to "DIN99", matching the normative DIN99 definition used by Lab_to_DIN99.
The provided value is validated against DIN99_METHODS, which remains the single source of truth for supported DIN99 variants.
Preflight
Code Style and Quality
colour,colour.models.Documentation