IDSpeakIPL  v1.8.0
peak_ipl_edge_enhancement.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
18 
19 #include <type_traits>
20 #include <algorithm>
21 #include <cstdint>
22 #include <iterator>
23 #include <vector>
24 
28 namespace peak
29 {
30 namespace ipl
31 {
32 class Image;
33 enum class PixelFormatName;
39 class EdgeEnhancement final
40 {
41 public:
49 
57 
69  EdgeEnhancement(const EdgeEnhancement& other);
70 
83 
92  EdgeEnhancement(EdgeEnhancement&& other) noexcept;
93 
102  EdgeEnhancement& operator=(EdgeEnhancement&& other) noexcept;
103 
117  inline void ProcessInPlace(Image& image) const;
118 
134  PEAK_IPL_NO_DISCARD inline Image Process(const Image& image) const;
135 
149  PEAK_IPL_NO_DISCARD inline bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
150 
160  inline void SetFactor(std::uint32_t factor);
161 
171  PEAK_IPL_NO_DISCARD inline std::uint32_t Factor() const;
172 
182  PEAK_IPL_NO_DISCARD inline std::uint32_t DefaultFactor() const;
183 
194 
195 private:
196  PEAK_IPL_EDGE_ENHANCEMENT_HANDLE m_backendHandle{};
197 };
198 
200 {
202 }
203 
205 {
206  if (m_backendHandle)
207  {
209  }
210 }
211 
213 {
214  *this = std::move(other);
215 }
216 
218 {
219  if (other.m_backendHandle)
220  {
222  }
223 
224  m_backendHandle = other.m_backendHandle;
225 }
226 
228 {
229  if (this != &other)
230  {
231  if (m_backendHandle)
232  {
234  }
235 
236  if (other.m_backendHandle)
237  {
239  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_EdgeEnhancement_Acquire(other.m_backendHandle); });
240  }
241  }
242 
243  m_backendHandle = other.m_backendHandle;
244 
245  return *this;
246 }
247 
249 {
250  if (this != &other)
251  {
253  m_backendHandle = other.m_backendHandle;
254  other.m_backendHandle = nullptr;
255  }
256 
257  return *this;
258 }
259 
260 inline void EdgeEnhancement::ProcessInPlace(Image& image) const
261 {
264  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
265  });
266 }
267 
268 inline Image EdgeEnhancement::Process(const Image& image) const
269 {
270  PEAK_IPL_IMAGE_HANDLE handle{};
271 
274  m_backendHandle, ImageBackendAccessor::BackendHandle(image), &handle);
275  });
276 
277  return ImageBackendAccessor::CreateImage(handle);
278 }
279 
281 {
282  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
283 
286  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName), &isPixelFormatSupported);
287  });
288 
289  return isPixelFormatSupported != 0;
290 }
291 
292 inline void EdgeEnhancement::SetFactor(std::uint32_t factor)
293 {
296  m_backendHandle, factor);
297  });
298 }
299 
300 inline uint32_t EdgeEnhancement::Factor() const
301 {
302  uint32_t factor{};
303 
306  m_backendHandle, &factor);
307  });
308 
309  return factor;
310 }
311 
312 inline uint32_t EdgeEnhancement::DefaultFactor() const
313 {
314  uint32_t factor{};
315 
318  m_backendHandle, &factor);
319  });
320 
321  return factor;
322 }
323 
325 {
326  PEAK_IPL_RANGE range{};
327 
330  m_backendHandle, &range);
331  });
332 
333  return { range.min, range.max, range.inc };
334 }
335 
336 } /* namespace ipl */
337 } /* namespace peak */
#define PEAK_IPL_NO_DISCARD
Definition: peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_GetFactorRange(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, struct PEAK_IPL_RANGE *range)
Get the range of valid factors for edge enhancement.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
struct PEAK_IPL_EDGE_ENHANCEMENT * PEAK_IPL_EDGE_ENHANCEMENT_HANDLE
Definition: peak_ipl_backend.h:374
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_SetFactor(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, uint32_t factor)
Set the factor for edge enhancement.
PEAK_IPL_NO_DISCARD peak::ipl::Range< std::uint32_t > Range() const
Get the range for the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:324
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_NO_DISCARD std::uint32_t DefaultFactor() const
Get the default edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:312
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_IsPixelFormatSupported(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given edge enhancement whether it supports the given pixel format.
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_Process(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Process the given image with edge enhancement.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:182
PEAK_IPL_NO_DISCARD std::uint32_t Factor() const
Get the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:300
EdgeEnhancement()
Constructor for a new EdgeEnhancement instance.
Definition: peak_ipl_edge_enhancement.hpp:199
PEAK_IPL_NO_DISCARD bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Check if the pixel format is supported.
Definition: peak_ipl_edge_enhancement.hpp:280
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
Definition: peak_ipl_backend.h:313
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_Construct(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE *handle)
Create the edge enhancement associated with the given handle.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:354
EdgeEnhancement & operator=(const EdgeEnhancement &other)
Copy assigment for EdgeEnhancement instance.
Definition: peak_ipl_edge_enhancement.hpp:227
Range support and convenience class.
Definition: peak_ipl_range.hpp:30
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_Destruct(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle)
Destruct the edge enhancement associated with the given handle.
void ProcessInPlace(Image &image) const
Process an image.
Definition: peak_ipl_edge_enhancement.hpp:260
void SetFactor(std::uint32_t factor)
Set the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:292
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.h:41
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_Acquire(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle)
Increase the reference count of an edge enhancement object.
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_ProcessInPlace(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Process the given image with edge enhancement.
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_GetDefaultFactor(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, uint32_t *factor)
Get the default factor for edge enhancement.
PEAK_IPL_NO_DISCARD Image Process(const Image &image) const
Process an image.
Definition: peak_ipl_edge_enhancement.hpp:268
~EdgeEnhancement()
Destructor for the EdgeEnhancement instance.
Definition: peak_ipl_edge_enhancement.hpp:204
Edge Enhancement for a given image.
Definition: peak_ipl_edge_enhancement.hpp:39
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_GetFactor(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, uint32_t *factor)
Get the factor for edge enhancement.