IDS peak ICV v1.1.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 Indicates whether the feature is currently enabled.
61 @return True if enabled; otherwise, False.
62
63 @since ids_peak_icv 1.0
64 """
65 return self._module.enabled
66
67 @enabled.setter
68 def enabled(self, value: bool) -> None:
69 """!
70 @brief
71 Enables or disables the feature.
72 @param value: Set to True to enable the feature, or False to disable it.
73
74 @since ids_peak_icv 1.0
75 """
76 self._module.enabled = value
77
78 def reset_to_default(self) -> None:
79 """!
80 @brief
81 Resets the all gain values to 1.0.
82
83 @note The enabled state does not change when calling this function.
84
85 @since ids_peak_icv 1.0
86 """
88
89 @property
90 def red(self) -> float:
91 """!
92 @brief
93 Retrieves the current red gain.
94 @return The current red gain.
95
96 @since ids_peak_icv 1.0
97 """
98 return self._module.red
99
100 @red.setter
101 def red(self, value: float) -> None:
102 """!
103 @brief
104 Sets the red gain value.
105
106 Sets the color gain for the red channel. The valid range for the gain value can be
107 obtained using the range property.
108
109 @param value: The red gain value to set.
110
111 @exception OutOfRangeException: If the gain value is outside the valid range.
112
113 @since ids_peak_icv 1.0
114 """
115 self._module.red = value
116
117 @property
118 def green(self) -> float:
119 """!
120 @brief
121 Retrieves the current green gain.
122 @return The current green gain.
123
124 @since ids_peak_icv 1.0
125 """
126 return self._module.green
127
128 @green.setter
129 def green(self, value: float) -> None:
130 """!
131 @brief
132 Sets the green gain value.
133
134 Sets the color gain for the green channel. The valid range for the gain value can be
135 obtained using the range property.
136
137 @param value: The green gain value to set.
138
139 @exception OutOfRangeException: If the gain value is outside the valid range.
140
141 @since ids_peak_icv 1.0
142 """
143 self._module.green = value
144
145 @property
146 def blue(self) -> float:
147 """!
148 @brief
149 Retrieves the current blue gain.
150 @return The current blue gain.
151
152 @since ids_peak_icv 1.0
153 """
154 return self._module.blue
155
156 @blue.setter
157 def blue(self, value: float) -> None:
158 """!
159 @brief
160 Sets the blue gain value.
161
162 Sets the color gain for the blue channel. The valid range for the gain value can be
163 obtained using the range property.
164
165 @param value: The blue gain value to set.
166
167 @exception OutOfRangeException: If the gain value is outside the valid range.
168
169 @since ids_peak_icv 1.0
170 """
171 self._module.blue = value
172
173 @property
174 def master(self) -> float:
175 """!
176 @brief
177 Retrieves the current master gain.
178 @return The current master gain.
179
180 @since ids_peak_icv 1.0
181 """
182 return self._module.master
183
184 @master.setter
185 def master(self, value: float) -> None:
186 """!
187 @brief
188 Sets the master gain value.
189
190 Sets the color gain for the master channel. The valid range for the gain value can be
191 obtained using the range property.
192
193 @param value: The master gain value to set.
194
195 @exception OutOfRangeException: If the gain value is outside the valid range.
196
197 @since ids_peak_icv 1.0
198 """
199 self._module.master = value
200
201 @property
202 def range(self) -> Interval:
203 """!
204 @brief
205 Retrieves the valid range for the gamma correction exponent.
206
207 The returned interval specifies the minimum and maximum values that can be passed to value property.
208
209 @return An Interval representing the valid gamma range.
210
211 @since ids_peak_icv 1.0
212 """
213 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 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)
Indicates whether the 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