IDS peak ICV v1.2.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 Indicates whether the feature is currently enabled.
86 @return True if enabled; otherwise, False.
87
88 @since ids_peak_icv 1.0
89 """
90 return self._module.enabled
91
92 @enabled.setter
93 def enabled(self, value: bool) -> None:
94 """!
95 @brief
96 Enables or disables the feature.
97 @param value: Set to True to enable the feature, or False to disable it.
98
99 @since ids_peak_icv 1.0
100 """
101 self._module.enabled = value
102
103 def reset_to_default(self) -> None:
104 """!
105 @brief
106 Resets all settings to the default configuration:
107 - x = 1
108 - y = 1
109 - BinningMode.BinningAverage
110
111 @note The enabled state does not change when calling this function.
112
113 @since ids_peak_icv 1.0
114 """
116
117 @property
118 def x(self) -> int:
119 """!
120 @brief
121 Gets the current number of columns used for binning.
122
123 @return The current number of columns summarized/averaged during binning.
124
125 @since ids_peak_icv 1.0
126 """
127 return self._module.x
128
129 @x.setter
130 def x(self, value: int) -> None:
131 """!
132 @brief
133 Sets the number of columns used for binning.
134
135 @param value: An integer value representing the number of columns summarized/averaged during binning.
136 Valid values are within the range returned by object.range.
137 @exception OutOfRangeException: If value is outside the valid range.
138
139 @since ids_peak_icv 1.0
140 """
141 self._module.x = value
142
143 @property
144 def y(self) -> int:
145 """!
146 @brief
147 Gets the current number of rows used for binning.
148
149 @return The current number of rows summarized/averaged during binning.
150
151 @since ids_peak_icv 1.0
152 """
153 return self._module.y
154
155 @y.setter
156 def y(self, value: int) -> None:
157 """!
158 @brief
159 Sets the number of rows used for binning.
160
161 @param value: An integer value representing the number of rows summarized/averaged during binning.
162 Valid values are within the range returned by object.range.
163 @exception OutOfRangeException: If value is outside the valid range.
164
165 @since ids_peak_icv 1.0
166 """
167 self._module.y = value
168
169 @property
170 def mode(self) -> BinningMode:
171 """!
172 @brief
173 Gets the current BinningMode.
174
175 @return The current BinningMode.
176
177 @since ids_peak_icv 1.0
178 """
179 return BinningMode(self._module.mode.value)
180
181 @mode.setter
182 def mode(self, value: BinningMode) -> None:
183 """!
184 @brief
185 Sets the BinningMode.
186
187 @param value: The BinningMode to set.
188
189 @since ids_peak_icv 1.0
190 """
191 self._module.mode = DownsamplingMode(value.value)
192
193 @property
194 def range(self) -> Interval:
195 """!
196 @brief
197 Gets the valid range for the binning factors x and y.
198
199 The returned interval specifies the minimum and maximum values that can be passed to object.x or object.y.
200
201 @return An Interval representing the valid binning factor range.
202
203 @since ids_peak_icv 1.0
204 """
205 return self._module.range
None reset_to_default(self)
Resets all settings to the default configuration:
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)
Indicates whether the 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