IDS peak IPL  v1.4.0
peak_ipl_hotpixel_correction.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 
14 
15 #include <cstdint>
16 #include <vector>
17 
18 namespace peak
19 {
20 namespace ipl
21 {
22 
23 class Image;
24 
28 struct Point2D
29 {
30  size_t x;
31  size_t y;
32 };
33 
43 class HotpixelCorrection final
44 {
45 public:
52  enum class SensitivityLevel
53  {
54  Invalid,
55  SensitivityLevel1,
56  SensitivityLevel2,
57  SensitivityLevel3, // default
58  SensitivityLevel4,
59  SensitivityLevel5
60  };
61 
64  HotpixelCorrection(const HotpixelCorrection& other) = delete;
65  HotpixelCorrection& operator=(const HotpixelCorrection& other) = delete;
66  HotpixelCorrection(HotpixelCorrection&& other) noexcept;
67  HotpixelCorrection& operator=(HotpixelCorrection&& other) noexcept;
68 
78  void SetSensitivity(SensitivityLevel sensitivityLevel = SensitivityLevel::SensitivityLevel3);
79 
89  SensitivityLevel Sensitivity() const;
90 
100  void SetGainFactorPercent(uint32_t gainFactorPercent = 100);
101 
111  uint32_t GainFactorPercent() const;
112 
113 
127  std::vector<Point2D> Detect(const Image& inputImage) const;
128 
146  Image Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const;
147 
164  Image CorrectAdaptive(const Image& inputImage);
165 
166 private:
168 };
169 
170 } /* namespace ipl */
171 } /* namespace peak */
172 
174 
175 namespace peak
176 {
177 namespace ipl
178 {
179 
181 {
183  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_Construct(&m_backendHandle); });
184 
185  // make sure default params are set
186  SetSensitivity();
187  SetGainFactorPercent();
188 }
189 
191 {
193 }
194 
196 {
197  *this = std::move(other);
198 }
199 
201 {
202  if (this != &other)
203  {
205  m_backendHandle = other.m_backendHandle;
206  other.m_backendHandle = nullptr;
207  }
208 
209  return *this;
210 }
211 
213 {
216  m_backendHandle, static_cast<PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY>(sensitivityLevel));
217  });
218 }
219 
221 {
225  m_backendHandle, &sensitivityLevel);
226  });
227 
228  return static_cast<SensitivityLevel>(sensitivityLevel);
229 }
230 
231 inline void HotpixelCorrection::SetGainFactorPercent(uint32_t gainFactorPercent)
232 {
235  m_backendHandle, gainFactorPercent);
236  });
237 }
238 
240 {
241  uint32_t gainFactorPercent;
244  m_backendHandle, &gainFactorPercent);
245  });
246 
247  return gainFactorPercent;
248 }
249 
250 inline std::vector<Point2D> HotpixelCorrection::Detect(const Image& inputImage) const
251 {
254  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
255  });
256 
257  size_t size = 0;
259  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(m_backendHandle, nullptr, &size);
260  });
261  std::vector<Point2D> hotpixels(size);
264  m_backendHandle, reinterpret_cast<PEAK_IPL_POINT_2D*>(hotpixels.data()), &size);
265  });
266 
267  return hotpixels;
268 }
269 
270 inline Image HotpixelCorrection::Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const
271 {
272  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
275  ImageBackendAccessor::BackendHandle(inputImage),
276  reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size(), &outputImageHandle);
277  });
278 
279  return ImageBackendAccessor::CreateImage(outputImageHandle);
280 }
281 
283 {
284  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
287  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
288  });
289 
290  return ImageBackendAccessor::CreateImage(outputImageHandle);
291 }
292 
293 
294 } /* namespace ipl */
295 } /* namespace peak */
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Detect(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle)
Detects hotpixels in the given image.
Image CorrectAdaptive(const Image &inputImage)
Corrects the given image adaptively.
Definition: peak_ipl_hotpixel_correction.hpp:282
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_GetSensitivity(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY *sensitivityLevel)
Queries the given adaptive hotpixel corrector algorithm&#39;s current sensitivity.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_SetGainFactorPercent(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, uint32_t gainFactorPercent)
Sets the given adaptive hotpixel corrector algorithm&#39;s gain factor in percent.
#define PEAK_IPL_C_ABI_PREFIX
Definition: peak_ipl_dll_defines.h:16
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:16
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Correct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle, const PEAK_IPL_POINT_2D *hotpixels, size_t hotpixelsSize, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Corrects the given hotpixels in the given image.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition: peak_ipl_exception.hpp:128
Algorithm for (adaptive) hotpixel detection and correction.
Definition: peak_ipl_hotpixel_correction.hpp:43
size_t x
Definition: peak_ipl_hotpixel_correction.hpp:30
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_CorrectAdaptive(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Detects and corrects hotpixels in the given image.
~HotpixelCorrection()
Definition: peak_ipl_hotpixel_correction.hpp:190
Image Correct(const Image &inputImage, const std::vector< Point2D > &hotpixels) const
Corrects the given hotpixels in the given image.
Definition: peak_ipl_hotpixel_correction.hpp:270
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:37
SensitivityLevel Sensitivity() const
Returns the current sensitivity.
Definition: peak_ipl_hotpixel_correction.hpp:220
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Construct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE *adaptiveHotpixelCorrectorHandle)
Creates an adaptive hotpixel corrector algorithm.
2D position in an image.
Definition: peak_ipl_hotpixel_correction.hpp:28
SensitivityLevel
SensitivityLevel parameter for the HotpixelCorrection algorithm.
Definition: peak_ipl_hotpixel_correction.hpp:52
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:238
uint32_t GainFactorPercent() const
Returns the current gain factor in percent.
Definition: peak_ipl_hotpixel_correction.hpp:239
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_GetGainFactorPercent(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, uint32_t *gainFactorPercent)
Queries the given adaptive hotpixel corrector algorithm&#39;s current gain factor in percent.
void SetSensitivity(SensitivityLevel sensitivityLevel=SensitivityLevel::SensitivityLevel3)
Sets the sensitivity of the hotpixel detection.
Definition: peak_ipl_hotpixel_correction.hpp:212
int32_t PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY
Definition: peak_ipl_backend.h:182
HotpixelCorrection & operator=(const HotpixelCorrection &other)=delete
std::vector< Point2D > Detect(const Image &inputImage) const
Detects hotpixels in the given image.
Definition: peak_ipl_hotpixel_correction.hpp:250
HotpixelCorrection()
Definition: peak_ipl_hotpixel_correction.hpp:180
void SetGainFactorPercent(uint32_t gainFactorPercent=100)
Sets the gain factor in percent.
Definition: peak_ipl_hotpixel_correction.hpp:231
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_POINT_2D *hotpixels, size_t *hotpixelsSize)
Queries previously detected hotpixels.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_SetSensitivity(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY sensitivityLevel)
Sets the given adaptive hotpixel corrector algorithm&#39;s sensitivity.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Destruct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle)
Destroys the adaptive hotpixel corrector algorithm associated with the given handle.
struct PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR * PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE
Definition: peak_ipl_backend.h:218
size_t y
Definition: peak_ipl_hotpixel_correction.hpp:31