IDS peak IPL v1.17.0
Loading...
Searching...
No Matches
peak_ipl_decimation.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
18
23
24namespace peak
25{
26namespace ipl
27{
28
29class Decimation final
30{
31public:
38 Decimation();
39
47
59 Decimation(const Decimation& other);
60
72 Decimation& operator=(const Decimation& other);
73
82 Decimation(Decimation&& other) noexcept;
83
92 Decimation& operator=(Decimation&& other) noexcept;
93
103 void SetDecimationX(uint8_t value);
104
112 PEAK_IPL_NO_DISCARD uint8_t DecimationX() const;
113
123 void SetDecimationY(uint8_t value);
124
132 PEAK_IPL_NO_DISCARD uint8_t DecimationY() const;
133
141 PEAK_IPL_NO_DISCARD uint8_t DecimationMin() const;
149 PEAK_IPL_NO_DISCARD uint8_t DecimationMax() const;
150
164
175
189 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
190
191private:
192 PEAK_IPL_DECIMATION_HANDLE m_backendHandle{};
193};
194
199
201{
202 if (m_backendHandle)
203 {
205 }
206}
207
209{
210 if (other.m_backendHandle)
211 {
212 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
213 }
214
215 m_backendHandle = other.m_backendHandle;
216}
217
219{
220 if (this != &other)
221 {
222 if (m_backendHandle)
223 {
225 }
226
227 if (other.m_backendHandle)
228 {
230 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
231 }
232 }
233
234 m_backendHandle = other.m_backendHandle;
235
236 return *this;
237}
238
239inline Decimation::Decimation(Decimation&& other) noexcept
240{
241 *this = std::move(other);
242}
243
245{
246 if (this != &other)
247 {
248 if (m_backendHandle != nullptr)
249 {
251 }
252
253 m_backendHandle = other.m_backendHandle;
254 other.m_backendHandle = nullptr;
255 }
256
257 return *this;
258}
259
260inline void Decimation::SetDecimationX(uint8_t value)
261{
263 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationX(m_backendHandle, &value); });
264}
265
266inline void Decimation::SetDecimationY(uint8_t value)
267{
269 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationY(m_backendHandle, &value); });
270}
271
272inline uint8_t Decimation::DecimationX() const
273{
274 uint8_t value;
275
277 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationX(m_backendHandle, &value); });
278
279 return value;
280}
281
282inline uint8_t Decimation::DecimationY() const
283{
284 uint8_t value;
285
287 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationY(m_backendHandle, &value); });
288
289 return value;
290}
291
292inline uint8_t Decimation::DecimationMin() const
293{
294 uint8_t value;
295
297 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMin(m_backendHandle, &value); });
298
299 return value;
300}
301
302inline uint8_t Decimation::DecimationMax() const
303{
304 uint8_t value;
305
307 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMax(m_backendHandle, &value); });
308
309 return value;
310}
311
313{
314 Size2D size{};
316 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
317 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
318 });
319
320 return size;
321}
322
323inline bool Decimation::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
324{
325 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
326
329 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
330 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
331 });
332
333 return isPixelFormatSupported > 0;
334}
335
336inline Image Decimation::Process(const Image& inputImage) const
337{
338 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
341 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
342 });
343
344 return ImageBackendAccessor::CreateImage(outputImageHandle);
345}
346
347} /* namespace ipl */
348} /* namespace peak */
uint8_t DecimationY() const
Returns the value of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:282
Decimation & operator=(const Decimation &other)
Copy assigment for Decimation instance.
Definition peak_ipl_decimation.hpp:218
uint8_t DecimationX() const
Returns the value of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:272
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:312
uint8_t DecimationMin() const
Returns the minimum value for the decimation.
Definition peak_ipl_decimation.hpp:292
~Decimation()
Destructor for the Decimation instance.
Definition peak_ipl_decimation.hpp:200
Image Process(const Image &inputImage) const
Applies the decimation on the given image.
Definition peak_ipl_decimation.hpp:336
uint8_t DecimationMax() const
Returns the maximum value for the decimation.
Definition peak_ipl_decimation.hpp:302
void SetDecimationY(uint8_t value)
Sets the values of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:266
Decimation()
Constructor for a new Decimation instance.
Definition peak_ipl_decimation.hpp:195
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the decimation supports the given pixel format.
Definition peak_ipl_decimation.hpp:323
void SetDecimationX(uint8_t value)
Sets the values of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:260
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:46
The "peak::ipl" namespace contains the whole image processing library.
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:41
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:271
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
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:405
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:26
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
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:389
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:218
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:220
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:219