Skip to content

Commit 39b87ee

Browse files
authored
Merge pull request #100 from ampas/feature/exclude_k_from_clf_export
Feature/exclude k from clf export
2 parents 8d207e4 + 1d80c8f commit 39b87ee

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

aces/idt/core/common.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ def clf_processing_elements(
428428
use_range: bool = True,
429429
include_white_balance_in_clf: bool = False,
430430
flatten_clf: bool = True,
431+
include_exposure_factor_in_clf: bool = False,
431432
) -> Et.Element:
432433
"""
433434
Add the *Common LUT Format* (CLF) elements for given *IDT* matrix,
@@ -449,6 +450,8 @@ def clf_processing_elements(
449450
Whether to include the white balance multipliers in the *CLF*.
450451
flatten_clf
451452
Whether to flatten the *CLF*. into a single 1D Lut & 1 3x3 Matrix
453+
include_exposure_factor_in_clf
454+
Whether to include the exposure factor :math:`k` in the *CLF*.
452455
453456
Returns
454457
-------
@@ -493,14 +496,15 @@ def format_array(a: NDArrayFloat) -> str:
493496
et_max_out_value = Et.SubElement(et_range, "maxOutValue")
494497
et_max_out_value.text = "1"
495498

496-
et_k = Et.SubElement(root, "Matrix", inBitDepth="32f", outBitDepth="32f")
497-
et_description = Et.SubElement(et_k, "Description")
498-
et_description.text = (
499-
'Exposure factor *k* that results in a nominally "18% gray" object in '
500-
"the scene producing ACES values [0.18, 0.18, 0.18]."
501-
)
502-
et_array = Et.SubElement(et_k, "Array", dim="3 3")
503-
et_array.text = f"\n\t\t{format_array(np.ravel(np.diag([k_factor] * 3)))}"
499+
if include_exposure_factor_in_clf:
500+
et_k = Et.SubElement(root, "Matrix", inBitDepth="32f", outBitDepth="32f")
501+
et_description = Et.SubElement(et_k, "Description")
502+
et_description.text = (
503+
'Exposure factor *k* that results in a nominally "18% gray" object in '
504+
"the scene producing ACES values [0.18, 0.18, 0.18]."
505+
)
506+
et_array = Et.SubElement(et_k, "Array", dim="3 3")
507+
et_array.text = f"\n\t\t{format_array(np.ravel(np.diag([k_factor] * 3)))}"
504508

505509
et_M = Et.SubElement(root, "Matrix", inBitDepth="32f", outBitDepth="32f")
506510
et_description = Et.SubElement(et_M, "Description")
@@ -510,6 +514,11 @@ def format_array(a: NDArrayFloat) -> str:
510514

511515
else:
512516
# If we are flattening the clf we output just a single matrix into the clf
517+
518+
# If we do not include the k factor, we set it to 1.0 so it becomes and identity
519+
# matrix and has no affect
520+
if not include_exposure_factor_in_clf:
521+
k_factor = 1.0
513522
output_matrix = np.diag([k_factor] * 3) @ matrix
514523
if include_white_balance_in_clf:
515524
output_matrix = np.diag(multipliers) @ np.diag([k_factor] * 3) @ matrix

aces/idt/core/constants.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@ class ProjectSettingsMetadataConstants:
460460
ui_category=UICategories.STANDARD,
461461
)
462462

463+
INCLUDE_EXPOSURE_FACTOR_IN_CLF = Metadata(
464+
name="include_exposure_factor_in_clf",
465+
default_value=False,
466+
description="Whether to include the exposure factor (K) in the CLF",
467+
display_name="Include Exposure Factor in CLF",
468+
ui_type=UITypes.BOOLEAN_FIELD,
469+
ui_category=UICategories.STANDARD,
470+
)
471+
463472
ALL: ClassVar[tuple[Metadata, ...]] = (
464473
SCHEMA_VERSION,
465474
CAMERA_MAKE,
@@ -493,4 +502,5 @@ class ProjectSettingsMetadataConstants:
493502
OPTIMIZATION_KWARGS,
494503
INCLUDE_WHITE_BALANCE_IN_CLF,
495504
FLATTEN_CLF,
505+
INCLUDE_EXPOSURE_FACTOR_IN_CLF,
496506
)

aces/idt/framework/project_settings.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ def __init__(self, **kwargs: Dict):
181181
IDTProjectSettings.flatten_clf.metadata.name,
182182
IDTProjectSettings.flatten_clf.metadata.default_value,
183183
)
184+
self._include_exposure_factor_in_clf = kwargs.get(
185+
IDTProjectSettings.include_exposure_factor_in_clf.metadata.name,
186+
IDTProjectSettings.include_exposure_factor_in_clf.metadata.default_value,
187+
)
184188

185189
@metadata_property(metadata=MetadataConstants.SCHEMA_VERSION)
186190
def schema_version(self) -> str:
@@ -598,6 +602,18 @@ def flatten_clf(self) -> str:
598602

599603
return self._flatten_clf
600604

605+
@metadata_property(metadata=MetadataConstants.INCLUDE_EXPOSURE_FACTOR_IN_CLF)
606+
def include_exposure_factor_in_clf(self) -> bool:
607+
"""
608+
Getter property for whether to include the exposure factor (K) in the *CLF*.
609+
610+
Returns
611+
-------
612+
:class:`bool`
613+
Whether to include the exposure factor (K) in the *CLF*.
614+
"""
615+
return self._include_exposure_factor_in_clf
616+
601617
def get_reference_colour_checker_samples(self) -> NDArrayFloat:
602618
"""
603619
Return the reference colour checker samples.

aces/idt/generators/base_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,7 @@ def format_array(a):
837837
False,
838838
self.project_settings.include_white_balance_in_clf,
839839
self.project_settings.flatten_clf,
840+
self.project_settings.include_exposure_factor_in_clf,
840841
)
841842

842843
clf_path = (

tests/resources/example_from_folder.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"camera_make": "",
77
"camera_model": "",
88
"include_white_balance_in_clf": false,
9+
"include_exposure_factor_in_clf": false,
910
"flatten_clf": false,
1011
"iso": 800,
1112
"temperature": 6000,

0 commit comments

Comments
 (0)