IDS peak IPL  v1.10.0
peak_ipl_image_transformer.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
17 
21 namespace peak
22 {
23 namespace ipl
24 {
25 
26 class Image;
27 
35 class ImageTransformer final
36 {
37 public:
43  enum class RotationAngle : uint16_t
44  {
46  Degree90Clockwise = 270,
47  Degree180 = 180
48  };
49 
57 
65 
77  ImageTransformer(const ImageTransformer& other);
78 
91 
100  ImageTransformer(ImageTransformer&& other) noexcept;
101 
110  ImageTransformer& operator=(ImageTransformer&& other) noexcept;
111 
128  PEAK_IPL_NO_DISCARD Image MirrorUpDown(const Image& inputImage) const;
129 
146  PEAK_IPL_NO_DISCARD Image MirrorLeftRight(const Image& inputImage) const;
147 
164  PEAK_IPL_NO_DISCARD Image MirrorUpDownLeftRight(const Image& inputImage) const;
165 
180  void MirrorUpDownInPlace(Image& image) const;
181 
196  void MirrorLeftRightInPlace(Image& image) const;
197 
213  void MirrorUpDownLeftRightInPlace(Image& image) const;
214 
232  PEAK_IPL_NO_DISCARD Image Rotate(const Image& inputImage, RotationAngle rotationAngle) const;
233 
249  void RotateInPlace(Image& image, RotationAngle rotationAngle) const;
250 
251 private:
252  PEAK_IPL_IMAGE_TRANSFORMER_HANDLE m_backendHandle{};
253 };
254 
255 } /* namespace ipl */
256 } /* namespace peak */
257 
259 
260 
261 namespace peak
262 {
263 namespace ipl
264 {
265 
267 {
269 }
270 
271 
273 {
274  if (m_backendHandle)
275  {
277  }
278 }
279 
281 {
282  if (other.m_backendHandle)
283  {
285  }
286 
287  m_backendHandle = other.m_backendHandle;
288 }
289 
291 {
292  if (this != &other)
293  {
294  if (m_backendHandle)
295  {
297  }
298 
299  if (other.m_backendHandle)
300  {
302  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_ImageTransformer_Acquire(other.m_backendHandle); });
303  }
304  }
305 
306  m_backendHandle = other.m_backendHandle;
307 
308  return *this;
309 }
310 
312 {
313  *this = std::move(other);
314 }
315 
317 {
318  if (this != &other)
319  {
320  if (m_backendHandle != nullptr)
321  {
323  }
324 
325  m_backendHandle = other.m_backendHandle;
326  other.m_backendHandle = nullptr;
327  }
328 
329  return *this;
330 }
331 
332 inline Image ImageTransformer::MirrorUpDown(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 inline Image ImageTransformer::MirrorLeftRight(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 inline Image ImageTransformer::MirrorUpDownLeftRight(const Image& inputImage) const
355 {
356  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
359  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
360  });
361 
362  return ImageBackendAccessor::CreateImage(outputImageHandle);
363 }
364 
366 {
369  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
370  });
371 }
372 
374 {
377  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
378  });
379 }
380 
382 {
385  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
386  });
387 }
388 
389 inline Image ImageTransformer::Rotate(const Image& inputImage, RotationAngle rotationAngle) const
390 {
391  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
394  ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle,
395  static_cast<PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t>(rotationAngle));
396  });
397 
398  return ImageBackendAccessor::CreateImage(outputImageHandle);
399 }
400 
401 
402 inline void ImageTransformer::RotateInPlace(Image& image, RotationAngle rotationAngle) const
403 {
406  ImageBackendAccessor::BackendHandle(image),
407  static_cast<PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t>(rotationAngle));
408  });
409 }
410 
411 
412 } /* namespace ipl */
413 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
ImageTransformer()
Constructor for a new ImageTransformer instance.
Definition: peak_ipl_image_transformer.hpp:266
~ImageTransformer()
Destructor for the ImageTransformer instance.
Definition: peak_ipl_image_transformer.hpp:272
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
void RotateInPlace(Image &image, RotationAngle rotationAngle) const
Rotate the input image with the given rotationAngle.
Definition: peak_ipl_image_transformer.hpp:402
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorLeftRight(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image containing the data of the current image mirrored in left-right direction...
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_Destruct(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle)
Destroys the image transformer associated with the given handle.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_Rotate(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle, enum PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t rotationAngle)
Creates a new image containing the data of the current image rotated in the supplied direction and va...
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_Acquire(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle)
Increase the reference count of an image transformer object.
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorUpDownInPlace(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Mirrors the image in up-down direction in place i.e. it will change the input image itself...
ImageTransformer & operator=(const ImageTransformer &other)
Copy assigment for ImageTransformer instance.
Definition: peak_ipl_image_transformer.hpp:290
void MirrorLeftRightInPlace(Image &image) const
Mirrors the given image in the left-right direction in place i.e. it will change the input image itse...
Definition: peak_ipl_image_transformer.hpp:373
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_RotateInPlace(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, enum PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t rotationAngle)
Rotates the image in the direction and value of the rotation angle in place i.e. it will change the i...
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:361
struct PEAK_IPL_IMAGE_transformer * PEAK_IPL_IMAGE_TRANSFORMER_HANDLE
Definition: peak_ipl_backend.h:333
Performs transformations like mirror and rotate on images.
Definition: peak_ipl_image_transformer.hpp:35
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorLeftRightInPlace(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Mirrors the image left-right direction in place i.e. it will change the input image itself...
RotationAngle
Angle parameter for the Rotation algorithm.
Definition: peak_ipl_image_transformer.hpp:43
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorUpDownLeftRight(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image containing the data of the current image mirrored in up-down and left-right direc...
void MirrorUpDownLeftRightInPlace(Image &image) const
Mirrors the given image in up-down and left-right direction in place i.e. it will change the input im...
Definition: peak_ipl_image_transformer.hpp:381
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorUpDownLeftRightInPlace(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Mirrors the image in up-down and left-right direction in place i.e. it will change the input image it...
void MirrorUpDownInPlace(Image &image) const
Mirrors the given image in up-down direction in place i.e. it will change the input image itself...
Definition: peak_ipl_image_transformer.hpp:365
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_MirrorUpDown(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE imageTransformerHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Creates a new image containing the data of the current image mirrored in up-down direction.
PEAK_IPL_C_API PEAK_IPL_ImageTransformer_Construct(PEAK_IPL_IMAGE_TRANSFORMER_HANDLE *imageTransformerHandle)
Creates an image transformer.