IDS peak ICV v1.2.0
Loading...
Searching...
No Matches
peak_icv_binning_feature.hpp
Go to the documentation of this file.
1
11#pragma once
12
17
18namespace peak
19{
20namespace pipeline
21{
22namespace features
23{
24
54{
55public:
64
68 void SetEnabled(bool enabled) override;
69
73 PEAK_COMMON_NO_DISCARD bool IsEnabled() const override;
74
82 void ResetToDefault() override;
83
94 void SetX(uint32_t x);
95
106 void SetY(uint32_t y);
107
115 PEAK_COMMON_NO_DISCARD uint32_t GetX() const;
116
124 PEAK_COMMON_NO_DISCARD uint32_t GetY() const;
125
135 PEAK_COMMON_NO_DISCARD peak::common::IntervalU GetRange() const;
136
146 void SetMode(const BinningMode& mode);
147
155 PEAK_COMMON_NO_DISCARD BinningMode GetMode() const;
156
157private:
159};
160
162 : m_module(module)
163{}
164
165inline void BinningFeature::SetEnabled(bool enabled)
166{
167 m_module.SetEnabled(enabled);
168}
169
170inline bool BinningFeature::IsEnabled() const
171{
172 return m_module.IsEnabled();
173}
174
176{
177 m_module.ResetToDefault();
178}
179
180inline void BinningFeature::SetX(uint32_t x)
181{
182 try
183 {
184 m_module.SetX(x);
185 }
186 catch (const peak::icv::OutOfRangeException&)
187 {
188 const auto range = m_module.GetRange();
189 throw peak::icv::OutOfRangeException("The specified binning factor " + std::to_string(x)
190 + " is incorrect; the expected value must be between " + std::to_string(range.GetMinimum()) + " and "
191 + std::to_string(range.GetMaximum()) + ".");
192 }
193}
194
195inline void BinningFeature::SetY(uint32_t y)
196{
197 try
198 {
199 m_module.SetY(y);
200 }
201 catch (const peak::icv::OutOfRangeException&)
202 {
203 const auto range = m_module.GetRange();
204 throw peak::icv::OutOfRangeException("The specified binning factor " + std::to_string(y)
205 + " is incorrect; the expected value must be between " + std::to_string(range.GetMinimum()) + " and "
206 + std::to_string(range.GetMaximum()) + ".");
207 }
208}
209
210inline uint32_t BinningFeature::GetX() const
211{
212 return m_module.GetX();
213}
214
215inline uint32_t BinningFeature::GetY() const
216{
217 return m_module.GetY();
218}
219
221{
222 return m_module.GetRange();
223}
224
225inline void BinningFeature::SetMode(const BinningMode& mode)
226{
227 if (mode != BinningMode::Sum && mode != BinningMode::Average)
228 {
229 throw peak::icv::NotSupportedException("The binning mode is not supported");
230 }
231 try
232 {
233 m_module.SetMode(static_cast<detail::DownsamplingMode>(mode));
234 }
236 {
237 throw peak::icv::NotSupportedException("The binning mode is not supported");
238 }
239}
240
242{
243 return static_cast<BinningMode>(m_module.GetMode());
244}
245
246} // namespace features
247} // namespace pipeline
248} // namespace peak
Represents a continuous numeric interval with inclusive lower and upper bounds.
Thrown when a requested operation is not implemented or supported.
Thrown when a value is outside the allowed range.
Downsampling is used to decrease the image size.
uint32_t GetY() const
Returns the current number of rows used for downsampling.
DownsamplingMode GetMode() const
Returns the current DownsamplingMode.
void SetMode(const DownsamplingMode &mode)
Sets the DownsamplingMode.
uint32_t GetX() const
Returns the current number of columns used for downsampling.
void SetEnabled(bool enabled) override
Sets the enabled state of this module.
void SetY(uint32_t y)
Sets the number of rows to downsample.
void SetX(uint32_t x)
Sets the number of columns to downsample.
peak::common::IntervalU GetRange() const
Returns the valid range for downsampling factors x and y.
void ResetToDefault() override
Resets all settings to default values, except the CustomType.
bool IsEnabled() const override
Checks if the module is currently enabled.
Binning is used to decrease the image size.
uint32_t GetY() const
Gets the current number of rows used for binning.
void SetMode(const BinningMode &mode)
Sets the BinningMode.
BinningFeature(detail::DownsamplingModule &module)
Creates a BinningFeature for an existing downsampling module.
uint32_t GetX() const
Gets the current number of columns used for binning.
void SetEnabled(bool enabled) override
Enables or disables the feature.
void SetY(uint32_t y)
Sets the number of rows used for binning.
void SetX(uint32_t x)
Sets the number of columns used for binning.
BinningMode GetMode() const
Gets the current BinningMode.
peak::common::IntervalU GetRange() const
Gets the valid range for the binning factors x and y.
void ResetToDefault() override
Resets all settings to the default values.
bool IsEnabled() const override
Indicates whether the feature is currently enabled.
Abstract base class for all image processing pipeline features.
DownsamplingMode
Mode parameter for the downsampling algorithm.
BinningMode
Mode parameter for the binning algorithm.
@ Sum
The pixel values of neighboring rows and/or columns are summed during binning.
@ Average
The averaged pixel values of neighboring rows and/or columns are computed during binning.