IDS peak IPL  v1.5.0
peak_ipl_binning.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
16 namespace peak
17 {
18 namespace ipl
19 {
20 
21 class Image;
22 
26 struct Size2D
27 {
28  size_t width;
29  size_t height;
30 };
31 
32 class Binning final
33 {
34 public:
40  enum class BinningMode : uint16_t
41  {
42  Average = 0,
43  Sum = 1
44  };
45  Binning();
46  ~Binning();
47  Binning(const Binning& other) = delete;
48  Binning& operator=(const Binning& other) = delete;
49  Binning(Binning&& other);
50  Binning& operator=(Binning&& other);
51 
61  void SetBinningX(uint8_t value);
62 
70  uint8_t BinningX() const;
71 
81  void SetBinningY(uint8_t value);
82 
90  uint8_t BinningY() const;
91 
99  uint8_t BinningMin() const;
107  uint8_t BinningMax() const;
108 
121  Size2D ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const;
122 
132  void SetMode(BinningMode mode);
133 
141  BinningMode Mode() const;
142 
152  bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
153 
165  Image Process(const Image& inputImage) const;
166 
167 private:
168  PEAK_IPL_BINNING_HANDLE m_backendHandle{};
169 };
171 {
173 }
175 {
177 }
178 inline Binning::Binning(Binning&& other)
179 {
180  *this = std::move(other);
181 }
183 {
184  if (this != &other)
185  {
186  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Destruct(m_backendHandle);
187  m_backendHandle = other.m_backendHandle;
188  other.m_backendHandle = nullptr;
189  }
190 
191  return *this;
192 }
193 inline void Binning::SetBinningX(uint8_t value)
194 {
195  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningX(m_backendHandle, &value); });
196 }
197 inline void Binning::SetBinningY(uint8_t value)
198 {
199  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningY(m_backendHandle, &value); });
200 }
201 inline uint8_t Binning::BinningX() const
202 {
203  uint8_t value;
204 
205  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningX(m_backendHandle, &value); });
206 
207  return value;
208 }
209 inline uint8_t Binning::BinningY() const
210 {
211  uint8_t value;
212 
213  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningY(m_backendHandle, &value); });
214 
215  return value;
216 }
217 inline uint8_t Binning::BinningMin() const
218 {
219  uint8_t value;
220 
222  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMin(m_backendHandle, &value); });
223 
224  return value;
225 }
226 inline uint8_t Binning::BinningMax() const
227 {
228  uint8_t value;
229 
231  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMax(m_backendHandle, &value); });
232 
233  return value;
234 }
235 inline Size2D Binning::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
236 {
237  Size2D size{};
239  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
240  inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
241  });
242 
243  return size;
244 }
245 inline bool Binning::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
246 {
247  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
248 
251  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
252  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
253  });
254 
255  return isPixelFormatSupported > 0;
256 }
257 inline Image Binning::Process(const Image& inputImage) const
258 {
259  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
262  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
263  });
264 
265  return ImageBackendAccessor::CreateImage(outputImageHandle);
266 }
268 {
270  m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&mode)); });
271 }
273 {
274  BinningMode value;
275 
277  m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&value)); });
278 
279  return value;
280 }
281 
282 
283 } /* namespace ipl */
284 } /* namespace peak */
uint8_t BinningX() const
Returns the value of the binning in horizontal direction.
Definition: peak_ipl_binning.hpp:201
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_Construct(PEAK_IPL_BINNING_HANDLE *binningHandle)
Creates a binning.
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_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_SetBinningMode(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_BINNINGMODE *mode)
Sets the value of binning mode.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
size_t height
Definition: peak_ipl_binning.hpp:29
Definition: peak_ipl_backend.h:199
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
Definition: peak_ipl_binning.hpp:32
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.
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:16
uint8_t BinningY() const
Returns the value of the binning in vertical direction.
Definition: peak_ipl_binning.hpp:209
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
2D size of an image.
Definition: peak_ipl_binning.hpp:26
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:37
Image Process(const Image &inputImage) const
Applies the binning on the given image.
Definition: peak_ipl_binning.hpp:257
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:267
PEAK_IPL_C_API PEAK_IPL_Binning_SetBinningY(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningYValue)
Sets the value of binning in vertical direction.
void SetBinningY(uint8_t value)
Sets the values of the Binning in vertical direction.
Definition: peak_ipl_binning.hpp:197
Definition: peak_ipl_backend.h:200
PEAK_IPL_C_API PEAK_IPL_Binning_ExpectedOutputSize(PEAK_IPL_BINNING_HANDLE binningHandle, size_t *outputWidth, size_t *outputHeight, const size_t inputWidth, const size_t inputHeight, const PEAK_IPL_PIXEL_FORMAT pixelFormat)
Returns the size of a binned image given the input size and pixelformat.
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.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.
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:235
BinningMode
Mode parameter for the binning algorithm.
Definition: peak_ipl_binning.hpp:40
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the binning supports the given pixel format.
Definition: peak_ipl_binning.hpp:245
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_GetBinningMode(PEAK_IPL_BINNING_HANDLE binningHandle, PEAK_IPL_BINNINGMODE *mode)
Returns the value of binning mode.
void SetBinningX(uint8_t value)
Sets the values of the Binning in horizontal direction.
Definition: peak_ipl_binning.hpp:193
PEAK_IPL_C_API PEAK_IPL_Binning_GetBinningX(PEAK_IPL_BINNING_HANDLE binningHandle, uint8_t *binningXValue)
Returns the value of binning in horizontal direction.
~Binning()
Definition: peak_ipl_binning.hpp:174
uint8_t BinningMin() const
Returns the minimum value for the binning.
Definition: peak_ipl_binning.hpp:217
Binning & operator=(const Binning &other)=delete
size_t width
Definition: peak_ipl_binning.hpp:28
Binning()
Definition: peak_ipl_binning.hpp:170
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.
uint8_t BinningMax() const
Returns the maximum value for the binning.
Definition: peak_ipl_binning.hpp:226
BinningMode Mode() const
Returns the value of the binning mode.
Definition: peak_ipl_binning.hpp:272
struct PEAK_IPL_BINNING * PEAK_IPL_BINNING_HANDLE
Definition: peak_ipl_backend.h:251
void SetMode(BinningMode mode)
Sets the values of the Binning mode.
Definition: peak_ipl_binning.hpp:267