IDS peak IPL v1.16.0
Loading...
Searching...
No Matches
peak_ipl_gain.hpp
Go to the documentation of this file.
1
10
11#pragma once
12
18
19namespace
20{
21class GainBackendAccessor;
22}
23
27namespace peak
28{
29namespace ipl
30{
31
35class Gain final
36{
37public:
44 Gain();
45
52 ~Gain();
53
65 Gain(const Gain& other);
66
78 Gain& operator=(const Gain& other);
79
88 Gain(Gain&& other) noexcept;
89
98 Gain& operator=(Gain&& other) noexcept;
99
109 void SetMasterGainValue(float masterGainValue);
110
119
128
137
147 void SetRedGainValue(float redGainValue);
148
156 PEAK_IPL_NO_DISCARD float RedGainValue() const;
157
165 PEAK_IPL_NO_DISCARD float RedGainMin() const;
166
174 PEAK_IPL_NO_DISCARD float RedGainMax() const;
175
185 void SetGreenGainValue(float greenGainValue);
186
195
203 PEAK_IPL_NO_DISCARD float GreenGainMin() const;
204
212 PEAK_IPL_NO_DISCARD float GreenGainMax() const;
213
223 void SetBlueGainValue(float blueGainValue);
224
233
241 PEAK_IPL_NO_DISCARD float BlueGainMin() const;
242
250 PEAK_IPL_NO_DISCARD float BlueGainMax() const;
251
262
276 void ProcessInPlace(Image& image) const;
277
292 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
293
294private:
295 friend GainBackendAccessor;
296 explicit Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept;
297 PEAK_IPL_GAIN_HANDLE m_backendHandle{};
298};
299
300} /* namespace ipl */
301} /* namespace peak */
302
303namespace
304{
305
307class GainBackendAccessor
308{
309public:
317 static PEAK_IPL_GAIN_HANDLE BackendHandle(const peak::ipl::Gain& gain)
318 {
319 return gain.m_backendHandle;
320 }
321
331 static peak::ipl::Gain CreateGain(PEAK_IPL_GAIN_HANDLE gainHandle)
332 {
333 return peak::ipl::Gain(gainHandle);
334 }
335};
336
337} /* namespace */
338
339namespace peak
340{
341namespace ipl
342{
344{
346}
347
348inline Gain::Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept
349 : m_backendHandle{ gainHandle }
350{
352}
353
355{
356 if (m_backendHandle)
357 {
358 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
359 }
360}
361
362inline Gain::Gain(Gain&& other) noexcept
363{
364 *this = std::move(other);
365}
366
367inline Gain::Gain(const Gain& other)
368{
369 if (other.m_backendHandle)
370 {
371 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
372 }
373
374 m_backendHandle = other.m_backendHandle;
375}
376
377inline Gain& Gain::operator=(const Gain& other)
378{
379 if (this != &other)
380 {
381 if (m_backendHandle)
382 {
383 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
384 }
385
386 if (other.m_backendHandle)
387 {
388 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
389 }
390 }
391
392 m_backendHandle = other.m_backendHandle;
393
394 return *this;
395}
396
397inline Gain& Gain::operator=(Gain&& other) noexcept
398{
399 if (this != &other)
400 {
401 if (m_backendHandle != nullptr)
402 {
403 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
404 }
405
406 m_backendHandle = other.m_backendHandle;
407 other.m_backendHandle = nullptr;
408 }
409
410 return *this;
411}
412inline void Gain::SetMasterGainValue(float masterGainValue)
413{
416 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
417 });
418}
419inline float Gain::MasterGainValue() const
420{
421 float masterGainValue;
422
425 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
426 });
427
428 return masterGainValue;
429}
430inline float Gain::MasterGainMin() const
431{
432 float masterGainMin;
433
436 m_backendHandle, reinterpret_cast<float*>(&masterGainMin));
437 });
438
439 return masterGainMin;
440}
441inline float Gain::MasterGainMax() const
442{
443 float masterGainMax;
444
447 m_backendHandle, reinterpret_cast<float*>(&masterGainMax));
448 });
449
450 return masterGainMax;
451}
452inline void Gain::SetRedGainValue(float redGainValue)
453{
456 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
457 });
458}
459inline float Gain::RedGainValue() const
460{
461 float redGainValue;
462
465 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
466 });
467
468 return redGainValue;
469}
470inline float Gain::RedGainMin() const
471{
472 float redGainMin;
473
475 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMin(m_backendHandle, reinterpret_cast<float*>(&redGainMin));
476 });
477
478 return redGainMin;
479}
480inline float Gain::RedGainMax() const
481{
482 float redGainMax;
483
485 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMax(m_backendHandle, reinterpret_cast<float*>(&redGainMax));
486 });
487
488 return redGainMax;
489}
490inline void Gain::SetGreenGainValue(float greenGainValue)
491{
494 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
495 });
496}
497inline float Gain::GreenGainValue() const
498{
499 float greenGainValue;
500
503 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
504 });
505
506 return greenGainValue;
507}
508inline float Gain::GreenGainMin() const
509{
510 float greenGainMin;
511
514 m_backendHandle, reinterpret_cast<float*>(&greenGainMin));
515 });
516
517 return greenGainMin;
518}
519inline float Gain::GreenGainMax() const
520{
521 float greenGainMax;
522
525 m_backendHandle, reinterpret_cast<float*>(&greenGainMax));
526 });
527
528 return greenGainMax;
529}
530inline void Gain::SetBlueGainValue(float blueGainValue)
531{
534 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
535 });
536}
537inline float Gain::BlueGainValue() const
538{
539 float blueGainValue;
540
543 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
544 });
545
546 return blueGainValue;
547}
548inline float Gain::BlueGainMin() const
549{
550 float blueGainMin;
551
554 m_backendHandle, reinterpret_cast<float*>(&blueGainMin));
555 });
556
557 return blueGainMin;
558}
559inline float Gain::BlueGainMax() const
560{
561 float blueGainMax;
562
565 m_backendHandle, reinterpret_cast<float*>(&blueGainMax));
566 });
567
568 return blueGainMax;
569}
570inline bool Gain::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
571{
572 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
573
576 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
577 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
578 });
579
580 return isPixelFormatSupported > 0;
581}
582inline void Gain::ProcessInPlace(Image& image) const
583{
586 m_backendHandle, ImageBackendAccessor::BackendHandle(image));
587 });
588}
589inline Image Gain::Process(const Image& inputImage) const
590{
591 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
594 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
595 });
596
597 return ImageBackendAccessor::CreateImage(outputImageHandle);
598}
599
600} /* namespace ipl */
601} /* namespace peak */
Applies gain to the data.
Definition peak_ipl_gain.hpp:36
float GreenGainMin() const
Returns the minimum value of the green gain.
Definition peak_ipl_gain.hpp:508
float GreenGainValue() const
Returns the value of the green gain.
Definition peak_ipl_gain.hpp:497
~Gain()
Destructor for the Gain instance.
Definition peak_ipl_gain.hpp:354
void ProcessInPlace(Image &image) const
Applies the gain on the given image in place that is, it will change the input image.
Definition peak_ipl_gain.hpp:582
float BlueGainValue() const
Returns the value of the blue gain.
Definition peak_ipl_gain.hpp:537
Image Process(const Image &inputImage) const
Applies the gain on the given image.
Definition peak_ipl_gain.hpp:589
float MasterGainMax() const
Returns the maximum value of the master gain.
Definition peak_ipl_gain.hpp:441
Gain & operator=(const Gain &other)
Copy assigment for Gain instance.
Definition peak_ipl_gain.hpp:377
float MasterGainValue() const
Returns the value of the master gain.
Definition peak_ipl_gain.hpp:419
void SetRedGainValue(float redGainValue)
Sets the values of the red Gain.
Definition peak_ipl_gain.hpp:452
float BlueGainMax() const
Returns the maximum value of the blue gain.
Definition peak_ipl_gain.hpp:559
void SetMasterGainValue(float masterGainValue)
Sets the values of the master Gain.
Definition peak_ipl_gain.hpp:412
float GreenGainMax() const
Returns the maximum value of the green gain.
Definition peak_ipl_gain.hpp:519
float RedGainMin() const
Returns the minimum value of the red gain.
Definition peak_ipl_gain.hpp:470
float BlueGainMin() const
Returns the minimum value of the blue gain.
Definition peak_ipl_gain.hpp:548
float MasterGainMin() const
Returns the minimum value of the master gain.
Definition peak_ipl_gain.hpp:430
void SetGreenGainValue(float greenGainValue)
Sets the values of the green Gain.
Definition peak_ipl_gain.hpp:490
void SetBlueGainValue(float blueGainValue)
Sets the values of the blue Gain.
Definition peak_ipl_gain.hpp:530
float RedGainValue() const
Returns the value of the red gain.
Definition peak_ipl_gain.hpp:459
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gain supports the given pixel format.
Definition peak_ipl_gain.hpp:570
float RedGainMax() const
Returns the maximum value of the red gain.
Definition peak_ipl_gain.hpp:480
Gain()
Constructor for a new Gain instance.
Definition peak_ipl_gain.hpp:343
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
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:39
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
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainMin)
Returns the minimum red gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_GetIsPixelFormatSupported(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_PIXEL_FORMAT pixelFormat, PEAK_IPL_BOOL8 *isPixelFormatSupported)
Asks the given gamma corrector whether it supports the given pixel format.
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainMax)
Returns the maximum red gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_SetBlueGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainValue)
Sets the value of the blue gain.
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainValue)
Returns the green gain value.
PEAK_IPL_C_API PEAK_IPL_Gain_GetRedGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainValue)
Returns the red gain value.
PEAK_IPL_C_API PEAK_IPL_Gain_SetGreenGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainValue)
Sets the value of the green gain.
PEAK_IPL_C_API PEAK_IPL_Gain_Process(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_IMAGE_HANDLE imageHandle, PEAK_IPL_IMAGE_HANDLE *outputImageHandle)
Apply the gain on the given image.
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainMax)
Returns the maximum blue gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainMax)
Returns the maximum master gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_SetMasterGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainValue)
Sets the value of the master gain.
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainMax(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainMax)
Returns the maximum green gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainMin)
Returns the minimum master gain value which can be set.
PEAK_IPL_C_API PEAK_IPL_Gain_Construct(PEAK_IPL_GAIN_HANDLE *gainHandle)
Creates a gain.
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainMin)
Returns the minimum blue gain value which can be set.
struct PEAK_IPL_GAIN * PEAK_IPL_GAIN_HANDLE
Definition peak_ipl_backend.h:397
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:405
PEAK_IPL_C_API PEAK_IPL_Gain_GetMasterGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *masterGainValue)
Returns the master gain value.
PEAK_IPL_C_API PEAK_IPL_Gain_ProcessInPlace(PEAK_IPL_GAIN_HANDLE gainHandle, PEAK_IPL_IMAGE_HANDLE imageHandle)
Apply the gain on the given image.
PEAK_IPL_C_API PEAK_IPL_Gain_Destruct(PEAK_IPL_GAIN_HANDLE gainHandle)
Destroys the gain associated with the given handle.
int8_t PEAK_IPL_BOOL8
Definition peak_ipl_backend.h:26
PEAK_IPL_C_API PEAK_IPL_Gain_GetBlueGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *blueGainValue)
Returns the blue gain value.
int32_t PEAK_IPL_PIXEL_FORMAT
Definition peak_ipl_backend.h:173
PEAK_IPL_C_API PEAK_IPL_Gain_SetRedGainValue(PEAK_IPL_GAIN_HANDLE gainHandle, float *redGainValue)
Sets the value of the red gain.
PEAK_IPL_C_API PEAK_IPL_Gain_Acquire(PEAK_IPL_GAIN_HANDLE gainHandle)
Increase the reference count of a gain object.
PEAK_IPL_C_API PEAK_IPL_Gain_GetGreenGainMin(PEAK_IPL_GAIN_HANDLE gainHandle, float *greenGainMin)
Returns the minimum green gain value which can be set.
#define PEAK_IPL_C_ABI_PREFIX
Definition peak_ipl_dll_defines.h:16