IDS peak IPL  v1.6.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 
23 class Binning final
24 {
25 public:
31  enum class BinningMode : uint16_t
32  {
33  Average = 0,
34  Sum = 1
35  };
36  Binning();
37  ~Binning();
38  Binning(const Binning& other) = delete;
39  Binning& operator=(const Binning& other) = delete;
40  Binning(Binning&& other) noexcept;
41  Binning& operator=(Binning&& other) noexcept;
42 
52  void SetBinningX(uint8_t value);
53 
61  uint8_t BinningX() const;
62 
72  void SetBinningY(uint8_t value);
73 
81  uint8_t BinningY() const;
82 
90  uint8_t BinningMin() const;
98  uint8_t BinningMax() const;
99 
112  Size2D ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const;
113 
123  void SetMode(BinningMode mode);
124 
132  BinningMode Mode() const;
133 
143  bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
144 
156  Image Process(const Image& inputImage) const;
157 
158 private:
159  PEAK_IPL_BINNING_HANDLE m_backendHandle{};
160 };
162 {
164 }
166 {
168 }
169 inline Binning::Binning(Binning&& other) noexcept
170 {
171  *this = std::move(other);
172 }
173 inline Binning& Binning::operator=(Binning&& other) noexcept
174 {
175  if (this != &other)
176  {
177  (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_Destruct(m_backendHandle);
178  m_backendHandle = other.m_backendHandle;
179  other.m_backendHandle = nullptr;
180  }
181 
182  return *this;
183 }
184 inline void Binning::SetBinningX(uint8_t value)
185 {
186  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningX(m_backendHandle, &value); });
187 }
188 inline void Binning::SetBinningY(uint8_t value)
189 {
190  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_SetBinningY(m_backendHandle, &value); });
191 }
192 inline uint8_t Binning::BinningX() const
193 {
194  uint8_t value;
195 
196  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningX(m_backendHandle, &value); });
197 
198  return value;
199 }
200 inline uint8_t Binning::BinningY() const
201 {
202  uint8_t value;
203 
204  ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningY(m_backendHandle, &value); });
205 
206  return value;
207 }
208 inline uint8_t Binning::BinningMin() const
209 {
210  uint8_t value;
211 
213  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMin(m_backendHandle, &value); });
214 
215  return value;
216 }
217 inline uint8_t Binning::BinningMax() const
218 {
219  uint8_t value;
220 
222  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_GetBinningMax(m_backendHandle, &value); });
223 
224  return value;
225 }
226 inline Size2D Binning::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
227 {
228  Size2D size{};
230  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Binning_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
231  inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
232  });
233 
234  return size;
235 }
236 inline bool Binning::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
237 {
238  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
239 
242  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
243  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
244  });
245 
246  return isPixelFormatSupported > 0;
247 }
248 inline Image Binning::Process(const Image& inputImage) const
249 {
250  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
253  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
254  });
255 
256  return ImageBackendAccessor::CreateImage(outputImageHandle);
257 }
259 {
261  m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&mode)); });
262 }
264 {
265  BinningMode value;
266 
268  m_backendHandle, reinterpret_cast<PEAK_IPL_BINNINGMODE*>(&value)); });
269 
270  return value;
271 }
272 
273 
274 } /* namespace ipl */
275 } /* namespace peak */
uint8_t BinningX() const
Returns the value of the binning in horizontal direction.
Definition: peak_ipl_binning.hpp:192
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_simple_types.hpp:166
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
Definition: peak_ipl_binning.hpp:23
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:200
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.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
2D size of an image.
Definition: peak_ipl_simple_types.hpp:163
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:248
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:307
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:188
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:226
BinningMode
Mode parameter for the binning algorithm.
Definition: peak_ipl_binning.hpp:31
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the binning supports the given pixel format.
Definition: peak_ipl_binning.hpp:236
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:184
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:165
uint8_t BinningMin() const
Returns the minimum value for the binning.
Definition: peak_ipl_binning.hpp:208
Binning & operator=(const Binning &other)=delete
size_t width
Definition: peak_ipl_simple_types.hpp:165
Binning()
Definition: peak_ipl_binning.hpp:161
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:217
BinningMode Mode() const
Returns the value of the binning mode.
Definition: peak_ipl_binning.hpp:263
struct PEAK_IPL_BINNING * PEAK_IPL_BINNING_HANDLE
Definition: peak_ipl_backend.h:287
void SetMode(BinningMode mode)
Sets the values of the binning mode.
Definition: peak_ipl_binning.hpp:258