IDS peak ICV v1.0.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
48{
49public:
58
62 void SetEnabled(bool enabled) override;
63
67 PEAK_COMMON_NO_DISCARD bool IsEnabled() const override;
68
76 void ResetToDefault() override;
77
88 void SetX(uint32_t x);
89
100 void SetY(uint32_t y);
101
109 PEAK_COMMON_NO_DISCARD uint32_t GetX() const;
110
118 PEAK_COMMON_NO_DISCARD uint32_t GetY() const;
119
130
140 void SetMode(const BinningMode& mode);
141
150
151private:
153};
154
156 : m_module(module)
157{}
158
159inline void BinningFeature::SetEnabled(bool enabled)
160{
161 m_module.SetEnabled(enabled);
162}
163
164inline bool BinningFeature::IsEnabled() const
165{
166 return m_module.IsEnabled();
167}
168
170{
171 m_module.ResetToDefault();
172}
173
174inline void BinningFeature::SetX(uint32_t x)
175{
176 try
177 {
178 m_module.SetX(x);
179 }
180 catch (const peak::icv::OutOfRangeException&)
181 {
182 const auto range = m_module.GetRange();
183 throw peak::icv::OutOfRangeException("The specified binning factor " + std::to_string(x)
184 + " is incorrect; the expected value must be between " + std::to_string(range.GetMinimum()) + " and "
185 + std::to_string(range.GetMaximum()) + ".");
186 }
187}
188
189inline void BinningFeature::SetY(uint32_t y)
190{
191 try
192 {
193 m_module.SetY(y);
194 }
195 catch (const peak::icv::OutOfRangeException&)
196 {
197 const auto range = m_module.GetRange();
198 throw peak::icv::OutOfRangeException("The specified binning factor " + std::to_string(y)
199 + " is incorrect; the expected value must be between " + std::to_string(range.GetMinimum()) + " and "
200 + std::to_string(range.GetMaximum()) + ".");
201 }
202}
203
204inline uint32_t BinningFeature::GetX() const
205{
206 return m_module.GetX();
207}
208
209inline uint32_t BinningFeature::GetY() const
210{
211 return m_module.GetY();
212}
213
215{
216 return m_module.GetRange();
217}
218
219inline void BinningFeature::SetMode(const BinningMode& mode)
220{
221 if (mode != BinningMode::Sum && mode != BinningMode::Average)
222 {
223 throw peak::icv::NotSupportedException("The binning mode is not supported");
224 }
225 try
226 {
227 m_module.SetMode(static_cast<detail::DownsamplingMode>(mode));
228 }
230 {
231 throw peak::icv::NotSupportedException("The binning mode is not supported");
232 }
233}
234
236{
237 return static_cast<BinningMode>(m_module.GetMode());
238}
239
240} // namespace features
241} // namespace pipeline
242} // 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.
bool IsEnabled() const override
Checks if the module is currently enabled.
Binning is used to decrease the image size.
uint32_t GetY() const
Retrieves 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
Retrieves 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
Retrieves the current BinningMode.
peak::common::IntervalU GetRange() const
Retrieves 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.
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
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.