IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
peak_icv_hotpixel_detection.hpp
Go to the documentation of this file.
1
11#pragma once
12
15#include <peak_icv_c/algorithms/filters/peak_icv_median_filter.h>
16#include <peak_icv_c/algorithms/preprocessing/peak_icv_hotpixel_correction.h>
17#include <utility>
18
19namespace peak
20{
21namespace icv
22{
23
37{
38public:
47
54
61
67 HotpixelDetection(HotpixelDetection&& other) noexcept;
68
75
82
95 PEAK_COMMON_NO_DISCARD std::vector<peak::common::Point> Detect(const Image& image) const;
96
106 void SetSensitivity(uint32_t sensitivity);
107
115 uint32_t GetSensitivity() const;
116
125
136 void SetGainFactor(float gainFactor);
137
145 float GetGainFactor() const;
146
147private:
148 peak_icv_hotpixel_correction_handle m_handle{};
149 uint32_t m_sensitivity = 3;
150 float m_gainFactor = 1.0F;
151};
152
153inline std::vector<peak::common::Point> HotpixelDetection::Detect(const Image& image) const
154{
156 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_Detect(
157 m_handle, peak::common::detail::BackendAccessor<Image>::BackendHandle(image), m_sensitivity, m_gainFactor);
158 });
159
160 size_t hotpixelCount{};
162 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_GetList_GetCount(m_handle, &hotpixelCount);
163 });
164
165 if (hotpixelCount == 0)
166 {
167 return {};
168 }
169
170 std::vector<peak_common_point> hotpixelsC(hotpixelCount);
172 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_GetList(m_handle, hotpixelsC.data(), hotpixelCount);
173 });
174
175 std::vector<peak::common::Point> hotpixelsCpp;
176 hotpixelsCpp.reserve(hotpixelCount);
177 std::transform(hotpixelsC.begin(), hotpixelsC.end(), std::back_inserter(hotpixelsCpp), [](peak_common_point pointC) {
178 return peak::common::detail::BackendAccessor<peak::common::Point>::CreateInstance(pointC);
179 });
180
181 return hotpixelsCpp;
182}
183
185{
187 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_Create(&m_handle);
188 });
189}
190
192{
194 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_IncreaseUseCount(other.m_handle);
195 });
196 m_handle = other.m_handle;
197 m_gainFactor = other.m_gainFactor;
198 m_sensitivity = other.m_sensitivity;
199}
200
202{
203 m_handle = other.m_handle;
204 other.m_handle = nullptr;
205
206 m_sensitivity = std::move(other.m_sensitivity);
207 m_gainFactor = std::move(other.m_gainFactor);
208}
209
211{
212 if (m_handle != other.m_handle)
213 {
214 if (m_handle != nullptr)
215 {
217 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_Destroy(m_handle);
218 });
219 }
220
222 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_IncreaseUseCount(other.m_handle);
223 });
224 m_handle = other.m_handle;
225 m_gainFactor = other.m_gainFactor;
226 m_sensitivity = other.m_sensitivity;
227 }
228
229 return *this;
230}
231
233{
234 if (m_handle != other.m_handle)
235 {
236 if (m_handle != nullptr)
237 {
239 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_Destroy(m_handle);
240 });
241 }
242
243 m_handle = other.m_handle;
244 other.m_handle = nullptr;
245 m_sensitivity = std::move(other.m_sensitivity);
246 m_gainFactor = std::move(other.m_gainFactor);
247 }
248
249 return *this;
250}
251
253{
254 if (m_handle != nullptr)
255 {
256 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_Destroy(m_handle);
257 }
258}
259
260inline void HotpixelDetection::SetSensitivity(uint32_t sensitivity)
261{
262 const auto range = GetSensitivityRange();
263
264 if (sensitivity < range.GetMinimum() || sensitivity > range.GetMaximum())
265 {
266 throw OutOfRangeException("The given sensitivity is out of range. Check GetSensitivityRange() function for the valid range.");
267 }
268
269 m_sensitivity = sensitivity;
270}
271
273{
274 return m_sensitivity;
275}
276
278{
279 peak_common_interval_u sensitivityRange;
281 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_HotpixelCorrection_GetSensitivityRange(m_handle, &sensitivityRange);
282 });
283
284 return peak::common::detail::BackendAccessor<peak::common::IntervalU>::CreateInstance(sensitivityRange);
285}
286
287inline void HotpixelDetection::SetGainFactor(float gainFactor)
288{
289 m_gainFactor = gainFactor;
290}
291
293{
294 return m_gainFactor;
295}
296
297} /* namespace icv */
298} /* namespace peak */
Represents a continuous numeric interval with inclusive lower and upper bounds.
Detects hot pixels in images taken by a camera by identifying anomalies in the pixels intensities.
float GetGainFactor() const
Gets the current gain factor.
peak::common::IntervalU GetSensitivityRange()
Retrieves the valid range of sensitivity values.
HotpixelDetection()
Constructs a new HotpixelDetection instance.
void SetGainFactor(float gainFactor)
Sets the gain factor used during detection.
void SetSensitivity(uint32_t sensitivity)
Sets the sensitivity used during hot pixel detection.
std::vector< peak::common::Point > Detect(const Image &image) const
Detects hot pixels in the provided image.
HotpixelDetection & operator=(const HotpixelDetection &other)
uint32_t GetSensitivity() const
Returns the currently configured detection sensitivity.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
Occurs when a provided value falls outside the allowed valid range.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)