IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_decimation.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
13
18
19namespace peak
20{
21namespace ipl
22{
23
36class Decimation final
37{
38public:
45 Decimation();
46
54
66 Decimation(const Decimation& other);
67
79 Decimation& operator=(const Decimation& other);
80
89 Decimation(Decimation&& other) noexcept;
90
99 Decimation& operator=(Decimation&& other) noexcept;
100
110 void SetDecimationX(uint8_t value);
111
119 PEAK_IPL_NO_DISCARD uint8_t DecimationX() const;
120
130 void SetDecimationY(uint8_t value);
131
139 PEAK_IPL_NO_DISCARD uint8_t DecimationY() const;
140
148 PEAK_IPL_NO_DISCARD uint8_t DecimationMin() const;
156 PEAK_IPL_NO_DISCARD uint8_t DecimationMax() const;
157
171
182
196 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
197
198private:
199 PEAK_IPL_DECIMATION_HANDLE m_backendHandle{};
200};
201
206
208{
209 if (m_backendHandle)
210 {
212 }
213}
214
216{
217 if (other.m_backendHandle)
218 {
219 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
220 }
221
222 m_backendHandle = other.m_backendHandle;
223}
224
226{
227 if (this != &other)
228 {
229 if (m_backendHandle)
230 {
232 }
233
234 if (other.m_backendHandle)
235 {
237 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
238 }
239 }
240
241 m_backendHandle = other.m_backendHandle;
242
243 return *this;
244}
245
246inline Decimation::Decimation(Decimation&& other) noexcept
247{
248 *this = std::move(other);
249}
250
252{
253 if (this != &other)
254 {
255 if (m_backendHandle != nullptr)
256 {
258 }
259
260 m_backendHandle = other.m_backendHandle;
261 other.m_backendHandle = nullptr;
262 }
263
264 return *this;
265}
266
267inline void Decimation::SetDecimationX(uint8_t value)
268{
270 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationX(m_backendHandle, &value); });
271}
272
273inline void Decimation::SetDecimationY(uint8_t value)
274{
276 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationY(m_backendHandle, &value); });
277}
278
279inline uint8_t Decimation::DecimationX() const
280{
281 uint8_t value;
282
284 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationX(m_backendHandle, &value); });
285
286 return value;
287}
288
289inline uint8_t Decimation::DecimationY() const
290{
291 uint8_t value;
292
294 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationY(m_backendHandle, &value); });
295
296 return value;
297}
298
299inline uint8_t Decimation::DecimationMin() const
300{
301 uint8_t value;
302
304 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMin(m_backendHandle, &value); });
305
306 return value;
307}
308
309inline uint8_t Decimation::DecimationMax() const
310{
311 uint8_t value;
312
314 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMax(m_backendHandle, &value); });
315
316 return value;
317}
318
320{
321 Size2D size{};
324 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
325 });
326
327 return size;
328}
329
330inline bool Decimation::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
331{
332 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
333
336 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
337 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
338 });
339
340 return isPixelFormatSupported > 0;
341}
342
343inline Image Decimation::Process(const Image& inputImage) const
344{
345 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
348 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
349 });
350
351 return ImageBackendAccessor::CreateImage(outputImageHandle);
352}
353
354} /* namespace ipl */
355} /* namespace peak */
uint8_t DecimationY() const
Returns the value of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:289
Decimation & operator=(const Decimation &other)
Copy assigment for Decimation instance.
Definition peak_ipl_decimation.hpp:225
uint8_t DecimationX() const
Returns the value of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:279
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:319
uint8_t DecimationMin() const
Returns the minimum value for the decimation.
Definition peak_ipl_decimation.hpp:299
~Decimation()
Destructor for the Decimation instance.
Definition peak_ipl_decimation.hpp:207
Image Process(const Image &inputImage) const
Applies the decimation on the given image.
Definition peak_ipl_decimation.hpp:343
uint8_t DecimationMax() const
Returns the maximum value for the decimation.
Definition peak_ipl_decimation.hpp:309
void SetDecimationY(uint8_t value)
Sets the values of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:273
Decimation()
Constructor for a new Decimation instance.
Definition peak_ipl_decimation.hpp:202
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the decimation supports the given pixel format.
Definition peak_ipl_decimation.hpp:330
void SetDecimationX(uint8_t value)
Sets the values of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:267
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:42
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:38
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:284
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
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:402
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:23
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:170
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:386
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:11
2D size of an image.
Definition peak_ipl_simple_types.hpp:220
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:222
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:221