IDSpeakIPL  v1.8.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  {
321  m_backendHandle = other.m_backendHandle;
322  other.m_backendHandle = nullptr;
323  }
324 
325  return *this;
326 }
327 
328 inline Image ImageTransformer::MirrorUpDown(const Image& inputImage) const
329 {
330  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
333  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
334  });
335 
336  return ImageBackendAccessor::CreateImage(outputImageHandle);
337 }
338 
339 inline Image ImageTransformer::MirrorLeftRight(const Image& inputImage) const
340 {
341  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
344  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
345  });
346 
347  return ImageBackendAccessor::CreateImage(outputImageHandle);
348 }
349 
350 inline Image ImageTransformer::MirrorUpDownLeftRight(const Image& inputImage) const
351 {
352  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
355  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
356  });
357 
358  return ImageBackendAccessor::CreateImage(outputImageHandle);
359 }
360 
362 {
365  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
366  });
367 }
368 
370 {
373  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
374  });
375 }
376 
378 {
381  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
382  });
383 }
384 
385 inline Image ImageTransformer::Rotate(const Image& inputImage, RotationAngle rotationAngle) const
386 {
387  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
390  ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle,
391  static_cast<PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t>(rotationAngle));
392  });
393 
394  return ImageBackendAccessor::CreateImage(outputImageHandle);
395 }
396 
397 
398 inline void ImageTransformer::RotateInPlace(Image& image, RotationAngle rotationAngle) const
399 {
402  ImageBackendAccessor::BackendHandle(image),
403  static_cast<PEAK_IPL_IMAGE_TRANSFORMER_ROTATION_ANGLE_t>(rotationAngle));
404  });
405 }
406 
407 
408 } /* namespace ipl */
409 } /* 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:398
PEAK_IPL_NO_DISCARD Image MirrorUpDown(const Image &inputImage) const
Mirrors the input image in up-down direction.
Definition: peak_ipl_image_transformer.hpp:328
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:369
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:354
struct PEAK_IPL_IMAGE_transformer * PEAK_IPL_IMAGE_TRANSFORMER_HANDLE
Definition: peak_ipl_backend.h:326
PEAK_IPL_NO_DISCARD Image MirrorUpDownLeftRight(const Image &inputImage) const
Mirrors the input image in up-down and left-right direction.
Definition: peak_ipl_image_transformer.hpp:350
PEAK_IPL_NO_DISCARD Image MirrorLeftRight(const Image &inputImage) const
Mirrors the input image in the left-right direction.
Definition: peak_ipl_image_transformer.hpp:339
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_NO_DISCARD Image Rotate(const Image &inputImage, RotationAngle rotationAngle) const
Rotate the input image with the given rotationAngle.
Definition: peak_ipl_image_transformer.hpp:385
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:377
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:361
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.