IDS peak IPL v1.17.1
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
43class Binning final
44{
45public:
59
66 Binning();
67
74 ~Binning();
75
87 Binning(const Binning& other);
88
100 Binning& operator=(const Binning& other);
101
110 Binning(Binning&& other) noexcept;
111
120 Binning& operator=(Binning&& other) noexcept;
121
131 void SetBinningX(uint8_t value);
132
140 PEAK_IPL_NO_DISCARD uint8_t BinningX() const;
141
151 void SetBinningY(uint8_t value);
152
160 PEAK_IPL_NO_DISCARD uint8_t BinningY() const;
161
169 PEAK_IPL_NO_DISCARD uint8_t BinningMin() const;
170
178 PEAK_IPL_NO_DISCARD uint8_t BinningMax() const;
179
193
203 void SetMode(BinningMode mode);
204
213
224
238 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
239
240private:
241 PEAK_IPL_BINNING_HANDLE m_backendHandle{};
242};
243
245{
247}
248
250{
251 if (m_backendHandle)
252 {
254 }
255}
256
257inline Binning::Binning(const Binning& other)
258{
259 if (other.m_backendHandle)
260 {
261 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
262 }
263
264 m_backendHandle = other.m_backendHandle;
265}
266
267inline Binning& Binning::operator=(const Binning& other)
268{
269 if (this != &other)
270 {
271 if (m_backendHandle)
272 {
274 }
275
276 if (other.m_backendHandle)
277 {
279 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
280 }
281 }
282
283 m_backendHandle = other.m_backendHandle;
284
285 return *this;
286}
287
288inline Binning::Binning(Binning&& other) noexcept
289{
290 *this = std::move(other);
291}
292
293inline Binning& Binning::operator=(Binning&& other) noexcept
294{
295 if (this != &other)
296 {
297 if (m_backendHandle != nullptr)
298 {
300 }
301
302 m_backendHandle = other.m_backendHandle;
303 other.m_backendHandle = nullptr;
304 }
305
306 return *this;
307}
308
309inline void Binning::SetBinningX(uint8_t value)
310{
311 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningX(m_backendHandle, &value); });
312}
313
314inline void Binning::SetBinningY(uint8_t value)
315{
316 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningY(m_backendHandle, &value); });
317}
318
319inline uint8_t Binning::BinningX() const
320{
321 uint8_t value;
322
323 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningX(m_backendHandle, &value); });
324
325 return value;
326}
327
328inline uint8_t Binning::BinningY() const
329{
330 uint8_t value;
331
332 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningY(m_backendHandle, &value); });
333
334 return value;
335}
336
337inline uint8_t Binning::BinningMin() const
338{
339 uint8_t value;
340
342 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMin(m_backendHandle, &value); });
343
344 return value;
345}
346
347inline uint8_t Binning::BinningMax() const
348{
349 uint8_t value;
350
352 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMax(m_backendHandle, &value); });
353
354 return value;
355}
356
357inline Size2D Binning::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
358{
359 Size2D size{};
361 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
362 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
363 });
364
365 return size;
366}
367
368inline bool Binning::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
369{
370 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
371
374 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
375 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
376 });
377
378 return isPixelFormatSupported > 0;
379}
380
381inline Image Binning::Process(const Image& inputImage) const
382{
383 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
386 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
387 });
388
389 return ImageBackendAccessor::CreateImage(outputImageHandle);
390}
391
393{
396 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&mode));
397 });
398}
399
401{
402 BinningMode value;
403
406 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&value));
407 });
408
409 return value;
410}
411
412
413} /* namespace ipl */
414} /* namespace peak */
Performs spatial binning on 2D images.
Definition peak_ipl_binning.hpp:44
~Binning()
Destructor for the Binning instance.
Definition peak_ipl_binning.hpp:249
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:357
uint8_t BinningMax() const
Returns the maximum value for the binning.
Definition peak_ipl_binning.hpp:347
Image Process(const Image &inputImage) const
Applies the binning on the given image.
Definition peak_ipl_binning.hpp:381
uint8_t BinningY() const
Returns the value of the binning in vertical direction.
Definition peak_ipl_binning.hpp:328
Binning()
Constructor for a new Binning instance.
Definition peak_ipl_binning.hpp:244
BinningMode Mode() const
Returns the value of the binning mode.
Definition peak_ipl_binning.hpp:400
void SetBinningX(uint8_t value)
Sets the values of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:309
void SetMode(BinningMode mode)
Sets the values of the binning mode.
Definition peak_ipl_binning.hpp:392
void SetBinningY(uint8_t value)
Sets the values of the binning in vertical direction.
Definition peak_ipl_binning.hpp:314
Binning & operator=(const Binning &other)
Copy assigment for Binning instance.
Definition peak_ipl_binning.hpp:267
uint8_t BinningX() const
Returns the value of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:319
uint8_t BinningMin() const
Returns the minimum value for the binning.
Definition peak_ipl_binning.hpp:337
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the binning supports the given pixel format.
Definition peak_ipl_binning.hpp:368
BinningMode
Mode parameter for the binning algorithm.
Definition peak_ipl_binning.hpp:52
@ Sum
Sum of pixels.
Definition peak_ipl_binning.hpp:57
@ Average
Average (mean) of pixels.
Definition peak_ipl_binning.hpp:54
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:47
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:43
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:282
#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:225
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:227
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:226