IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_hotpixel_correction.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
9
10#include <cstdint>
11#include <vector>
12
13namespace peak
14{
15namespace ipl
16{
17
18class Image;
19struct Point2D;
20
21
22
34{
35public:
51
59
67
80
93
102 HotpixelCorrection(HotpixelCorrection&& other) noexcept;
103
113
124
135
145 void SetGainFactorPercent(uint32_t gainFactorPercent = 100);
146
156 PEAK_IPL_NO_DISCARD uint32_t GainFactorPercent() const;
157
173 PEAK_IPL_NO_DISCARD std::vector<Point2D> Detect(const Image& inputImage) const;
174
196 PEAK_IPL_NO_DISCARD Image Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const;
197
218 Image& CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const;
219
241
260 Image& CorrectAdaptiveInPlace(Image& inputImage);
261
262private:
264};
265
266} /* namespace ipl */
267} /* namespace peak */
268
270
271namespace peak
272{
273namespace ipl
274{
275
277{
280
281 // make sure default params are set
284}
285
287{
288 if (m_backendHandle)
289 {
291 }
292}
293
295{
296 if (other.m_backendHandle)
297 {
299 }
300
301 m_backendHandle = other.m_backendHandle;
302}
303
305{
306 if (this != &other)
307 {
308 if (m_backendHandle)
309 {
311 }
312
313 if (other.m_backendHandle)
314 {
316 [&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_Acquire(other.m_backendHandle); });
317 }
318 }
319
320 m_backendHandle = other.m_backendHandle;
321
322 return *this;
323}
324
326{
327 *this = std::move(other);
328}
329
331{
332 if (this != &other)
333 {
334 if (m_backendHandle != nullptr)
335 {
337 }
338
339 m_backendHandle = other.m_backendHandle;
340 other.m_backendHandle = nullptr;
341 }
342
343 return *this;
344}
345
347{
350 m_backendHandle, static_cast<PEAK_IPL_HOTPIXELCORRECTION_SENSITIVITY>(sensitivityLevel));
351 });
352}
353
355{
359 m_backendHandle, &sensitivityLevel);
360 });
361
362 return static_cast<SensitivityLevel>(sensitivityLevel);
363}
364
365inline void HotpixelCorrection::SetGainFactorPercent(uint32_t gainFactorPercent)
366{
369 m_backendHandle, gainFactorPercent);
370 });
371}
372
374{
375 uint32_t gainFactorPercent;
378 m_backendHandle, &gainFactorPercent);
379 });
380
381 return gainFactorPercent;
382}
383
384inline std::vector<Point2D> HotpixelCorrection::Detect(const Image& inputImage) const
385{
388 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
389 });
390
391 size_t size = 0;
393 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_AdaptiveHotpixelCorrector_GetHotpixels(m_backendHandle, nullptr, &size);
394 });
395 std::vector<Point2D> hotpixels(size);
398 m_backendHandle, reinterpret_cast<PEAK_IPL_POINT_2D*>(hotpixels.data()), &size);
399 });
400
401 return hotpixels;
402}
403
404inline Image HotpixelCorrection::Correct(const Image& inputImage, const std::vector<Point2D>& hotpixels) const
405{
406 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
409 ImageBackendAccessor::BackendHandle(inputImage),
410 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size(), &outputImageHandle);
411 });
412
413 return ImageBackendAccessor::CreateImage(outputImageHandle);
414}
415
416inline Image& HotpixelCorrection::CorrectInPlace(Image& inputImage, const std::vector<Point2D>& hotpixels) const
417{
420 ImageBackendAccessor::BackendHandle(inputImage),
421 reinterpret_cast<const PEAK_IPL_POINT_2D*>(hotpixels.data()), hotpixels.size());
422 });
423
424 return inputImage;
425}
426
428{
429 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
432 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
433 });
434
435 return ImageBackendAccessor::CreateImage(outputImageHandle);
436}
437
439{
442 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage));
443 });
444
445 return inputImage;
446}
447
448
449} /* namespace ipl */
450} /* namespace peak */
Algorithm for (adaptive) hotpixel detection and correction.
Definition peak_ipl_hotpixel_correction.hpp:34
~HotpixelCorrection()
Destructor for the HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:286
uint32_t GainFactorPercent() const
Returns the current gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:373
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:416
Image CorrectAdaptive(const Image &inputImage)
Corrects the given image adaptively.
Definition peak_ipl_hotpixel_correction.hpp:427
Image & CorrectAdaptiveInPlace(Image &inputImage)
Corrects the given image inplace adaptively.
Definition peak_ipl_hotpixel_correction.hpp:438
HotpixelCorrection & operator=(const HotpixelCorrection &other)
Copy assigment for HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:304
void SetSensitivity(SensitivityLevel sensitivityLevel=SensitivityLevel::SensitivityLevel3)
Sets the sensitivity of the hotpixel detection.
Definition peak_ipl_hotpixel_correction.hpp:346
SensitivityLevel Sensitivity() const
Returns the current sensitivity.
Definition peak_ipl_hotpixel_correction.hpp:354
SensitivityLevel
SensitivityLevel parameter for the HotpixelCorrection algorithm.
Definition peak_ipl_hotpixel_correction.hpp:43
@ SensitivityLevel2
Definition peak_ipl_hotpixel_correction.hpp:46
@ SensitivityLevel5
Definition peak_ipl_hotpixel_correction.hpp:49
@ SensitivityLevel3
default
Definition peak_ipl_hotpixel_correction.hpp:47
@ Invalid
Definition peak_ipl_hotpixel_correction.hpp:44
@ SensitivityLevel1
Definition peak_ipl_hotpixel_correction.hpp:45
@ SensitivityLevel4
Definition peak_ipl_hotpixel_correction.hpp:48
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:404
std::vector< Point2D > Detect(const Image &inputImage) const
Detects hotpixels in the given image.
Definition peak_ipl_hotpixel_correction.hpp:384
void SetGainFactorPercent(uint32_t gainFactorPercent=100)
Sets the gain factor in percent.
Definition peak_ipl_hotpixel_correction.hpp:365
HotpixelCorrection()
Constructor for a new HotpixelCorrection instance.
Definition peak_ipl_hotpixel_correction.hpp:276
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:42
The "peak::ipl" namespace contains the whole image processing library.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:284
#define PEAK_IPL_NO_DISCARD
Definition peak_ipl_attribute_defines.h:20
struct PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR * PEAK_IPL_ADAPTIVE_HOTPIXEL_CORRECTOR_HANDLE
Definition peak_ipl_backend.h:378
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:211
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:402
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:11
Definition peak_ipl_backend.h:256
2D position in an image.
Definition peak_ipl_simple_types.hpp:245