IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
chromatic_adaption_feature.py
Go to the documentation of this file.
1from __future__ import annotations
2
3import enum
4from ids_peak_common.datatypes.range import Range
6 ColorMatrixTransformationModule
7)
8from ids_peak_icv.pipeline.datatypes import ColorSpace, ChromaticAdaptionAlgorithm
10
11
13 """!
14 @brief
15 Adjusts to changes in lighting conditions to maintain consistent color perception
16 despite variations in light sources.
17
18 In industrial imaging, white balance can fail due to the lack of a neutral reference in the image, such as when the
19 scene contains no gray or white areas, or when the colors are unevenly distributed (as in images dominated by a single color).
20 In these cases, traditional white balance algorithms, like the gray world method, may fail to produce accurate color corrections.
21
22 Chromatic adaptation provides an alternative solution by adjusting the image’s colors based on the known or
23 estimated correlated color temperature of the light source.
24
25 @note
26 If chromatic adaption is used in combination with white balance, the result is indefinite.
27
28 Default Configuration:
29 - Chromatic adaption algorithm = Bradford
30 - Color space = SRGB_D65
31 - Color temperature = undefined (chromatic adaption won't be applied)
32
33 @since ids_peak_icv 1.3
34 @ingroup ids_peak_icv_python_pipeline_features
35 """
36
37 def __init__(self, module: ColorMatrixTransformationModule) -> None:
38 """!
39 @brief
40 Creates a ChromaticAdaptionFeature for an existing color matrix transformation module.
41
42 @param module: Reference to the underlying ColorMatrixTransformationModule.
43
44 @since ids_peak_icv 1.3
45 """
46 self._module = module
47
48 @property
49 def enabled(self) -> bool:
50 """!
51 @brief
52 Indicates whether chromatic adaptation is enabled.
53
54 @return True if enabled; otherwise, False.
55
56 @since ids_peak_icv 1.3
57 """
58 return self._module.chromatic_adaption_enabled
59
60 @enabled.setter
61 def enabled(self, value: bool) -> None:
62 """!
63 @brief
64 Enables or disables chromatic adaptation.
65
66 @param value: Set to True to enable the feature, or False to disable it.
67
68 @since ids_peak_icv 1.3
69 """
70 self._module.chromatic_adaption_enabled = value
71
72 def reset_to_default(self) -> None:
73 """!
74 @brief
75 Resets the chromatic adaption configuration to the default values.
76
77 @note The enabled state does not change when calling this function.
78
79 @since ids_peak_icv 1.3
80 """
81 self._module.reset_chromatic_adaption()
82
83 @property
84 def target_color_space(self) -> ColorSpace:
85 """!
86 @brief
87 Retrieves the current target color space.
88
89 @return The currently set color space.
90
91 @since ids_peak_icv 1.3
92 """
93 return self._module.target_color_space
94
95 @target_color_space.setter
96 def target_color_space(self, value: ColorSpace) -> None:
97 """!
98 @brief
99 Sets the target color space.
100
101 A color space is a specific implementation of a color model, mapping colors to a defined range of values
102 (e.g., standard primaries, white point, and gamma).
103
104 @param value: The color space to set.
105
106 @since ids_peak_icv 1.3
107 """
108 self._module.target_color_space = value
109
110 @property
111 def algorithm(self) -> ChromaticAdaptionAlgorithm:
112 """!
113 @brief
114 Retrieves the current chromatic adaption algorithm.
115
116 @return The currently set chromatic adaption algorithm.
117
118 @since ids_peak_icv 1.3
119 """
120 return self._module.chromatic_adaption_algorithm
121
122 @algorithm.setter
123 def algorithm(self, value: ChromaticAdaptionAlgorithm) -> None:
124 """!
125 @brief
126 Sets the algorithm used for chromatic adaption.
127
128 The algorithms use a CAT (chromatic adaptation transform) matrix.
129
130 @param value: The chromatic adaption algorithm to set.
131
132 @since ids_peak_icv 1.3
133 """
134 self._module.chromatic_adaption_algorithm = value
135
136 @property
137 def color_temperature(self) -> int:
138 """!
139 @brief
140 Retrieves the current color temperature.
141
142 @return The current color temperature in Kelvin.
143
144 @exception NotPossibleException: If the color temperature has not been set (it has no default value).
145
146 @since ids_peak_icv 1.3
147 """
148 return self._module.color_temperature
149
150 @color_temperature.setter
151 def color_temperature(self, value: int) -> None:
152 """!
153 @brief
154 Sets the color temperature of the light source.
155 If no color temperature is explicitly set the chromatic adaption won't be applied.
156
157 @param value: The color temperature in Kelvin to set. Must be within the allowed range.
158
159 @since ids_peak_icv 1.3
160 """
161 self._module.color_temperature = value
162
163 def has_color_temperature(self) -> bool:
164 """!
165 @brief
166 Checks whether a color temperature has been set.
167
168 @return True if a color temperature is set, False otherwise.
169
170 @since ids_peak_icv 1.3
171 """
172 return self._module.has_color_temperature()
173
174 @property
175 def color_temperature_range(self) -> Range:
176 """!
177 @brief
178 Returns the allowed temperature range for the current combination of color space and algorithm.
179
180 @return A Range representing the allowed temperature range in Kelvin.
181
182 @since ids_peak_icv 1.3
183 """
184 return self._module.color_temperature_range
Adjusts to changes in lighting conditions to maintain consistent color perception despite variations ...
None reset_to_default(self)
Resets the chromatic adaption configuration to the default values.
None __init__(self, ColorMatrixTransformationModule module)
Creates a ChromaticAdaptionFeature for an existing color matrix transformation module.
ChromaticAdaptionAlgorithm algorithm(self)
Retrieves the current chromatic adaption algorithm.
Range color_temperature_range(self)
Returns the allowed temperature range for the current combination of color space and algorithm.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6