IDS peak IPL v1.18.0
Loading...
Searching...
No Matches
peak_ipl_gain.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
13
14namespace
15{
16class GainBackendAccessor;
17}
18
23
24namespace peak
25{
26namespace ipl
27{
28
33class Gain final
34{
35public:
42 Gain();
43
50 ~Gain();
51
63 Gain(const Gain& other);
64
76 Gain& operator=(const Gain& other);
77
86 Gain(Gain&& other) noexcept;
87
96 Gain& operator=(Gain&& other) noexcept;
97
107 void SetMasterGainValue(float masterGainValue);
108
117
126
135
145 void SetRedGainValue(float redGainValue);
146
154 PEAK_IPL_NO_DISCARD float RedGainValue() const;
155
163 PEAK_IPL_NO_DISCARD float RedGainMin() const;
164
172 PEAK_IPL_NO_DISCARD float RedGainMax() const;
173
183 void SetGreenGainValue(float greenGainValue);
184
193
201 PEAK_IPL_NO_DISCARD float GreenGainMin() const;
202
210 PEAK_IPL_NO_DISCARD float GreenGainMax() const;
211
221 void SetBlueGainValue(float blueGainValue);
222
231
239 PEAK_IPL_NO_DISCARD float BlueGainMin() const;
240
248 PEAK_IPL_NO_DISCARD float BlueGainMax() const;
249
260
274 void ProcessInPlace(Image& image) const;
275
290 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
291
292private:
293 friend GainBackendAccessor;
294 explicit Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept;
295 PEAK_IPL_GAIN_HANDLE m_backendHandle{};
296};
297
298} /* namespace ipl */
299} /* namespace peak */
300
301namespace
302{
303
305class GainBackendAccessor
306{
307public:
315 static PEAK_IPL_GAIN_HANDLE BackendHandle(const peak::ipl::Gain& gain)
316 {
317 return gain.m_backendHandle;
318 }
319
329 static peak::ipl::Gain CreateGain(PEAK_IPL_GAIN_HANDLE gainHandle)
330 {
331 return peak::ipl::Gain(gainHandle);
332 }
333};
334
335} /* namespace */
336
337namespace peak
338{
339namespace ipl
340{
342{
344}
345
346inline Gain::Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept
347 : m_backendHandle{ gainHandle }
348{
350}
351
353{
354 if (m_backendHandle)
355 {
356 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
357 }
358}
359
360inline Gain::Gain(Gain&& other) noexcept
361{
362 *this = std::move(other);
363}
364
365inline Gain::Gain(const Gain& other)
366{
367 if (other.m_backendHandle)
368 {
369 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
370 }
371
372 m_backendHandle = other.m_backendHandle;
373}
374
375inline Gain& Gain::operator=(const Gain& other)
376{
377 if (this != &other)
378 {
379 if (m_backendHandle)
380 {
381 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
382 }
383
384 if (other.m_backendHandle)
385 {
386 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
387 }
388 }
389
390 m_backendHandle = other.m_backendHandle;
391
392 return *this;
393}
394
395inline Gain& Gain::operator=(Gain&& other) noexcept
396{
397 if (this != &other)
398 {
399 if (m_backendHandle != nullptr)
400 {
401 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
402 }
403
404 m_backendHandle = other.m_backendHandle;
405 other.m_backendHandle = nullptr;
406 }
407
408 return *this;
409}
410inline void Gain::SetMasterGainValue(float masterGainValue)
411{
414 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
415 });
416}
417inline float Gain::MasterGainValue() const
418{
419 float masterGainValue;
420
423 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
424 });
425
426 return masterGainValue;
427}
428inline float Gain::MasterGainMin() const
429{
430 float masterGainMin;
431
434 m_backendHandle, reinterpret_cast<float*>(&masterGainMin));
435 });
436
437 return masterGainMin;
438}
439inline float Gain::MasterGainMax() const
440{
441 float masterGainMax;
442
445 m_backendHandle, reinterpret_cast<float*>(&masterGainMax));
446 });
447
448 return masterGainMax;
449}
450inline void Gain::SetRedGainValue(float redGainValue)
451{
454 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
455 });
456}
457inline float Gain::RedGainValue() const
458{
459 float redGainValue;
460
463 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
464 });
465
466 return redGainValue;
467}
468inline float Gain::RedGainMin() const
469{
470 float redGainMin;
471
473 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMin(m_backendHandle, reinterpret_cast<float*>(&redGainMin));
474 });
475
476 return redGainMin;
477}
478inline float Gain::RedGainMax() const
479{
480 float redGainMax;
481
483 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMax(m_backendHandle, reinterpret_cast<float*>(&redGainMax));
484 });
485
486 return redGainMax;
487}
488inline void Gain::SetGreenGainValue(float greenGainValue)
489{
492 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
493 });
494}
495inline float Gain::GreenGainValue() const
496{
497 float greenGainValue;
498
501 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
502 });
503
504 return greenGainValue;
505}
506inline float Gain::GreenGainMin() const
507{
508 float greenGainMin;
509
512 m_backendHandle, reinterpret_cast<float*>(&greenGainMin));
513 });
514
515 return greenGainMin;
516}
517inline float Gain::GreenGainMax() const
518{
519 float greenGainMax;
520
523 m_backendHandle, reinterpret_cast<float*>(&greenGainMax));
524 });
525
526 return greenGainMax;
527}
528inline void Gain::SetBlueGainValue(float blueGainValue)
529{
532 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
533 });
534}
535inline float Gain::BlueGainValue() const
536{
537 float blueGainValue;
538
541 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
542 });
543
544 return blueGainValue;
545}
546inline float Gain::BlueGainMin() const
547{
548 float blueGainMin;
549
552 m_backendHandle, reinterpret_cast<float*>(&blueGainMin));
553 });
554
555 return blueGainMin;
556}
557inline float Gain::BlueGainMax() const
558{
559 float blueGainMax;
560
563 m_backendHandle, reinterpret_cast<float*>(&blueGainMax));
564 });
565
566 return blueGainMax;
567}
568inline bool Gain::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
569{
570 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
571
574 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
575 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
576 });
577
578 return isPixelFormatSupported > 0;
579}
580inline void Gain::ProcessInPlace(Image& image) const
581{
584 m_backendHandle, ImageBackendAccessor::BackendHandle(image));
585 });
586}
587inline Image Gain::Process(const Image& inputImage) const
588{
589 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
592 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
593 });
594
595 return ImageBackendAccessor::CreateImage(outputImageHandle);
596}
597
598} /* namespace ipl */
599} /* namespace peak */
Applies gain to the data.
Definition peak_ipl_gain.hpp:34
float GreenGainMin() const
Returns the minimum value of the green gain.
Definition peak_ipl_gain.hpp:506
float GreenGainValue() const
Returns the value of the green gain.
Definition peak_ipl_gain.hpp:495
~Gain()
Destructor for the Gain instance.
Definition peak_ipl_gain.hpp:352
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:580
float BlueGainValue() const
Returns the value of the blue gain.
Definition peak_ipl_gain.hpp:535
Image Process(const Image &inputImage) const
Applies the gain on the given image.
Definition peak_ipl_gain.hpp:587
float MasterGainMax() const
Returns the maximum value of the master gain.
Definition peak_ipl_gain.hpp:439
Gain & operator=(const Gain &other)
Copy assigment for Gain instance.
Definition peak_ipl_gain.hpp:375
float MasterGainValue() const
Returns the value of the master gain.
Definition peak_ipl_gain.hpp:417
void SetRedGainValue(float redGainValue)
Sets the values of the red Gain.
Definition peak_ipl_gain.hpp:450
float BlueGainMax() const
Returns the maximum value of the blue gain.
Definition peak_ipl_gain.hpp:557
void SetMasterGainValue(float masterGainValue)
Sets the values of the master Gain.
Definition peak_ipl_gain.hpp:410
float GreenGainMax() const
Returns the maximum value of the green gain.
Definition peak_ipl_gain.hpp:517
float RedGainMin() const
Returns the minimum value of the red gain.
Definition peak_ipl_gain.hpp:468
float BlueGainMin() const
Returns the minimum value of the blue gain.
Definition peak_ipl_gain.hpp:546
float MasterGainMin() const
Returns the minimum value of the master gain.
Definition peak_ipl_gain.hpp:428
void SetGreenGainValue(float greenGainValue)
Sets the values of the green Gain.
Definition peak_ipl_gain.hpp:488
void SetBlueGainValue(float blueGainValue)
Sets the values of the blue Gain.
Definition peak_ipl_gain.hpp:528
float RedGainValue() const
Returns the value of the red gain.
Definition peak_ipl_gain.hpp:457
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gain supports the given pixel format.
Definition peak_ipl_gain.hpp:568
float RedGainMax() const
Returns the maximum value of the red gain.
Definition peak_ipl_gain.hpp:478
Gain()
Constructor for a new Gain instance.
Definition peak_ipl_gain.hpp:341
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:42
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:38
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
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:394
struct PEAK_IPL_IMAGE * PEAK_IPL_IMAGE_HANDLE
Definition peak_ipl_backend.h:402
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:23
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:170
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:11