IDS peak IPL  v1.7.0
peak_ipl_decimation.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
18 
22 namespace peak
23 {
24 namespace ipl
25 {
26 
27 class Decimation final
28 {
29 public:
30  Decimation();
31  ~Decimation();
32  Decimation(const Decimation& other) = delete;
33  Decimation& operator=(const Decimation& other) = delete;
34  Decimation(Decimation&& other) noexcept;
35  Decimation& operator=(Decimation&& other) noexcept;
36 
46  void SetDecimationX(uint8_t value);
47 
55  uint8_t DecimationX() const;
56 
66  void SetDecimationY(uint8_t value);
67 
75  uint8_t DecimationY() const;
76 
84  uint8_t DecimationMin() const;
92  uint8_t DecimationMax() const;
93 
106  Size2D ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const;
107 
117  bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
118 
130  Image Process(const Image& inputImage) const;
131 
132 private:
133  PEAK_IPL_DECIMATION_HANDLE m_backendHandle{};
134 };
136 {
138 }
140 {
141  if (m_backendHandle)
142  {
144  }
145 }
146 inline Decimation::Decimation(Decimation&& other) noexcept
147 {
148  *this = std::move(other);
149 }
150 inline Decimation& Decimation::operator=(Decimation&& other) noexcept
151 {
152  if (this != &other)
153  {
155  m_backendHandle = other.m_backendHandle;
156  other.m_backendHandle = nullptr;
157  }
158 
159  return *this;
160 }
161 inline void Decimation::SetDecimationX(uint8_t value)
162 {
164  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationX(m_backendHandle, &value); });
165 }
166 inline void Decimation::SetDecimationY(uint8_t value)
167 {
169  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationY(m_backendHandle, &value); });
170 }
171 inline uint8_t Decimation::DecimationX() const
172 {
173  uint8_t value;
174 
176  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationX(m_backendHandle, &value); });
177 
178  return value;
179 }
180 inline uint8_t Decimation::DecimationY() const
181 {
182  uint8_t value;
183 
185  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationY(m_backendHandle, &value); });
186 
187  return value;
188 }
189 inline uint8_t Decimation::DecimationMin() const
190 {
191  uint8_t value;
192 
194  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMin(m_backendHandle, &value); });
195 
196  return value;
197 }
198 inline uint8_t Decimation::DecimationMax() const
199 {
200  uint8_t value;
201 
203  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMax(m_backendHandle, &value); });
204 
205  return value;
206 }
207 inline Size2D Decimation::ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
208 {
209  Size2D size{};
211  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
212  inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
213  });
214 
215  return size;
216 }
217 inline bool Decimation::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
218 {
219  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
220 
223  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
224  reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
225  });
226 
227  return isPixelFormatSupported > 0;
228 }
229 inline Image Decimation::Process(const Image& inputImage) const
230 {
231  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
234  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
235  });
236 
237  return ImageBackendAccessor::CreateImage(outputImageHandle);
238 }
239 
240 } /* namespace ipl */
241 } /* namespace peak */
PEAK_IPL_C_API PEAK_IPL_Decimation_GetDecimationMax(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationMax)
Returns the maximum decimation value which can be set.
PEAK_IPL_C_API PEAK_IPL_Decimation_GetDecimationX(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationXValue)
Returns the value of decimation in horizontal direction.
Decimation & operator=(const Decimation &other)=delete
PEAK_IPL_C_API PEAK_IPL_Decimation_Destruct(PEAK_IPL_DECIMATION_HANDLE decimationHandle)
Destroys the decimation associated with the given handle.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
uint8_t DecimationY() const
Returns the value of the decimation in vertical direction.
Definition: peak_ipl_decimation.hpp:180
size_t height
Definition: peak_ipl_simple_types.hpp:180
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
~Decimation()
Definition: peak_ipl_decimation.hpp:139
PEAK_IPL_C_API PEAK_IPL_Decimation_IsPixelformatSupported(PEAK_IPL_DECIMATION_HANDLE decimationHandle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given decimation whether it supports the given pixel format.
Decimation()
Definition: peak_ipl_decimation.hpp:135
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_C_API PEAK_IPL_Decimation_SetDecimationY(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationYValue)
Sets the value of decimation in vertical direction.
PEAK_IPL_C_API PEAK_IPL_Decimation_SetDecimationX(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationXValue)
Sets the value of decimation in horizontal direction.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
PEAK_IPL_C_API PEAK_IPL_Decimation_GetDecimationMin(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationMin)
Returns the minimum decimation value which can be set.
2D size of an image.
Definition: peak_ipl_simple_types.hpp:177
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
void SetDecimationY(uint8_t value)
Sets the values of the decimation in vertical direction.
Definition: peak_ipl_decimation.hpp:166
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:326
PEAK_IPL_C_API PEAK_IPL_Decimation_GetDecimationY(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationYValue)
Returns the value of decimation in vertical direction.
uint8_t DecimationMin() const
Returns the minimum value for the decimation.
Definition: peak_ipl_decimation.hpp:189
PEAK_IPL_C_API PEAK_IPL_Decimation_Process(PEAK_IPL_DECIMATION_HANDLE decimationHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Apply the decimation on the given image.
PEAK_IPL_C_API PEAK_IPL_Decimation_Construct(PEAK_IPL_DECIMATION_HANDLE *decimationHandle)
Creates a decimation.
Definition: peak_ipl_decimation.hpp:27
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the decimation supports the given pixel format.
Definition: peak_ipl_decimation.hpp:217
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.h:25
PEAK_IPL_C_API PEAK_IPL_Decimation_ExpectedOutputSize(PEAK_IPL_DECIMATION_HANDLE decimationHandle, 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.
Size2D ExpectedOutputSize(Size2D inputSize, PixelFormatName pixelFormat) const
Returns the size of a decimated image given the input size and pixelformat.
Definition: peak_ipl_decimation.hpp:207
void SetDecimationX(uint8_t value)
Sets the values of the decimation in horizontal direction.
Definition: peak_ipl_decimation.hpp:161
size_t width
Definition: peak_ipl_simple_types.hpp:179
Image Process(const Image &inputImage) const
Applies the decimation on the given image.
Definition: peak_ipl_decimation.hpp:229
uint8_t DecimationX() const
Returns the value of the decimation in horizontal direction.
Definition: peak_ipl_decimation.hpp:171
uint8_t DecimationMax() const
Returns the maximum value for the decimation.
Definition: peak_ipl_decimation.hpp:198
struct PEAK_IPL_DECIMATION * PEAK_IPL_DECIMATION_HANDLE
Definition: peak_ipl_backend.h:310