IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
binning_feature.py
Go to the documentation of this file.
1from __future__ import annotations
2
3import enum
4
5from ids_peak_common.datatypes.interval import Interval
6
7from ids_peak_icv.pipeline._internal.downsampling_module import DownsamplingModule, DownsamplingMode
9
10
11class BinningMode(enum.Enum):
12 """!
13 @brief
14 Mode parameter for the binning algorithm.
15
16 The enum holding the possible modes.
17
18 @since ids_peak_icv 1.0
19 @ingroup ids_peak_icv_python_pipeline_types
20 """
21
22 BINNING_AVERAGE = 0
23 """!
24 @brief
25 The averaged pixel values of neighboring rows and/or columns are computed during binning.
26
27 @since ids_peak_icv 1.0
28 """
29
30 BINNING_SUM = 1
31 """!
32 @brief
33 The pixel values of neighboring rows and/or columns are summed during binning.
34
35 @since ids_peak_icv 1.0
36 """
37
38
40 """!
41 @brief
42 Binning is used to decrease the image size.
43
44 @supportedPixelformats{ImageTransformation}
45
46 This method reduces resolution by summarizing or averaging groups of pixels
47 in the horizontal (x) and/or vertical (y) directions.
48 It helps preserve image quality by minimizing aliasing artifacts.
49
50 @note Processes the entire image, ignoring any specified image region.
51
52 @note The alpha channel of the input image (if present) is also ignored.
53 This is because the alpha channel can have different interpretations
54 — such as transparency, segmentation labels, or masks —
55 each of which would require different handling during binning.
56 Consequently, the alpha channel of the output image is always set to the maximum possible pixel value.
57
58 @note Binning permanently reduces image resolution. The original resolution cannot be recovered
59 after binning is applied.
60
61 Default configuration:
62 - x = 1
63 - y = 1
64 - BinningMode.BinningAverage
65
66 @since ids_peak_icv 1.0
67 @ingroup ids_peak_icv_python_pipeline_features
68 """
69
70 def __init__(self, module: DownsamplingModule) -> None:
71 """!
72 @brief
73 Creates a BinningFeature for an existing downsampling module.
74
75 @param module: Reference to the underlying DownsamplingModule.
76
77 @since ids_peak_icv 1.0
78 """
79 self._module = module
80
81 @property
82 def enabled(self) -> bool:
83 """!
84 @brief
85 Gets whether this feature is currently enabled.
86
87 @return True if enabled; otherwise False.
88
89 @since ids_peak_icv 1.0
90 """
91 return self._module.enabled
92
93 @enabled.setter
94 def enabled(self, enabled: bool) -> None:
95 """!
96 @brief
97 Enables or disables the feature.
98
99 @param enabled: True to enable, False to disable.
100
101 @since ids_peak_icv 1.0
102 """
103 self._module.enabled = enabled
104
105 def reset_to_default(self) -> None:
106 """!
107 @brief
108 Resets all settings to their defaults.
109
110 Default configuration:
111 - x = 1
112 - y = 1
113 - mode = BinningMode.BinningAverage
114
115 @note The enabled state does not change when calling this function.
116
117 @since ids_peak_icv 1.0
118 """
120
121 @property
122 def x(self) -> int:
123 """!
124 @brief
125 Gets the current number of columns used for binning.
126
127 @return The current number of columns summarized/averaged during binning.
128
129 @since ids_peak_icv 1.0
130 """
131 return self._module.x
132
133 @x.setter
134 def x(self, value: int) -> None:
135 """!
136 @brief
137 Sets the number of columns used for binning.
138
139 @param value: An integer value representing the number of columns summarized/averaged during binning.
140 Valid values are within the range returned by object.range.
141 @exception OutOfRangeException: If value is outside the valid range.
142
143 @since ids_peak_icv 1.0
144 """
145 self._module.x = value
146
147 @property
148 def y(self) -> int:
149 """!
150 @brief
151 Gets the current number of rows used for binning.
152
153 @return The current number of rows summarized/averaged during binning.
154
155 @since ids_peak_icv 1.0
156 """
157 return self._module.y
158
159 @y.setter
160 def y(self, value: int) -> None:
161 """!
162 @brief
163 Sets the number of rows used for binning.
164
165 @param value: An integer value representing the number of rows summarized/averaged during binning.
166 Valid values are within the range returned by object.range.
167 @exception OutOfRangeException: If value is outside the valid range.
168
169 @since ids_peak_icv 1.0
170 """
171 self._module.y = value
172
173 @property
174 def mode(self) -> BinningMode:
175 """!
176 @brief
177 Gets the current BinningMode.
178
179 @return The current BinningMode.
180
181 @since ids_peak_icv 1.0
182 """
183 return BinningMode(self._module.mode.value)
184
185 @mode.setter
186 def mode(self, value: BinningMode) -> None:
187 """!
188 @brief
189 Sets the BinningMode.
190
191 @param value: The BinningMode to set.
192
193 @since ids_peak_icv 1.0
194 """
195 self._module.mode = DownsamplingMode(value.value)
196
197 @property
198 def range(self) -> Interval:
199 """!
200 @brief
201 Gets the valid range for the binning factors x and y.
202
203 The returned interval specifies the minimum and maximum values that can be passed to object.x or object.y.
204
205 @return An Interval representing the valid binning factor range.
206
207 @since ids_peak_icv 1.0
208 """
209 return self._module.range
None reset_to_default(self)
Resets all settings to their defaults.
None __init__(self, DownsamplingModule module)
Creates a BinningFeature for an existing downsampling module.
int y(self)
Gets the current number of rows used for binning.
bool enabled(self)
Gets whether this feature is currently enabled.
int x(self)
Gets the current number of columns used for binning.
Interval range(self)
Gets the valid range for the binning factors x and y.
BinningMode mode(self)
Gets the current BinningMode.
Abstract base class for all image processing pipeline features.
Definition ifeature.py:6