7from ids_peak_icv
import lib_loader
24 Gain is an image pipeline module that applies gain correction to an image.
26 This module adjusts the intensity or color gain of an image by modifying
27 the master and per-channel (R, G, B) gain factors. It can be used to correct
28 image brightness or color balance after acquisition.
30 The gain correction is applied independently to each channel, and is typically
31 used as part of the early preprocessing stages of an image pipeline.
33 Default configuration:
39 @ingroup ids_peak_icv_python_pipeline_modules
40 @since ids_peak_icv 1.0
43 DEFAULT_MASTER: float = 1.0
46 Default master gain value.
48 @since ids_peak_icv 1.0
51 DEFAULT_RED: float = 1.0
54 Default red gain value.
56 @since ids_peak_icv 1.0
59 DEFAULT_GREEN: float = 1.0
62 Default green gain value.
64 @since ids_peak_icv 1.0
67 DEFAULT_BLUE: float = 1.0
70 Default blue gain value.
72 @since ids_peak_icv 1.0
75 SUPPORTED_PIXEL_FORMATS = [PixelFormat.BAYER_RG_8, PixelFormat.BAYER_RG_10, PixelFormat.BAYER_RG_12,
76 PixelFormat.BAYER_GR_8, PixelFormat.BAYER_GR_10, PixelFormat.BAYER_GR_12,
77 PixelFormat.BAYER_BG_8, PixelFormat.BAYER_BG_10, PixelFormat.BAYER_BG_12,
78 PixelFormat.BAYER_GB_8, PixelFormat.BAYER_GB_10, PixelFormat.BAYER_GB_12,
79 PixelFormat.MONO_8, PixelFormat.MONO_10, PixelFormat.MONO_12, PixelFormat.MONO_16]
84 Creates an instance of the gain module.
85 @since ids_peak_icv 1.0
95 execute_and_map_return_codes(
96 lib_loader.dll().peak_icv_Preprocessing_Gain_Create,
101 if getattr(self,
"_handle",
None):
102 lib_loader.dll().peak_icv_Preprocessing_Gain_Destroy(self.
_handle)
108 Returns the type of the module for serialization purposes.
110 @since ids_peak_icv 1.0
117 Resets all gain values to defaults.
119 Master, Red, Green, and Blue gains are all reset to 1.0.
120 @since ids_peak_icv 1.0
136 Returns the current master gain value.
137 @since ids_peak_icv 1.0
145 Sets the master gain.
147 @param value: Gain value within the valid range returned by :py:meth:`range`.
148 @exception OutOfRangeException: If value is outside the valid range.
149 @since ids_peak_icv 1.0
152 self.
_apply(_GainType.MASTER, value)
158 Returns the current red gain value.
159 @since ids_peak_icv 1.0
164 def red(self, value: float) ->
None:
167 Sets the red channel gain.
169 @param value: Gain value within valid range.
170 @since ids_peak_icv 1.0
173 self.
_apply(_GainType.RED, value)
179 Returns the current green gain value.
180 @since ids_peak_icv 1.0
185 def green(self, value: float) ->
None:
188 Sets the green channel gain.
190 @param value: Gain value within valid range.
191 @since ids_peak_icv 1.0
194 self.
_apply(_GainType.GREEN, value)
200 Returns the current blue gain value.
201 @since ids_peak_icv 1.0
206 def blue(self, value: float) ->
None:
209 Sets the blue channel gain.
211 @param value: Gain value within valid range.
212 @since ids_peak_icv 1.0
215 self.
_apply(_GainType.BLUE, value)
221 Returns the valid range for all gain values.
223 The range applies to master and per-channel gains.
225 @return Interval representing the valid min/max gain values.
226 @since ids_peak_icv 1.0
230 execute_and_map_return_codes(
231 lib_loader.dll().peak_icv_Preprocessing_Gain_GetRange,
233 ctypes.pointer(c_interval)
235 return Interval(c_interval.minimum, c_interval.maximum)
237 def process(self, input_image: Image) -> Image:
240 Processes the input image by applying gain correction (if enabled).
242 @supportedPixelformats{Gain}
244 @param input_image: Input image to be processed.
245 @return Processed output image.
246 @since ids_peak_icv 1.0
254 input_handle = input_image._handle
255 execute_and_map_return_codes(
256 lib_loader.dll().peak_icv_Preprocessing_Gain_ProcessInplace,
265 Serializes the module’s internal state into an archive.
267 @return Serialized archive containing all parameters.
268 @since ids_peak_icv 1.0
279 Restores the module’s state from an archive.
281 @param archive: Archive containing the serialized state.
282 @exception CorruptedException: If the archive is malformed.
283 @exception NotSupportedException: If version is unsupported.
285 @since ids_peak_icv 1.0
294 def _apply(self, gain_type: _GainType, value: float) ->
None:
295 execute_and_map_return_codes(
296 lib_loader.dll().peak_icv_Preprocessing_Gain_SetValue,
298 ctypes.c_int(gain_type.value),
299 ctypes.c_float(value),
302 def _fetch(self, gain_type: _GainType) -> float:
303 value = ctypes.c_float()
304 execute_and_map_return_codes(
305 lib_loader.dll().peak_icv_Preprocessing_Gain_GetValue,
307 ctypes.c_int(gain_type.value),
308 ctypes.pointer(value),
Represents an interval with lower and upper boundaries.
Interface for modules that provide gain control functionality.
float red(self)
Retrieves the gain value for the red channel.
None master(self, float value)
Sets the master gain value.
float green(self)
Retrieves the gain value for the green channel.
None blue(self, float value)
Sets the gain value for the blue channel.
float blue(self)
Retrieves the gain value for the blue channel.
None red(self, float value)
Sets the gain value for the red channel.
float master(self)
Retrieves the current master gain value.
None green(self, float value)
Sets the gain value for the green channel.
Gain is an image pipeline module that applies gain correction to an image.
None reset_to_default(self)
Resets all gain values to defaults.
float red(self)
Returns the current red gain value.
None deserialize(self, IArchive archive)
Restores the module’s state from an archive.
list SUPPORTED_PIXEL_FORMATS
None master(self, float value)
Sets the master gain.
float green(self)
Returns the current green gain value.
None blue(self, float value)
Sets the blue channel gain.
None _apply(self, _GainType gain_type, float value)
str type(self)
Returns the type of the module for serialization purposes.
float blue(self)
Returns the current blue gain value.
Image process(self, Image input_image)
Processes the input image by applying gain correction (if enabled).
None __init__(self)
Creates an instance of the gain module.
None red(self, float value)
Sets the red channel gain.
Interval range(self)
Returns the valid range for all gain values.
None serialize(self, IArchive archive)
Serializes the module’s internal state into an archive.
float master(self)
Returns the current master gain value.
None green(self, float value)
Sets the green channel gain.
float _fetch(self, _GainType gain_type)
Base class for all pipeline modules.