IDS peak IPL v1.17.1
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
39{
40public:
56
64
72
85
98
107 HotpixelCorrection(HotpixelCorrection&& other) noexcept;
108
118
129
140
150 void SetGainFactorPercent(uint32_t gainFactorPercent = 100);
151
161 PEAK_IPL_NO_DISCARD uint32_t GainFactorPercent() const;
162
178 PEAK_IPL_NO_DISCARD std::vector<Point2D> Detect(const Image& inputImage) const;
179
201 PEAK_IPL_NO_DISCARD Image Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const;
202
223 Image& CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const;
224
246
265 Image& CorrectAdaptiveInPlace(Image& inputImage);
266
267private:
269};
270
271} /* namespace ipl */
272} /* namespace peak */
273
275
276namespace peak
277{
278namespace ipl
279{
280
282{
285
286 // make sure default params are set
289}
290
292{
293 if (m_backendHandle)
294 {
296 }
297}
298
300{
301 if (other.m_backendHandle)
302 {
304 }
305
306 m_backendHandle = other.m_backendHandle;
307}
308
310{
311 if (this != &other)
312 {
313 if (m_backendHandle)
314 {
316 }
317
318 if (other.m_backendHandle)
319 {
321 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_Acquire(other.m_backendHandle); });
322 }
323 }
324
325 m_backendHandle = other.m_backendHandle;
326
327 return *this;
328}
329
331{
332 *this = std::move(other);
333}
334
336{
337 if (this != &other)
338 {
339 if (m_backendHandle != nullptr)
340 {
342 }
343
344 m_backendHandle = other.m_backendHandle;
345 other.m_backendHandle = nullptr;
346 }
347
348 return *this;
349}
350
352{
355 m_backendHandle, static_cast<PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY>(sensitivityLevel));
356 });
357}
358
360{
364 m_backendHandle, &sensitivityLevel);
365 });
366
367 return static_cast<SensitivityLevel>(sensitivityLevel);
368}
369
370inline void HotpixelCorrection::SetGainFactorPercent(uint32_t gainFactorPercent)
371{
374 m_backendHandle, gainFactorPercent);
375 });
376}
377
379{
380 uint32_t gainFactorPercent;
383 m_backendHandle, &gainFactorPercent);
384 });
385
386 return gainFactorPercent;
387}
388
389inline std::vector<Point2D> HotpixelCorrection::Detect(const Image& inputImage) const
390{
393 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
394 });
395
396 size_t size = 0;
398 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(m_backendHandle, nullptr, &size);
399 });
400 std::vector<Point2D> hotpixels(size);
403 m_backendHandle, reinterpret_cast<PEAK_IPL_POINT_2D*>(hotpixels.data()), &size);
404 });
405
406 return hotpixels;
407}
408
409inline Image HotpixelCorrection::Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const
410{
411 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
414 ImageBackendAccessor::BackendHandle(inputImage),
415 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size(), &outputImageHandle);
416 });
417
418 return ImageBackendAccessor::CreateImage(outputImageHandle);
419}
420
421inline Image& HotpixelCorrection::CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const
422{
425 ImageBackendAccessor::BackendHandle(inputImage),
426 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size());
427 });
428
429 return inputImage;
430}
431
433{
434 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
437 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
438 });
439
440 return ImageBackendAccessor::CreateImage(outputImageHandle);
441}
442
444{
447 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
448 });
449
450 return inputImage;
451}
452
453
454} /* namespace ipl */
455} /* namespace peak */
Algorithm for (adaptive) hotpixel detection and correction.
Definition peak_ipl_hotpixel_correction.hpp:39
~HotpixelCorrection()
Destructor for the HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:291
uint32_t GainFactorPercent() const
Returns the current gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:378
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:421
Image CorrectAdaptive(const Image &inputImage)
Corrects the given image adaptively.
Definition peak_ipl_hotpixel_correction.hpp:432
Image & CorrectAdaptiveInPlace(Image &inputImage)
Corrects the given image inplace adaptively.
Definition peak_ipl_hotpixel_correction.hpp:443
HotpixelCorrection & operator=(const HotpixelCorrection &other)
Copy assigment for HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:309
void SetSensitivity(SensitivityLevel sensitivityLevel=SensitivityLevel::SensitivityLevel3)
Sets the sensitivity of the hotpixel detection.
Definition peak_ipl_hotpixel_correction.hpp:351
SensitivityLevel Sensitivity() const
Returns the current sensitivity.
Definition peak_ipl_hotpixel_correction.hpp:359
SensitivityLevel
SensitivityLevel parameter for the HotpixelCorrection algorithm.
Definition peak_ipl_hotpixel_correction.hpp:48
@ SensitivityLevel2
Definition peak_ipl_hotpixel_correction.hpp:51
@ SensitivityLevel5
Definition peak_ipl_hotpixel_correction.hpp:54
@ SensitivityLevel3
default
Definition peak_ipl_hotpixel_correction.hpp:52
@ Invalid
Definition peak_ipl_hotpixel_correction.hpp:49
@ SensitivityLevel1
Definition peak_ipl_hotpixel_correction.hpp:50
@ SensitivityLevel4
Definition peak_ipl_hotpixel_correction.hpp:53
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:409
std::vector< Point2D > Detect(const Image &inputImage) const
Detects hotpixels in the given image.
Definition peak_ipl_hotpixel_correction.hpp:389
void SetGainFactorPercent(uint32_t gainFactorPercent=100)
Sets the gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:370
HotpixelCorrection()
Constructor for a new HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:281
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:47
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:289
#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:381
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:405
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:250