IDS peak IPL  v1.7.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:
44 
45  EdgeEnhancement(const EdgeEnhancement&) = delete;
46  EdgeEnhancement& operator=(const EdgeEnhancement&) = delete;
47 
48  EdgeEnhancement(EdgeEnhancement&&) noexcept;
50 
64  inline void ProcessInPlace(Image& image) const;
65 
81  inline Image Process(const Image& image) const;
82 
96  inline bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const;
97 
107  inline void SetFactor(std::uint32_t factor);
108 
118  inline std::uint32_t Factor() const;
119 
129  inline std::uint32_t DefaultFactor() const;
130 
140  inline peak::ipl::Range<std::uint32_t> Range() const;
141 
142 private:
143  PEAK_IPL_EDGE_ENHANCEMENT_HANDLE m_backendHandle{};
144 };
145 
147 {
149 }
150 
152 {
153  if (m_backendHandle)
154  {
156  }
157 }
158 
160 {
161  *this = std::move(other);
162 }
163 
165 {
166  if (this != &other)
167  {
169  m_backendHandle = other.m_backendHandle;
170  other.m_backendHandle = nullptr;
171  }
172 
173  return *this;
174 }
175 
176 inline void EdgeEnhancement::ProcessInPlace(Image& image) const
177 {
180  m_backendHandle, ImageBackendAccessor::BackendHandle(image));
181  });
182 }
183 
184 inline Image EdgeEnhancement::Process(const Image& image) const
185 {
186  PEAK_IPL_IMAGE_HANDLE handle{};
187 
190  m_backendHandle, ImageBackendAccessor::BackendHandle(image), &handle);
191  });
192 
193  return ImageBackendAccessor::CreateImage(handle);
194 }
195 
197 {
198  PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
199 
202  static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName), &isPixelFormatSupported);
203  });
204 
205  return isPixelFormatSupported != 0;
206 }
207 
208 inline void EdgeEnhancement::SetFactor(std::uint32_t factor)
209 {
212  m_backendHandle, factor);
213  });
214 }
215 
216 inline uint32_t EdgeEnhancement::Factor() const
217 {
218  uint32_t factor{};
219 
222  m_backendHandle, &factor);
223  });
224 
225  return factor;
226 }
227 
228 inline uint32_t EdgeEnhancement::DefaultFactor() const
229 {
230  uint32_t factor{};
231 
234  m_backendHandle, &factor);
235  });
236 
237  return factor;
238 }
239 
241 {
242  PEAK_IPL_RANGE range{};
243 
246  m_backendHandle, &range);
247  });
248 
249  return { range.min, range.max, range.inc };
250 }
251 
252 } /* namespace ipl */
253 } /* namespace peak */
#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:346
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::Range< std::uint32_t > Range() const
Get the range for the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:240
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
PEAK_IPL_C_API PEAK_IPL_EdgeEnhancement_GetFactorRange(PEAK_IPL_EDGE_ENHANCEMENT_HANDLE handle, PEAK_IPL_RANGE *range)
Get the range of valid factors for edge enhancement.
std::uint32_t DefaultFactor() const
Get the default edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:228
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
std::uint32_t Factor() const
Get the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:216
EdgeEnhancement()
Definition: peak_ipl_edge_enhancement.hpp:146
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Check if the pixel format is supported.
Definition: peak_ipl_edge_enhancement.hpp:196
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:285
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:326
Range.
Definition: peak_ipl_range.hpp:30
EdgeEnhancement & operator=(const EdgeEnhancement &)=delete
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:176
void SetFactor(std::uint32_t factor)
Set the edge enhancement factor.
Definition: peak_ipl_edge_enhancement.hpp:208
int8_t PEAK_IPL_BOOL8
Definition: peak_ipl_backend.h:25
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.
Image Process(const Image &image) const
Process an image.
Definition: peak_ipl_edge_enhancement.hpp:184
~EdgeEnhancement()
Definition: peak_ipl_edge_enhancement.hpp:151
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.