Summary
XYZ_to_color_temperature interpolates in mired space (using robertson_mired_table), converts the result to Kelvin via mired_to_kelvin, clamps, and returns Kelvin. Downstream code often immediately converts that Kelvin value back to mired with kelvin_to_mired (for example when weighting matrices). That is an extra round-trip that may be unnecessary or lossy from a numerical/design standpoint.
Background (for newcomers)
Correlated color temperature (CCT) appears both as Kelvin and as mired (micro reciprocal Kelvin, (10^6/\mathrm{K})) in this codebase. Helpers live in src/rawtoaces_core/rawtoaces_core.cpp: kelvin_to_mired, mired_to_kelvin, and XYZ_to_color_temperature. Some call sites take XYZ → CCT (Kelvin) → mired again within the same workflow.
This issue asks for a design cleanup (and tests as appropriate): clarify whether the Kelvin return is the right API, whether some paths should stay in mired until later, or whether the duplication is intentional and should be documented. Do not change behaviour blindly—justify any change with tests or references.
Where to look
src/rawtoaces_core/rawtoaces_core.cpp — XYZ_to_color_temperature (interpolation over robertson_mired_table, then mired_to_kelvin, clamp ~2000–50000 K).
- Same file — call sites such as neutral CCT:
XYZ_to_color_temperature then kelvin_to_mired (see search for neutral_CCT / kelvin_to_mired).
src/rawtoaces_core/rawtoaces_core_priv.h — declarations exposed for unit tests.
tests/testDNGIdt.cpp — existing tests touching XYZ_to_color_temperature / kelvin–mired helpers.
Suggested direction (not a prescription)
- Trace all callers of
XYZ_to_color_temperature and note Kelvin vs mired expectations.
- Decide: reduce redundant conversions, narrow API (if maintainers agree), or document why Kelvin at the boundary is required.
Summary
XYZ_to_color_temperatureinterpolates in mired space (usingrobertson_mired_table), converts the result to Kelvin viamired_to_kelvin, clamps, and returns Kelvin. Downstream code often immediately converts that Kelvin value back to mired withkelvin_to_mired(for example when weighting matrices). That is an extra round-trip that may be unnecessary or lossy from a numerical/design standpoint.Background (for newcomers)
Correlated color temperature (CCT) appears both as Kelvin and as mired (micro reciprocal Kelvin, (10^6/\mathrm{K})) in this codebase. Helpers live in
src/rawtoaces_core/rawtoaces_core.cpp:kelvin_to_mired,mired_to_kelvin, andXYZ_to_color_temperature. Some call sites take XYZ → CCT (Kelvin) → mired again within the same workflow.This issue asks for a design cleanup (and tests as appropriate): clarify whether the Kelvin return is the right API, whether some paths should stay in mired until later, or whether the duplication is intentional and should be documented. Do not change behaviour blindly—justify any change with tests or references.
Where to look
src/rawtoaces_core/rawtoaces_core.cpp—XYZ_to_color_temperature(interpolation overrobertson_mired_table, thenmired_to_kelvin, clamp ~2000–50000 K).XYZ_to_color_temperaturethenkelvin_to_mired(see search forneutral_CCT/kelvin_to_mired).src/rawtoaces_core/rawtoaces_core_priv.h— declarations exposed for unit tests.tests/testDNGIdt.cpp— existing tests touchingXYZ_to_color_temperature/ kelvin–mired helpers.Suggested direction (not a prescription)
XYZ_to_color_temperatureand note Kelvin vs mired expectations.