IDS peak IPL v1.15.0
Loading...
Searching...
No Matches
peak_ipl_hotpixel_correction.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
14
15#include <cstdint>
16#include <vector>
17
18namespace peak
19{
20namespace ipl
21{
22
23class Image;
24struct Point2D;
25
26
27
38{
39public:
55
63
71
84
97
106 HotpixelCorrection(HotpixelCorrection&& other) noexcept;
107
117
128
139
149 void SetGainFactorPercent(uint32_t gainFactorPercent = 100);
150
160 PEAK_IPL_NO_DISCARD uint32_t GainFactorPercent() const;
161
177 PEAK_IPL_NO_DISCARD std::vector<Point2D> Detect(const Image& inputImage) const;
178
200 PEAK_IPL_NO_DISCARD Image Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const;
201
222 Image& CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const;
223
245
264 Image& CorrectAdaptiveInPlace(Image& inputImage);
265
266private:
268};
269
270} /* namespace ipl */
271} /* namespace peak */
272
274
275namespace peak
276{
277namespace ipl
278{
279
281{
284
285 // make sure default params are set
288}
289
291{
292 if (m_backendHandle)
293 {
295 }
296}
297
299{
300 if (other.m_backendHandle)
301 {
303 }
304
305 m_backendHandle = other.m_backendHandle;
306}
307
309{
310 if (this != &other)
311 {
312 if (m_backendHandle)
313 {
315 }
316
317 if (other.m_backendHandle)
318 {
320 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_Acquire(other.m_backendHandle); });
321 }
322 }
323
324 m_backendHandle = other.m_backendHandle;
325
326 return *this;
327}
328
330{
331 *this = std::move(other);
332}
333
335{
336 if (this != &other)
337 {
338 if (m_backendHandle != nullptr)
339 {
341 }
342
343 m_backendHandle = other.m_backendHandle;
344 other.m_backendHandle = nullptr;
345 }
346
347 return *this;
348}
349
351{
354 m_backendHandle, static_cast<PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY>(sensitivityLevel));
355 });
356}
357
359{
363 m_backendHandle, &sensitivityLevel);
364 });
365
366 return static_cast<SensitivityLevel>(sensitivityLevel);
367}
368
369inline void HotpixelCorrection::SetGainFactorPercent(uint32_t gainFactorPercent)
370{
373 m_backendHandle, gainFactorPercent);
374 });
375}
376
378{
379 uint32_t gainFactorPercent;
382 m_backendHandle, &gainFactorPercent);
383 });
384
385 return gainFactorPercent;
386}
387
388inline std::vector<Point2D> HotpixelCorrection::Detect(const Image& inputImage) const
389{
392 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
393 });
394
395 size_t size = 0;
397 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(m_backendHandle, nullptr, &size);
398 });
399 std::vector<Point2D> hotpixels(size);
402 m_backendHandle, reinterpret_cast<PEAK_IPL_POINT_2D*>(hotpixels.data()), &size);
403 });
404
405 return hotpixels;
406}
407
408inline Image HotpixelCorrection::Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const
409{
410 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
413 ImageBackendAccessor::BackendHandle(inputImage),
414 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size(), &outputImageHandle);
415 });
416
417 return ImageBackendAccessor::CreateImage(outputImageHandle);
418}
419
420inline Image& HotpixelCorrection::CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const
421{
424 ImageBackendAccessor::BackendHandle(inputImage),
425 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size());
426 });
427
428 return inputImage;
429}
430
432{
433 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
436 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
437 });
438
439 return ImageBackendAccessor::CreateImage(outputImageHandle);
440}
441
443{
446 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
447 });
448
449 return inputImage;
450}
451
452
453} /* namespace ipl */
454} /* namespace peak */
Algorithm for (adaptive) hotpixel detection and correction.
Definition peak_ipl_hotpixel_correction.hpp:38
~HotpixelCorrection()
Destructor for the HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:290
uint32_t GainFactorPercent() const
Returns the current gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:377
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:420
Image CorrectAdaptive(const Image &inputImage)
Corrects the given image adaptively.
Definition peak_ipl_hotpixel_correction.hpp:431
Image & CorrectAdaptiveInPlace(Image &inputImage)
Corrects the given image inplace adaptively.
Definition peak_ipl_hotpixel_correction.hpp:442
HotpixelCorrection & operator=(const HotpixelCorrection &other)
Copy assigment for HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:308
void SetSensitivity(SensitivityLevel sensitivityLevel=SensitivityLevel::SensitivityLevel3)
Sets the sensitivity of the hotpixel detection.
Definition peak_ipl_hotpixel_correction.hpp:350
SensitivityLevel Sensitivity() const
Returns the current sensitivity.
Definition peak_ipl_hotpixel_correction.hpp:358
SensitivityLevel
SensitivityLevel parameter for the HotpixelCorrection algorithm.
Definition peak_ipl_hotpixel_correction.hpp:47
@ SensitivityLevel2
Definition peak_ipl_hotpixel_correction.hpp:50
@ SensitivityLevel5
Definition peak_ipl_hotpixel_correction.hpp:53
@ SensitivityLevel3
default
Definition peak_ipl_hotpixel_correction.hpp:51
@ Invalid
Definition peak_ipl_hotpixel_correction.hpp:48
@ SensitivityLevel1
Definition peak_ipl_hotpixel_correction.hpp:49
@ SensitivityLevel4
Definition peak_ipl_hotpixel_correction.hpp:52
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:408
std::vector< Point2D > Detect(const Image &inputImage) const
Detects hotpixels in the given image.
Definition peak_ipl_hotpixel_correction.hpp:388
void SetGainFactorPercent(uint32_t gainFactorPercent=100)
Sets the gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:369
HotpixelCorrection()
Constructor for a new HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:280
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:41
Definition peak_ipl_binning.hpp:25
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:182
The "peak::ipl" namespace contains the whole image processing library.
Definition peak_ipl_binning.hpp:23
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:25
struct PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR * PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE
Definition peak_ipl_backend.h:364
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Correct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle, const struct PEAK_IPL_POINT_2D *hotpixels, size_t hotpixelsSize, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Corrects the given hotpixels in the given image.
int32_t PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY
Definition peak_ipl_backend.h:214
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, struct PEAK_IPL_POINT_2D *hotpixels, size_t *hotpixelsSize)
Queries previously detected hotpixels.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_CorrectInPlace(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle, PEAK_IPL_IMAGE_HANDLE inputImageHandle, const struct PEAK_IPL_POINT_2D *hotpixels, size_t hotpixelsSize)
Corrects the given hotpixels in place of the given image.
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's current sensitivity.
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's current gain factor in percent.
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.
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's gain factor in percent.
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:388
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.
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.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Construct(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE *adaptiveHotpixelCorrectorHandle)
Creates an adaptive hotpixel corrector algorithm.
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.
PEAK_IPL_C_API PEAK_IPL_AdaptiveHotpixelCorrector_Acquire(PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE adaptiveHotpixelCorrectorHandle)
Increase the reference count of an adaptive hotpixel corrector.
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's sensitivity.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16
Definition peak_ipl_backend.h:259
2D position in an image.
Definition peak_ipl_simple_types.hpp:240