IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
gamma_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.tone_curve_correction_module import ToneCurveCorrectionModule
6
7
9 """!
10 @brief
11 Gamma applies an inverse gamma transformation to an image.
12
13 @supportedPixelformats{ToneCurveCorrection}
14
15 This module adjusts the image luminance by applying an inverse gamma correction.
16 This prepares the image for a linear domain or further processing.
17
18 The correction is applied independently to each channel in the image.
19 For RGB images, it is applied to each color channel (R, G, B),
20 and for monochrome images, it is applied to the single intensity channel.
21
22 The correction is performed using the following formula: `color_value ^ (1.0 / gamma)`
23
24 @warning Gamma values close to zero may result in very dark images,
25 while very high values may cause loss of detail in dark areas.
26 Use values within the range returned by range property.
27
28 The default value for gamma is 1.0.
29
30 @since ids_peak_icv 1.0
31 @ingroup ids_peak_icv_python_pipeline_features
32 """
33
34 def __init__(self, module: ToneCurveCorrectionModule) -> None:
35 """!
36 @brief
37 Creates a gamma feature for an existing tone curve correction module.
38 @param module: Reference to the underlying module
39 """
40 self._module = module
41
42 @property
43 def enabled(self) -> bool:
44 """!
45 @brief
46 Gets whether this feature is currently enabled.
47
48 @return True if enabled; otherwise False.
49
50 @since ids_peak_icv 1.0
51 """
52 return self._module.gamma_enabled
53
54 @enabled.setter
55 def enabled(self, enabled: bool) -> None:
56 """!
57 @brief
58 Enables or disables the feature.
59
60 @param enabled: True to enable, False to disable.
61
62 @since ids_peak_icv 1.0
63 """
64 self._module.gamma_enabled = enabled
65
66 def reset_to_default(self) -> None:
67 """!
68 @brief
69 Resets the gamma value to its default value (1.0).
70
71 @note The enabled state does not change when calling this function.
72
73 @since ids_peak_icv 1.0
74 """
75 self.valuevaluevalue = 1.0
76
77 @property
78 def value(self) -> float:
79 """!
80 @brief
81 Gets the current gamma correction exponent.
82 @return The gamma exponent currently set.
83
84 @since ids_peak_icv 1.0
85 """
86 return self._module.gamma
87
88 @value.setter
89 def value(self, gamma: float) -> None:
90 """!
91 @brief
92 Sets the gamma correction exponent.
93
94 This value determines the degree of inverse gamma correction applied during processing,
95 where output values are computed as input ^ (1/gamma).
96 Higher gamma values lighten the image, while values closer to zero darken it.
97
98 @param gamma: A floating-point value representing the gamma exponent.
99 Valid values are within the range returned by range property.
100
101 @exception OutOfRangeException: If gamma is outside the valid range.
102
103 @since ids_peak_icv 1.0
104 """
105 self._module.gamma = gamma
106
107 @property
108 def range(self) -> Interval:
109 """!
110 @brief
111 Retrieves the valid range for the gamma correction exponent.
112
113 The returned interval specifies the minimum and maximum values that can be passed to value property.
114
115 @return An Interval representing the valid gamma range.
116
117 @since ids_peak_icv 1.0
118 """
119 return self._module.gamma_range
Gamma applies an inverse gamma transformation to an image.
None reset_to_default(self)
Resets the gamma value to its default value (1.0).
float value(self)
Gets the current gamma correction exponent.
None value(self, float gamma)
Sets the gamma correction exponent.
None __init__(self, ToneCurveCorrectionModule module)
Creates a gamma feature for an existing tone curve correction module.
bool enabled(self)
Gets whether this feature is currently enabled.
Interval range(self)
Retrieves the valid range for the gamma correction exponent.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6