IDS peak IPL v1.13.1
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
187 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
188
189private:
190 PEAK_IPL_DECIMATION_HANDLE m_backendHandle{};
191};
192
197
199{
200 if (m_backendHandle)
201 {
203 }
204}
205
207{
208 if (other.m_backendHandle)
209 {
210 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
211 }
212
213 m_backendHandle = other.m_backendHandle;
214}
215
217{
218 if (this != &other)
219 {
220 if (m_backendHandle)
221 {
223 }
224
225 if (other.m_backendHandle)
226 {
228 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_Acquire(other.m_backendHandle); });
229 }
230 }
231
232 m_backendHandle = other.m_backendHandle;
233
234 return *this;
235}
236
237inline Decimation::Decimation(Decimation&& other) noexcept
238{
239 *this = std::move(other);
240}
241
243{
244 if (this != &other)
245 {
246 if (m_backendHandle != nullptr)
247 {
249 }
250
251 m_backendHandle = other.m_backendHandle;
252 other.m_backendHandle = nullptr;
253 }
254
255 return *this;
256}
257
258inline void Decimation::SetDecimationX(uint8_t value)
259{
261 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationX(m_backendHandle, &value); });
262}
263
264inline void Decimation::SetDecimationY(uint8_t value)
265{
267 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_SetDecimationY(m_backendHandle, &value); });
268}
269
270inline uint8_t Decimation::DecimationX() const
271{
272 uint8_t value;
273
275 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationX(m_backendHandle, &value); });
276
277 return value;
278}
279
280inline uint8_t Decimation::DecimationY() const
281{
282 uint8_t value;
283
285 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationY(m_backendHandle, &value); });
286
287 return value;
288}
289
290inline uint8_t Decimation::DecimationMin() const
291{
292 uint8_t value;
293
295 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMin(m_backendHandle, &value); });
296
297 return value;
298}
299
300inline uint8_t Decimation::DecimationMax() const
301{
302 uint8_t value;
303
305 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_GetDecimationMax(m_backendHandle, &value); });
306
307 return value;
308}
309
311{
312 Size2D size{};
314 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Decimation_ExpectedOutputSize(m_backendHandle, &size.width, &size.height,
315 inputSize.width, inputSize.height, static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormat));
316 });
317
318 return size;
319}
320
321inline bool Decimation::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
322{
323 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
324
327 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
328 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
329 });
330
331 return isPixelFormatSupported > 0;
332}
333
334inline Image Decimation::Process(const Image& inputImage) const
335{
336 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
339 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
340 });
341
342 return ImageBackendAccessor::CreateImage(outputImageHandle);
343}
344
345} /* namespace ipl */
346} /* 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:280
Decimation & operator=(const Decimation &other)
Copy assigment for Decimation instance.
Definition peak_ipl_decimation.hpp:216
uint8_t DecimationX() const
Returns the value of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:270
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:310
uint8_t DecimationMin() const
Returns the minimum value for the decimation.
Definition peak_ipl_decimation.hpp:290
~Decimation()
Destructor for the Decimation instance.
Definition peak_ipl_decimation.hpp:198
Image Process(const Image &inputImage) const
Applies the decimation on the given image.
Definition peak_ipl_decimation.hpp:334
uint8_t DecimationMax() const
Returns the maximum value for the decimation.
Definition peak_ipl_decimation.hpp:300
void SetDecimationY(uint8_t value)
Sets the values of the decimation in vertical direction.
Definition peak_ipl_decimation.hpp:264
Decimation()
Constructor for a new Decimation instance.
Definition peak_ipl_decimation.hpp:193
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the decimation supports the given pixel format.
Definition peak_ipl_decimation.hpp:321
void SetDecimationX(uint8_t value)
Sets the values of the decimation in horizontal direction.
Definition peak_ipl_decimation.hpp:258
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:369
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:188
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:353
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:216
size_t height
Height of size.
Definition peak_ipl_simple_types.hpp:218
size_t width
Width of size.
Definition peak_ipl_simple_types.hpp:217