IDS peak IPL v1.11.0
Loading...
Searching...
No Matches
peak_ipl_decimation.hpp
Go to the documentation of this file.
1
11#pragma once
12
18
22namespace peak
23{
24namespace ipl
25{
26
27class Decimation final
28{
29public:
36 Decimation();
37
45
57 Decimation(const Decimation& other);
58
70 Decimation& operator=(const Decimation& other);
71
80 Decimation(Decimation&& other) noexcept;
81
90 Decimation& operator=(Decimation&& other) noexcept;
91
101 void SetDecimationX(uint8_t value);
102
110 PEAK_IPL_NO_DISCARD uint8_t DecimationX() const;
111
121 void SetDecimationY(uint8_t value);
122
130 PEAK_IPL_NO_DISCARD uint8_t DecimationY() const;
131
139 PEAK_IPL_NO_DISCARD uint8_t DecimationMin() const;
147 PEAK_IPL_NO_DISCARD uint8_t DecimationMax() const;
148
162
173
185 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
186
187private:
188 PEAK_IPL_DECIMATION_HANDLE m_backendHandle{};
189};
190
195
197{
198 if (m_backendHandle)
199 {
201 }
202}
203
205{
206 if (other.m_backendHandle)
207 {
208 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
209 }
210
211 m_backendHandle = other.m_backendHandle;
212}
213
215{
216 if (this != &other)
217 {
218 if (m_backendHandle)
219 {
221 }
222
223 if (other.m_backendHandle)
224 {
226 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
227 }
228 }
229
230 m_backendHandle = other.m_backendHandle;
231
232 return *this;
233}
234
235inline Decimation::Decimation(Decimation&& other) noexcept
236{
237 *this = std::move(other);
238}
239
241{
242 if (this != &other)
243 {
244 if (m_backendHandle != nullptr)
245 {
247 }
248
249 m_backendHandle = other.m_backendHandle;
250 other.m_backendHandle = nullptr;
251 }
252
253 return *this;
254}
255
256inline void Decimation::SetDecimationX(uint8_t value)
257{
259 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationX(m_backendHandle, &value); });
260}
261
262inline void Decimation::SetDecimationY(uint8_t value)
263{
265 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationY(m_backendHandle, &value); });
266}
267
268inline uint8_t Decimation::DecimationX() const
269{
270 uint8_t value;
271
273 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationX(m_backendHandle, &value); });
274
275 return value;
276}
277
278inline uint8_t Decimation::DecimationY() const
279{
280 uint8_t value;
281
283 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationY(m_backendHandle, &value); });
284
285 return value;
286}
287
288inline uint8_t Decimation::DecimationMin() const
289{
290 uint8_t value;
291
293 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMin(m_backendHandle, &value); });
294
295 return value;
296}
297
298inline uint8_t Decimation::DecimationMax() const
299{
300 uint8_t value;
301
303 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMax(m_backendHandle, &value); });
304
305 return value;
306}
307
309{
310 Size2D size{};
312 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
313 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
314 });
315
316 return size;
317}
318
319inline bool Decimation::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
320{
321 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
322
325 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
326 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
327 });
328
329 return isPixelFormatSupported > 0;
330}
331
332inline Image Decimation::Process(const Image& inputImage) const
333{
334 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
337 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
338 });
339
340 return ImageBackendAccessor::CreateImage(outputImageHandle);
341}
342
343} /* namespace ipl */
344} /* namespace peak */
Definition peak_ipl_decimation.hpp:28
uint8_t DecimationY() const
Returns the value of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:278
Decimation & operator=(const Decimation &other)
Copy assigment for Decimation instance.
Definition peak_ipl_decimation.hpp:214
uint8_t DecimationX() const
Returns the value of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:268
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:308
uint8_t DecimationMin() const
Returns the minimum value for the decimation.
Definition peak_ipl_decimation.hpp:288
~Decimation()
Destructor for the Decimation instance.
Definition peak_ipl_decimation.hpp:196
Image Process(const Image &inputImage) const
Applies the decimation on the given image.
Definition peak_ipl_decimation.hpp:332
uint8_t DecimationMax() const
Returns the maximum value for the decimation.
Definition peak_ipl_decimation.hpp:298
void SetDecimationY(uint8_t value)
Sets the values of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:262
Decimation()
Constructor for a new Decimation instance.
Definition peak_ipl_decimation.hpp:191
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the decimation supports the given pixel format.
Definition peak_ipl_decimation.hpp:319
void SetDecimationX(uint8_t value)
Sets the values of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:256
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_Decimation_SetDecimationX(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationXValue)
Sets the value of decimation in horizontal direction.
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.
PEAK_IPL_C_API PEAK_IPL_Decimation_Construct(PEAK_IPL_DECIMATION_HANDLE *decimationHandle)
Creates a decimation.
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_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.
PEAK_IPL_C_API PEAK_IPL_Decimation_SetDecimationY(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationYValue)
Sets the value of decimation in vertical direction.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:361
PEAK_IPL_C_API PEAK_IPL_Decimation_Acquire(PEAK_IPL_DECIMATION_HANDLE decimationHandle)
Increase the reference count of a decimation object.
int8_t PEAK_IPL_BOOL8
Definition peak_ipl_backend.h:41
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_backend.h:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:180
PEAK_IPL_C_API PEAK_IPL_Decimation_GetDecimationY(PEAK_IPL_DECIMATION_HANDLE decimationHandle, uint8_t *decimationYValue)
Returns the value of decimation in vertical direction.
PEAK_IPL_C_API PEAK_IPL_Decimation_Destruct(PEAK_IPL_DECIMATION_HANDLE decimationHandle)
Destroys the decimation associated with the given handle.
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.
struct PEAK_IPL_DECIMATION * PEAK_IPL_DECIMATION_HANDLE
Definition peak_ipl_backend.h:345
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.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16
2D size of an image.
Definition peak_ipl_simple_types.hpp:208
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:210
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:209