IDS peak IPL  v1.7.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 struct Point2D;
25 
26 
27 
37 class HotpixelCorrection final
38 {
39 public:
46  enum class SensitivityLevel
47  {
48  Invalid,
51  SensitivityLevel3, // default
54  };
55 
58  HotpixelCorrection(const HotpixelCorrection& other) = delete;
59  HotpixelCorrection& operator=(const HotpixelCorrection& other) = delete;
60  HotpixelCorrection(HotpixelCorrection&& other) noexcept;
62 
73 
84 
94  void SetGainFactorPercent(uint32_t gainFactorPercent = 100);
95 
105  uint32_t GainFactorPercent() const;
106 
107 
123  std::vector<Point2D> Detect(const Image& inputImage) const;
124 
144  Image Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const;
145 
164  Image& CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const;
165 
184  Image CorrectAdaptive(const Image& inputImage);
185 
202  Image& CorrectAdaptiveInPlace(Image& inputImage);
203 
204 private:
206 };
207 
208 } /* namespace ipl */
209 } /* namespace peak */
210 
212 
213 namespace peak
214 {
215 namespace ipl
216 {
217 
219 {
221  [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_Construct(&m_backendHandle); });
222 
223  // make sure default params are set
224  SetSensitivity();
226 }
227 
229 {
230  if (m_backendHandle)
231  {
233  }
234 }
235 
237 {
238  *this = std::move(other);
239 }
240 
242 {
243  if (this != &other)
244  {
246  m_backendHandle = other.m_backendHandle;
247  other.m_backendHandle = nullptr;
248  }
249 
250  return *this;
251 }
252 
254 {
257  m_backendHandle, static_cast<PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY>(sensitivityLevel));
258  });
259 }
260 
262 {
266  m_backendHandle, &sensitivityLevel);
267  });
268 
269  return static_cast<SensitivityLevel>(sensitivityLevel);
270 }
271 
272 inline void HotpixelCorrection::SetGainFactorPercent(uint32_t gainFactorPercent)
273 {
276  m_backendHandle, gainFactorPercent);
277  });
278 }
279 
281 {
282  uint32_t gainFactorPercent;
285  m_backendHandle, &gainFactorPercent);
286  });
287 
288  return gainFactorPercent;
289 }
290 
291 inline std::vector<Point2D> HotpixelCorrection::Detect(const Image& inputImage) const
292 {
295  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
296  });
297 
298  size_t size = 0;
300  return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(m_backendHandle, nullptr, &size);
301  });
302  std::vector<Point2D> hotpixels(size);
305  m_backendHandle, reinterpret_cast<PEAK_IPL_POINT_2D*>(hotpixels.data()), &size);
306  });
307 
308  return hotpixels;
309 }
310 
311 inline Image HotpixelCorrection::Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const
312 {
313  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
316  ImageBackendAccessor::BackendHandle(inputImage),
317  reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size(), &outputImageHandle);
318  });
319 
320  return ImageBackendAccessor::CreateImage(outputImageHandle);
321 }
322 
323 inline Image& HotpixelCorrection::CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const
324 {
327  ImageBackendAccessor::BackendHandle(inputImage),
328  reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size());
329  });
330 
331  return inputImage;
332 }
333 
335 {
336  PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
339  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
340  });
341 
342  return ImageBackendAccessor::CreateImage(outputImageHandle);
343 }
344 
346 {
349  m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
350  });
351 
352  return inputImage;
353 }
354 
355 
356 } /* namespace ipl */
357 } /* 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:334
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
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_CorrectInPlace(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle, const PEAK_IPL_POINT_2D *hotpixels, size_t hotpixelsSize)
Corrects the given hotpixels in place of the given image.
Image & CorrectInPlace(Image &inputImage, const std::vector< Point2D > &hotpixels) const
Corrects the given hotpixels inplace in the given image.
Definition: peak_ipl_hotpixel_correction.hpp:323
The "peak::ipl" namespace contains the whole image processing library.
Definition: peak_ipl_binning.hpp:22
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:182
Algorithm for (adaptive) hotpixel detection and correction.
Definition: peak_ipl_hotpixel_correction.hpp:37
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:228
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:311
Stores the pixel format, width and height of an image and the pointer to the image buffer...
Definition: peak_ipl_image.hpp:39
SensitivityLevel Sensitivity() const
Returns the current sensitivity.
Definition: peak_ipl_hotpixel_correction.hpp:261
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Construct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE *adaptiveHotpixelCorrectorHandle)
Creates an adaptive hotpixel corrector algorithm.
SensitivityLevel
SensitivityLevel parameter for the HotpixelCorrection algorithm.
Definition: peak_ipl_hotpixel_correction.hpp:46
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition: peak_ipl_backend.h:326
uint32_t GainFactorPercent() const
Returns the current gain factor in percent.
Definition: peak_ipl_hotpixel_correction.hpp:280
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:253
int32_t PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY
Definition: peak_ipl_backend.h:186
HotpixelCorrection & operator=(const HotpixelCorrection &other)=delete
Image & CorrectAdaptiveInPlace(Image &inputImage)
Corrects the given image inplace adaptively.
Definition: peak_ipl_hotpixel_correction.hpp:345
std::vector< Point2D > Detect(const Image &inputImage) const
Detects hotpixels in the given image.
Definition: peak_ipl_hotpixel_correction.hpp:291
HotpixelCorrection()
Definition: peak_ipl_hotpixel_correction.hpp:218
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_CorrectAdaptiveInPlace(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle)
Detects and corrects hotpixels in place within the given image.
void SetGainFactorPercent(uint32_t gainFactorPercent=100)
Sets the gain factor in percent.
Definition: peak_ipl_hotpixel_correction.hpp:272
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:302