IDS peak IPL  v1.9.2
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  {
252  if (m_backendHandle != nullptr)
253  {
255  }
256 
257  m_backendHandle = other.m_backendHandle;
258  other.m_backendHandle = nullptr;
259  }
260 
261  return *this;
262 }
263 
264 inline void EdgeEnhancement::ProcessInPlace(Image& image) const
265 {
268  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
269  });
270 }
271 
272 inline Image EdgeEnhancement::Process(const Image& image) const
273 {
274  PEAK_IPL_IMAGE_HANDLE handle{};
275 
278  m_backendHandle, ImageBackendAccessor::BackendHandle(image), &handle);
279  });
280 
281  return ImageBackendAccessor::CreateImage(handle);
282 }
283 
284 inline bool EdgeEnhancement::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
285 {
286  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
287 
290  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName), &isPixelFormatSupported);
291  });
292 
293  return isPixelFormatSupported != 0;
294 }
295 
296 inline void EdgeEnhancement::SetFactor(std::uint32_t factor)
297 {
300  m_backendHandle, factor);
301  });
302 }
303 
304 inline uint32_t EdgeEnhancement::Factor() const
305 {
306  uint32_t factor{};
307 
310  m_backendHandle, &factor);
311  });
312 
313  return factor;
314 }
315 
316 inline uint32_t EdgeEnhancement::DefaultFactor() const
317 {
318  uint32_t factor{};
319 
322  m_backendHandle, &factor);
323  });
324 
325  return factor;
326 }
327 
328 inline Range<std::uint32_t> EdgeEnhancement::Range() const
329 {
330  PEAK_IPL_RANGE range{};
331 
334  m_backendHandle, &range);
335  });
336 
337  return { range.min, range.max, range.inc };
338 }
339 
340 } /* namespace ipl */
341 } /* 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:377
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_SetFactor(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, uint32_t factor)
Set the factor for edge enhancement.
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PixelFormatName
Enum holding the possible pixel format names.
Definition: peak_ipl_simple_types.hpp:38
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
EdgeEnhancement()
Constructor for a new EdgeEnhancement instance.
Definition: peak_ipl_edge_enhancement.hpp:199
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:316
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:357
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:264
void SetFactor(std::uint32_t factor)
Set the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:296
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.
~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.