PR: Add TLCI-2012 and TLMF-2013 quality metrics#1408
Conversation
Implement the EBU Tech 3355 Television Lighting Consistency Index and Television Luminaire Matching Factor calculations, including the standard camera model, TLMF exposure normalisation, Tech 3355 reference-locus CCT selection, reference illuminant selection, and reported result data. Add the EBU Tech 3355 Appendix 2 Planckian and daylight chromaticity tables, Appendix 3 daylight radiation vectors, and Appendix 4 test colour sample data used by TLCI and TLMF. Document that the coloured samples are derived from BBC R&D Report 1988/2 with small deviations in the published table, and that the greyscale samples use unpublished BBC R&D data. Reuse Colour spectral, transfer-function, colourspace, and CIE 2000 colour-difference routines for the underlying mathematics. Keep only Tech 3355-specific CCT normal-intersection and Planckian/daylight reference synthesis local, because TLCI defines those calculations against its Appendix data and reference-luminaire procedure. Preserve the Tech 3355 studio-swing signal headroom through the camera BT.709 signal path, and cap it at the 8-bit code-value limit defined by the nominal 16-235 range. Add public quality API exports, documentation, examples, and reproducible validation spectra covering Planckian, daylight, mixed-reference, phosphor-like LED, RGB LED, and TLMF matching cases. Include reference-locus distance sign, mixed-boundary, TLMF exposure, Tech 3355 Planckian-reference, CIE 2000, and test-colour sample regression tests. This provides redistributable test coverage despite the lack of official EBU reference vectors. Fixes colour-science#974 Signed-off-by: Christoph Müllner <christophm30@gmail.com>
|
CI is currently failing for two reasons. The GitHub Actions failure appears unrelated to this PR. The failing job is Codacy reports 65 new issues, mostly in the new TLCI/TLMF files:
My read is that many of these findings conflict with the existing project style: the test suite widely uses pytest assert, Ruff ignores S101 for test_* files, and several of the pydocstyle rules reported by Codacy are explicitly ignored by |
|
Hi @cmuellner, Thanks a lot! Great work. #1406 is pending and is incompatible with it at the moment so, the best way would be for me to merge it and rebase #1406 on top of it and bring it up to Array API standard compatibility. Don't worry about Codacy and the ONNX download CI issue. |
|
Thanks! If you would prefer the opposite sequencing for any reason (Python Array API lands first), I’m also happy to adjust this PR accordingly. |
|
The issue is that we might change some of our Array API Standard implementation. I will keep you posted! |
Summary
Add EBU Tech 3355 TLCI-2012 and TLMF-2013 quality metrics.
This implements:
for TLCI CCT selection.
daylight references.
including the documented BBC R&D Report 1988/2 and unpublished BBC R&D
provenance.
colourandcolour.qualityAPI exports.Fixes #974.
Implementation Notes
TLCI/TLMF was not a straightforward transcription from the public
specification. A few parts of EBU Tech 3355 require careful interpretation:
CCT/D_uv methods such as Ohno (2013) or Robertson (1968). Tech 3355 uses
the Appendix 2 Planckian and daylight chromaticity tables, scans adjacent
locus points, and computes the normal intersection using the section 1.1.1
slope/angle procedure.
regenerated blackbody or CIE daylight loci. The Planckian and daylight loci
also remain separate through the 3400-5000 K mixed-reference region.
equation [9] uses a simplified Planckian expression with wavelength in
nanometres, a
1.435e7 nm Kradiation constant, and normalisation at560 nm; this is not delegated to Colour's generic blackbody helper.
uses Appendix 3 daylight radiation vectors and Tech 3355 coefficients for
M,M1, andM2; this differs from Colour's generalsd_CIE_illuminant_D_serieshelper, which uses the library CIE D-seriesbasis data and its standard coefficient/rounding path.
Planckian 3400 K and daylight 5000 K endpoint spectra, after normalising
each endpoint at 560 nm. It is not generated from Planckian/daylight spectra
at the test source CCT.
they are not simply a direct copy of the published BBC R&D Report 1988/2
ColorChecker table. Some coloured samples differ slightly from the published
BBC table, and the greyscale samples are attributed by Tech 3355 to
unpublished BBC R&D data. The dataset is therefore documented as Tech 3355
data, with BBC R&D Report 1988/2 as partial provenance.
d_uvcalculation differs from Colour's existingCCT/D_uv methods such as Ohno (2013) and Robertson (1968): it uses the
Tech 3355 reference loci, normalises the distance by 0.0054, and reports
positive values on the magenta side and negative values on the green side.
This follows the section 1.1.1 prose that reverses the sign for green-side
offsets, where
u_T < u_L, and the section 1.1.2.3 equations [16]-[17]labels (
d > 0towards magenta,d <= 0towards green). The EBU referencebinary appears to report this secondary
d_uvvalue with the opposite sign,but the implementation follows the published specification. The reported
d_uvalso includes the Tech 3355 mixed-region adjustment between 4000 Kand 5000 K, where the Planckian and daylight loci are not joined.
balance with a test-luminaire exposure correction, matching the TLMF
procedure instead of independently white-balancing both sources as TLCI does.
The exposure correction uses the reference/test neutral luma ratio after the
camera matrix.
ColorChecker samples, while TLMF-2013 uses all 24 samples, including the
greyscale patches.
by Tech 3355 section 2, equation [61], capping at code value 255 relative
to the nominal 16-235 range instead of clipping at nominal white.
CIEDE2000 path with unity
kfactors, using Colour's existing CIE 2000implementation for the standard colour-difference calculation.
Validation
EBU Tech 3355 does not distribute official reference test vectors. The tests
therefore use reproducible generated spectral distributions covering the main
specified algorithm paths:
offsets.
coverage.
Additional local validation sets, including a 1000-case TLCI and 1000-pair
TLMF diagnostic set, were used to stress the CCT branches, mixed-reference
transition, green/magenta
d_uvsign, LED spectra, fixture-like spectra, andlow-score TLMF cases. The committed tests use only deterministic,
redistributable spectra and public in-tree spectral data; they do not depend
on local measurement files.
Because no official reference vectors are published, this PR cannot claim
independent conformance from official test data. The validation strategy is
instead:
transfer functions, and colourspace conversions;
not covered by an existing Colour routine;
algorithm branches.
Tests
isort,ruff format,ruff check,codespell,blacken-docs,check-added-large-files,check-case-conflict,check-merge-conflict,check-symlinks,check-yaml,debug-statement-hook,end-of-file-fixer,mixed-line-ending,name-tests-test, andtrailing-whitespace-fixer.prettierand the RST pygrep hooks were run throughprek; norequirements.txtfiles are touched by the commit.uv run ruff check colour/quality/tlci.py colour/quality/datasets/tlci2012.py colour/quality/datasets/__init__.py colour/quality/tests/test_tlci.pyuv run pyright --threads --skipunannotated colour/quality/tlci.py colour/quality/datasets/tlci2012.py colour/quality/tests/test_tlci.pyuv run python -m doctest colour/quality/tlci.pyuv run pytest --doctest-modules colour/quality/tlci.pyuv run pytest colour/quality/tests/test__init__.py colour/quality/tests/test_tlci.pyPreflight
Code Style and Quality
colour,colour.models.Documentation