IDS peak IPL v1.17.0
Loading...
Searching...
No Matches
peak_ipl_binning.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
18
23
24namespace peak
25{
26namespace ipl
27{
28
29class Binning final
30{
31public:
45
52 Binning();
53
60 ~Binning();
61
73 Binning(const Binning& other);
74
86 Binning& operator=(const Binning& other);
87
96 Binning(Binning&& other) noexcept;
97
106 Binning& operator=(Binning&& other) noexcept;
107
117 void SetBinningX(uint8_t value);
118
126 PEAK_IPL_NO_DISCARD uint8_t BinningX() const;
127
137 void SetBinningY(uint8_t value);
138
146 PEAK_IPL_NO_DISCARD uint8_t BinningY() const;
147
155 PEAK_IPL_NO_DISCARD uint8_t BinningMin() const;
156
164 PEAK_IPL_NO_DISCARD uint8_t BinningMax() const;
165
179
189 void SetMode(BinningMode mode);
190
199
210
224 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
225
226private:
227 PEAK_IPL_BINNING_HANDLE m_backendHandle{};
228};
229
231{
233}
234
236{
237 if (m_backendHandle)
238 {
240 }
241}
242
243inline Binning::Binning(const Binning& other)
244{
245 if (other.m_backendHandle)
246 {
247 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
248 }
249
250 m_backendHandle = other.m_backendHandle;
251}
252
253inline Binning& Binning::operator=(const Binning& other)
254{
255 if (this != &other)
256 {
257 if (m_backendHandle)
258 {
260 }
261
262 if (other.m_backendHandle)
263 {
265 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
266 }
267 }
268
269 m_backendHandle = other.m_backendHandle;
270
271 return *this;
272}
273
274inline Binning::Binning(Binning&& other) noexcept
275{
276 *this = std::move(other);
277}
278
279inline Binning& Binning::operator=(Binning&& other) noexcept
280{
281 if (this != &other)
282 {
283 if (m_backendHandle != nullptr)
284 {
286 }
287
288 m_backendHandle = other.m_backendHandle;
289 other.m_backendHandle = nullptr;
290 }
291
292 return *this;
293}
294
295inline void Binning::SetBinningX(uint8_t value)
296{
297 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningX(m_backendHandle, &value); });
298}
299
300inline void Binning::SetBinningY(uint8_t value)
301{
302 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningY(m_backendHandle, &value); });
303}
304
305inline uint8_t Binning::BinningX() const
306{
307 uint8_t value;
308
309 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningX(m_backendHandle, &value); });
310
311 return value;
312}
313
314inline uint8_t Binning::BinningY() const
315{
316 uint8_t value;
317
318 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningY(m_backendHandle, &value); });
319
320 return value;
321}
322
323inline uint8_t Binning::BinningMin() const
324{
325 uint8_t value;
326
328 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMin(m_backendHandle, &value); });
329
330 return value;
331}
332
333inline uint8_t Binning::BinningMax() const
334{
335 uint8_t value;
336
338 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMax(m_backendHandle, &value); });
339
340 return value;
341}
342
343inline Size2D Binning::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
344{
345 Size2D size{};
347 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
348 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
349 });
350
351 return size;
352}
353
354inline bool Binning::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
355{
356 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
357
360 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
361 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
362 });
363
364 return isPixelFormatSupported > 0;
365}
366
367inline Image Binning::Process(const Image& inputImage) const
368{
369 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
372 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
373 });
374
375 return ImageBackendAccessor::CreateImage(outputImageHandle);
376}
377
379{
382 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&mode));
383 });
384}
385
387{
388 BinningMode value;
389
392 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&value));
393 });
394
395 return value;
396}
397
398
399} /* namespace ipl */
400} /* namespace peak */
Definition peak_ipl_binning.hpp:30
~Binning()
Destructor for the Binning instance.
Definition peak_ipl_binning.hpp:235
PEAK_IPL_NO_DISCARD Size2D ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
Returns the size of a binned image given the input size and pixelformat.
Definition peak_ipl_binning.hpp:343
PEAK_IPL_NO_DISCARD uint8_t BinningMax() const
Returns the maximum value for the binning.
Definition peak_ipl_binning.hpp:333
PEAK_IPL_NO_DISCARD Image Process(const Image &inputImage) const
Applies the binning on the given image.
Definition peak_ipl_binning.hpp:367
PEAK_IPL_NO_DISCARD uint8_t BinningY() const
Returns the value of the binning in vertical direction.
Definition peak_ipl_binning.hpp:314
Binning()
Constructor for a new Binning instance.
Definition peak_ipl_binning.hpp:230
PEAK_IPL_NO_DISCARD BinningMode Mode() const
Returns the value of the binning mode.
Definition peak_ipl_binning.hpp:386
void SetBinningX(uint8_t value)
Sets the values of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:295
void SetMode(BinningMode mode)
Sets the values of the binning mode.
Definition peak_ipl_binning.hpp:378
void SetBinningY(uint8_t value)
Sets the values of the binning in vertical direction.
Definition peak_ipl_binning.hpp:300
Binning & operator=(const Binning &other)
Copy assigment for Binning instance.
Definition peak_ipl_binning.hpp:253
PEAK_IPL_NO_DISCARD uint8_t BinningX() const
Returns the value of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:305
PEAK_IPL_NO_DISCARD uint8_t BinningMin() const
Returns the minimum value for the binning.
Definition peak_ipl_binning.hpp:323
PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the binning supports the given pixel format.
Definition peak_ipl_binning.hpp:354
BinningMode
Mode parameter for the binning algorithm.
Definition peak_ipl_binning.hpp:38
@ Sum
Sum of pixels.
Definition peak_ipl_binning.hpp:43
@ Average
Average (mean) of pixels.
Definition peak_ipl_binning.hpp:40
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:46
The "peak::ipl" namespace contains the whole image processing library.
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:41
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:271
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningY(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningYValue)
Returns the value of binning in vertical direction.
PEAK_IPL_C_API PEAK_IPL_Binning_SetBinningMode(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_BINNINGMODE *mode)
Sets the value of binning mode.
PEAK_IPL_C_API PEAK_IPL_Binning_IsPixelformatSupported(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given binning whether it supports the given pixel format.
PEAK_IPL_C_API PEAK_IPL_Binning_ExpectedOutputSize(PEAK_IPL_BINNING_HANDLE binningHandle, size_t *outputWidth, size_t *outputHeight, size_t inputWidth, size_t inputHeight, PEAK_IPL_PIXEL_FORMAT pixelFormat)
Returns the size of a binned image given the input size and pixelformat.
PEAK_IPL_C_API PEAK_IPL_Binning_Acquire(PEAK_IPL_BINNING_HANDLE binningHandle)
Increase the reference count of a binning object.
PEAK_IPL_C_API PEAK_IPL_Binning_SetBinningY(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningYValue)
Sets the value of binning in vertical direction.
PEAK_IPL_C_API PEAK_IPL_Binning_Process(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Apply the binning on the given image.
@ PEAK_IPL_BINNINGMODE_SUM
Definition peak_ipl_backend.h:228
@ PEAK_IPL_BINNINGMODE_AVERAGE
Definition peak_ipl_backend.h:227
uint16_t PEAK_IPL_BINNINGMODE
Definition peak_ipl_backend.h:230
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningMax(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningMax)
Returns the maximum binning value which can be set.
PEAK_IPL_C_API PEAK_IPL_Binning_SetBinningX(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningXValue)
Sets the value of binning in horizontal direction.
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningMode(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_BINNINGMODE *mode)
Returns the value of binning mode.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:405
PEAK_IPL_C_API PEAK_IPL_Binning_Destruct(PEAK_IPL_BINNING_HANDLE binningHandle)
Destroys the binning associated with the given handle.
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningMin(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningMin)
Returns the minimum binning value which can be set.
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningX(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningXValue)
Returns the value of binning in horizontal direction.
int8_t PEAK_IPL_BOOL8
Definition peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_Binning_Construct(PEAK_IPL_BINNING_HANDLE *binningHandle)
Creates a binning.
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
struct PEAK_IPL_BINNING * PEAK_IPL_BINNING_HANDLE
Definition peak_ipl_backend.h:385
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16
2D size of an image.
Definition peak_ipl_simple_types.hpp:218
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:220
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:219