IDS peak IPL v1.12.0
Loading...
Searching...
No Matches
peak_ipl_binning.hpp
Go to the documentation of this file.
1
11#pragma once
12
18
22namespace peak
23{
24namespace ipl
25{
26
27class Binning final
28{
29public:
35 enum class BinningMode : uint16_t
36 {
38 Average = 0,
39
41 Sum = 1
42 };
43
50 Binning();
51
58 ~Binning();
59
71 Binning(const Binning& other);
72
84 Binning& operator=(const Binning& other);
85
94 Binning(Binning&& other) noexcept;
95
104 Binning& operator=(Binning&& other) noexcept;
105
115 void SetBinningX(uint8_t value);
116
124 PEAK_IPL_NO_DISCARD uint8_t BinningX() const;
125
135 void SetBinningY(uint8_t value);
136
144 PEAK_IPL_NO_DISCARD uint8_t BinningY() const;
145
153 PEAK_IPL_NO_DISCARD uint8_t BinningMin() const;
154
162 PEAK_IPL_NO_DISCARD uint8_t BinningMax() const;
163
177
187 void SetMode(BinningMode mode);
188
197
208
222 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
223
224private:
225 PEAK_IPL_BINNING_HANDLE m_backendHandle{};
226};
227
229{
231}
232
234{
235 if (m_backendHandle)
236 {
238 }
239}
240
241inline Binning::Binning(const Binning& other)
242{
243 if (other.m_backendHandle)
244 {
245 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
246 }
247
248 m_backendHandle = other.m_backendHandle;
249}
250
251inline Binning& Binning::operator=(const Binning& other)
252{
253 if (this != &other)
254 {
255 if (m_backendHandle)
256 {
258 }
259
260 if (other.m_backendHandle)
261 {
263 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Acquire(other.m_backendHandle); });
264 }
265 }
266
267 m_backendHandle = other.m_backendHandle;
268
269 return *this;
270}
271
272inline Binning::Binning(Binning&& other) noexcept
273{
274 *this = std::move(other);
275}
276
277inline Binning& Binning::operator=(Binning&& other) noexcept
278{
279 if (this != &other)
280 {
281 if (m_backendHandle != nullptr)
282 {
284 }
285
286 m_backendHandle = other.m_backendHandle;
287 other.m_backendHandle = nullptr;
288 }
289
290 return *this;
291}
292
293inline void Binning::SetBinningX(uint8_t value)
294{
295 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningX(m_backendHandle, &value); });
296}
297
298inline void Binning::SetBinningY(uint8_t value)
299{
300 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningY(m_backendHandle, &value); });
301}
302
303inline uint8_t Binning::BinningX() const
304{
305 uint8_t value;
306
307 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningX(m_backendHandle, &value); });
308
309 return value;
310}
311
312inline uint8_t Binning::BinningY() const
313{
314 uint8_t value;
315
316 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningY(m_backendHandle, &value); });
317
318 return value;
319}
320
321inline uint8_t Binning::BinningMin() const
322{
323 uint8_t value;
324
326 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMin(m_backendHandle, &value); });
327
328 return value;
329}
330
331inline uint8_t Binning::BinningMax() const
332{
333 uint8_t value;
334
336 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMax(m_backendHandle, &value); });
337
338 return value;
339}
340
341inline Size2D Binning::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
342{
343 Size2D size{};
345 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
346 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
347 });
348
349 return size;
350}
351
352inline bool Binning::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
353{
354 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
355
358 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
359 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
360 });
361
362 return isPixelFormatSupported > 0;
363}
364
365inline Image Binning::Process(const Image& inputImage) const
366{
367 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
370 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
371 });
372
373 return ImageBackendAccessor::CreateImage(outputImageHandle);
374}
375
377{
380 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&mode));
381 });
382}
383
385{
386 BinningMode value;
387
390 m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&value));
391 });
392
393 return value;
394}
395
396
397} /* namespace ipl */
398} /* namespace peak */
Definition peak_ipl_binning.hpp:28
~Binning()
Destructor for the Binning instance.
Definition peak_ipl_binning.hpp:233
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:341
uint8_t BinningMax() const
Returns the maximum value for the binning.
Definition peak_ipl_binning.hpp:331
Image Process(const Image &inputImage) const
Applies the binning on the given image.
Definition peak_ipl_binning.hpp:365
uint8_t BinningY() const
Returns the value of the binning in vertical direction.
Definition peak_ipl_binning.hpp:312
Binning()
Constructor for a new Binning instance.
Definition peak_ipl_binning.hpp:228
BinningMode Mode() const
Returns the value of the binning mode.
Definition peak_ipl_binning.hpp:384
void SetBinningX(uint8_t value)
Sets the values of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:293
void SetMode(BinningMode mode)
Sets the values of the binning mode.
Definition peak_ipl_binning.hpp:376
void SetBinningY(uint8_t value)
Sets the values of the binning in vertical direction.
Definition peak_ipl_binning.hpp:298
Binning & operator=(const Binning &other)
Copy assigment for Binning instance.
Definition peak_ipl_binning.hpp:251
uint8_t BinningX() const
Returns the value of the binning in horizontal direction.
Definition peak_ipl_binning.hpp:303
uint8_t BinningMin() const
Returns the minimum value for the binning.
Definition peak_ipl_binning.hpp:321
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the binning supports the given pixel format.
Definition peak_ipl_binning.hpp:352
BinningMode
Mode parameter for the binning algorithm.
Definition peak_ipl_binning.hpp:36
@ Average
Average (mean) of pixels.
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:40
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:39
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
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.
uint16_t PEAK_IPL_BINNINGMODE
Definition peak_ipl_backend.h:245
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:369
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:41
PEAK_IPL_C_API PEAK_IPL_Binning_Construct(PEAK_IPL_BINNING_HANDLE *binningHandle)
Creates a binning.
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:188
struct PEAK_IPL_BINNING * PEAK_IPL_BINNING_HANDLE
Definition peak_ipl_backend.h:349
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16
2D size of an image.
Definition peak_ipl_simple_types.hpp:216
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:218
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:217