IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
gain_feature.py
Go to the documentation of this file.
1from __future__ import annotations
2
3from ids_peak_common.datatypes.interval import Interval
4from ids_peak_icv.pipeline._internal import GainModule
6
7
9 """!
10 @brief
11 Gain is an image pipeline feature that applies gain correction to an image.
12
13 @supportedPixelformats{Gain}
14
15 Gain is used to adjust pixel intensities either uniformly across all color channels using the master gain,
16 or individually per channel using the red, green, and blue gains.
17 With master gain, image brightness can be increased.
18 With color gains, the white balance can be adjusted.
19 For color images, gain is applied as follows::
20
21 red_value_out = red_value_in * red_gain * master_gain
22 green_value_out = green_value_in * green_gain * master_gain
23 blue_value_out = blue_value_in * blue_gain * master_gain
24
25 where red_value_in, green_value_in, and blue_value_in are the input red, green, and blue channel values, respectively,
26 and red_value_out, green_value_out, and blue_value_out are the corresponding output values.
27 All RGB values are normalized to the range [0.0, 1.0].
28 For mono images, the color gains are ignored and applied as follows::
29
30 gray_value_out = gray_value_in * master_gain
31
32 where gray_value_in is the input and gray_value_out the output value, normalized to the range [0.0, 1.0].
33
34 Warning: Excessive gain values may cause clipping and loss of image detail in bright areas.
35
36 Default configuration:
37 - Master gain = 1.0
38 - Red gain = 1.0
39 - Green gain = 1.0
40 - Blue gain = 1.0
41
42 @since ids_peak_icv 1.0
43 @ingroup ids_peak_icv_python_pipeline_features
44 """
45
46 def __init__(self, module: GainModule) -> None:
47 """!
48 @brief
49 Creates a gain feature for an existing gain module.
50 @param module: Reference to the underlying module
51
52 @since ids_peak_icv 1.0
53 """
54 self._module = module
55
56 @property
57 def enabled(self) -> bool:
58 """!
59 @brief
60 Gets whether this feature is currently enabled.
61
62 @return True if enabled; otherwise False.
63
64 @since ids_peak_icv 1.0
65 """
66 return self._module.enabled
67
68 @enabled.setter
69 def enabled(self, enabled: bool) -> None:
70 """!
71 @brief
72 Enables or disables the feature.
73
74 @param enabled: True to enable, False to disable.
75
76 @since ids_peak_icv 1.0
77 """
78 self._module.enabled = enabled
79
80 def reset_to_default(self) -> None:
81 """!
82 @brief
83 Resets the all gain values to their default value (1.0).
84
85 @note The enabled state does not change when calling this function.
86
87 @since ids_peak_icv 1.0
88 """
90
91 @property
92 def red(self) -> float:
93 """!
94 @brief
95 Retrieves the current red gain.
96 @return The current red gain.
97
98 @since ids_peak_icv 1.0
99 """
100 return self._module.red
101
102 @red.setter
103 def red(self, value: float) -> None:
104 """!
105 @brief
106 Sets the red gain value.
107
108 Sets the color gain for the red channel. The valid range for the gain value can be
109 obtained using the range property.
110
111 @param value: The red gain value to set.
112
113 @exception OutOfRangeException: If the gain value is outside the valid range.
114
115 @since ids_peak_icv 1.0
116 """
117 self._module.red = value
118
119 @property
120 def green(self) -> float:
121 """!
122 @brief
123 Retrieves the current green gain.
124 @return The current green gain.
125
126 @since ids_peak_icv 1.0
127 """
128 return self._module.green
129
130 @green.setter
131 def green(self, value: float) -> None:
132 """!
133 @brief
134 Sets the green gain value.
135
136 Sets the color gain for the green channel. The valid range for the gain value can be
137 obtained using the range property.
138
139 @param value: The green gain value to set.
140
141 @exception OutOfRangeException: If the gain value is outside the valid range.
142
143 @since ids_peak_icv 1.0
144 """
145 self._module.green = value
146
147 @property
148 def blue(self) -> float:
149 """!
150 @brief
151 Retrieves the current blue gain.
152 @return The current blue gain.
153
154 @since ids_peak_icv 1.0
155 """
156 return self._module.blue
157
158 @blue.setter
159 def blue(self, value: float) -> None:
160 """!
161 @brief
162 Sets the blue gain value.
163
164 Sets the color gain for the blue channel. The valid range for the gain value can be
165 obtained using the range property.
166
167 @param value: The blue gain value to set.
168
169 @exception OutOfRangeException: If the gain value is outside the valid range.
170
171 @since ids_peak_icv 1.0
172 """
173 self._module.blue = value
174
175 @property
176 def master(self) -> float:
177 """!
178 @brief
179 Retrieves the current master gain.
180 @return The current master gain.
181
182 @since ids_peak_icv 1.0
183 """
184 return self._module.master
185
186 @master.setter
187 def master(self, value: float) -> None:
188 """!
189 @brief
190 Sets the master gain value.
191
192 Sets the color gain for the master channel. The valid range for the gain value can be
193 obtained using the range property.
194
195 @param value: The master gain value to set.
196
197 @exception OutOfRangeException: If the gain value is outside the valid range.
198
199 @since ids_peak_icv 1.0
200 """
201 self._module.master = value
202
203 @property
204 def range(self) -> Interval:
205 """!
206 @brief
207 Retrieves the valid range for the gamma correction exponent.
208
209 The returned interval specifies the minimum and maximum values that can be passed to value property.
210
211 @return An Interval representing the valid gamma range.
212
213 @since ids_peak_icv 1.0
214 """
215 return self._module.range
Gain is an image pipeline feature that applies gain correction to an image.
None reset_to_default(self)
Resets the all gain values to their default value (1.0).
float red(self)
Retrieves the current red gain.
None __init__(self, GainModule module)
Creates a gain feature for an existing gain module.
float green(self)
Retrieves the current green gain.
float blue(self)
Retrieves the current blue gain.
bool enabled(self)
Gets whether this feature is currently enabled.
Interval range(self)
Retrieves the valid range for the gamma correction exponent.
float master(self)
Retrieves the current master gain.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6