IDS peak ICV v1.1.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 All input and output values are in the normalized range [0.0, 1.0].
25
26 @warning Gamma values close to zero may result in very dark images,
27 while very high values may cause loss of detail in dark areas.
28 Use values within the range returned by range property.
29
30 The default value for gamma is 1.0.
31
32 @since ids_peak_icv 1.0
33 @ingroup ids_peak_icv_python_pipeline_features
34 """
35
36 def __init__(self, module: ToneCurveCorrectionModule) -> None:
37 """!
38 @brief
39 Creates a gamma feature for an existing tone curve correction module.
40 @param module: Reference to the underlying module
41 """
42 self._module = module
43
44 @property
45 def enabled(self) -> bool:
46 """!
47 @brief
48 Indicates whether the feature is currently enabled.
49 @return True if enabled; otherwise, False.
50
51 @since ids_peak_icv 1.0
52 """
53 return self._module.gamma_enabled
54
55 @enabled.setter
56 def enabled(self, value: bool) -> None:
57 """!
58 @brief
59 Enables or disables the feature.
60 @param value: Set to True to enable the feature, or False to disable it.
61
62 @since ids_peak_icv 1.0
63 """
64 self._module.gamma_enabled = value
65
66 def reset_to_default(self) -> None:
67 """!
68 @brief
69 Resets the gamma value to 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 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)
Indicates whether the 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