IDS peak IPL v1.17.1
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
28
29namespace peak
30{
31namespace ipl
32{
33
38class Gain final
39{
40public:
47 Gain();
48
55 ~Gain();
56
68 Gain(const Gain& other);
69
81 Gain& operator=(const Gain& other);
82
91 Gain(Gain&& other) noexcept;
92
101 Gain& operator=(Gain&& other) noexcept;
102
112 void SetMasterGainValue(float masterGainValue);
113
122
131
140
150 void SetRedGainValue(float redGainValue);
151
159 PEAK_IPL_NO_DISCARD float RedGainValue() const;
160
168 PEAK_IPL_NO_DISCARD float RedGainMin() const;
169
177 PEAK_IPL_NO_DISCARD float RedGainMax() const;
178
188 void SetGreenGainValue(float greenGainValue);
189
198
206 PEAK_IPL_NO_DISCARD float GreenGainMin() const;
207
215 PEAK_IPL_NO_DISCARD float GreenGainMax() const;
216
226 void SetBlueGainValue(float blueGainValue);
227
236
244 PEAK_IPL_NO_DISCARD float BlueGainMin() const;
245
253 PEAK_IPL_NO_DISCARD float BlueGainMax() const;
254
265
279 void ProcessInPlace(Image& image) const;
280
295 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
296
297private:
298 friend GainBackendAccessor;
299 explicit Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept;
300 PEAK_IPL_GAIN_HANDLE m_backendHandle{};
301};
302
303} /* namespace ipl */
304} /* namespace peak */
305
306namespace
307{
308
310class GainBackendAccessor
311{
312public:
320 static PEAK_IPL_GAIN_HANDLE BackendHandle(const peak::ipl::Gain& gain)
321 {
322 return gain.m_backendHandle;
323 }
324
334 static peak::ipl::Gain CreateGain(PEAK_IPL_GAIN_HANDLE gainHandle)
335 {
336 return peak::ipl::Gain(gainHandle);
337 }
338};
339
340} /* namespace */
341
342namespace peak
343{
344namespace ipl
345{
347{
349}
350
351inline Gain::Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept
352 : m_backendHandle{ gainHandle }
353{
355}
356
358{
359 if (m_backendHandle)
360 {
361 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
362 }
363}
364
365inline Gain::Gain(Gain&& other) noexcept
366{
367 *this = std::move(other);
368}
369
370inline Gain::Gain(const Gain& other)
371{
372 if (other.m_backendHandle)
373 {
374 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
375 }
376
377 m_backendHandle = other.m_backendHandle;
378}
379
380inline Gain& Gain::operator=(const Gain& other)
381{
382 if (this != &other)
383 {
384 if (m_backendHandle)
385 {
386 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
387 }
388
389 if (other.m_backendHandle)
390 {
391 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
392 }
393 }
394
395 m_backendHandle = other.m_backendHandle;
396
397 return *this;
398}
399
400inline Gain& Gain::operator=(Gain&& other) noexcept
401{
402 if (this != &other)
403 {
404 if (m_backendHandle != nullptr)
405 {
406 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
407 }
408
409 m_backendHandle = other.m_backendHandle;
410 other.m_backendHandle = nullptr;
411 }
412
413 return *this;
414}
415inline void Gain::SetMasterGainValue(float masterGainValue)
416{
419 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
420 });
421}
422inline float Gain::MasterGainValue() const
423{
424 float masterGainValue;
425
428 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
429 });
430
431 return masterGainValue;
432}
433inline float Gain::MasterGainMin() const
434{
435 float masterGainMin;
436
439 m_backendHandle, reinterpret_cast<float*>(&masterGainMin));
440 });
441
442 return masterGainMin;
443}
444inline float Gain::MasterGainMax() const
445{
446 float masterGainMax;
447
450 m_backendHandle, reinterpret_cast<float*>(&masterGainMax));
451 });
452
453 return masterGainMax;
454}
455inline void Gain::SetRedGainValue(float redGainValue)
456{
459 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
460 });
461}
462inline float Gain::RedGainValue() const
463{
464 float redGainValue;
465
468 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
469 });
470
471 return redGainValue;
472}
473inline float Gain::RedGainMin() const
474{
475 float redGainMin;
476
478 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMin(m_backendHandle, reinterpret_cast<float*>(&redGainMin));
479 });
480
481 return redGainMin;
482}
483inline float Gain::RedGainMax() const
484{
485 float redGainMax;
486
488 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMax(m_backendHandle, reinterpret_cast<float*>(&redGainMax));
489 });
490
491 return redGainMax;
492}
493inline void Gain::SetGreenGainValue(float greenGainValue)
494{
497 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
498 });
499}
500inline float Gain::GreenGainValue() const
501{
502 float greenGainValue;
503
506 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
507 });
508
509 return greenGainValue;
510}
511inline float Gain::GreenGainMin() const
512{
513 float greenGainMin;
514
517 m_backendHandle, reinterpret_cast<float*>(&greenGainMin));
518 });
519
520 return greenGainMin;
521}
522inline float Gain::GreenGainMax() const
523{
524 float greenGainMax;
525
528 m_backendHandle, reinterpret_cast<float*>(&greenGainMax));
529 });
530
531 return greenGainMax;
532}
533inline void Gain::SetBlueGainValue(float blueGainValue)
534{
537 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
538 });
539}
540inline float Gain::BlueGainValue() const
541{
542 float blueGainValue;
543
546 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
547 });
548
549 return blueGainValue;
550}
551inline float Gain::BlueGainMin() const
552{
553 float blueGainMin;
554
557 m_backendHandle, reinterpret_cast<float*>(&blueGainMin));
558 });
559
560 return blueGainMin;
561}
562inline float Gain::BlueGainMax() const
563{
564 float blueGainMax;
565
568 m_backendHandle, reinterpret_cast<float*>(&blueGainMax));
569 });
570
571 return blueGainMax;
572}
573inline bool Gain::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
574{
575 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
576
579 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
580 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
581 });
582
583 return isPixelFormatSupported > 0;
584}
585inline void Gain::ProcessInPlace(Image& image) const
586{
589 m_backendHandle, ImageBackendAccessor::BackendHandle(image));
590 });
591}
592inline Image Gain::Process(const Image& inputImage) const
593{
594 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
597 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
598 });
599
600 return ImageBackendAccessor::CreateImage(outputImageHandle);
601}
602
603} /* namespace ipl */
604} /* namespace peak */
Applies gain to the data.
Definition peak_ipl_gain.hpp:39
float GreenGainMin() const
Returns the minimum value of the green gain.
Definition peak_ipl_gain.hpp:511
float GreenGainValue() const
Returns the value of the green gain.
Definition peak_ipl_gain.hpp:500
~Gain()
Destructor for the Gain instance.
Definition peak_ipl_gain.hpp:357
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:585
float BlueGainValue() const
Returns the value of the blue gain.
Definition peak_ipl_gain.hpp:540
Image Process(const Image &inputImage) const
Applies the gain on the given image.
Definition peak_ipl_gain.hpp:592
float MasterGainMax() const
Returns the maximum value of the master gain.
Definition peak_ipl_gain.hpp:444
Gain & operator=(const Gain &other)
Copy assigment for Gain instance.
Definition peak_ipl_gain.hpp:380
float MasterGainValue() const
Returns the value of the master gain.
Definition peak_ipl_gain.hpp:422
void SetRedGainValue(float redGainValue)
Sets the values of the red Gain.
Definition peak_ipl_gain.hpp:455
float BlueGainMax() const
Returns the maximum value of the blue gain.
Definition peak_ipl_gain.hpp:562
void SetMasterGainValue(float masterGainValue)
Sets the values of the master Gain.
Definition peak_ipl_gain.hpp:415
float GreenGainMax() const
Returns the maximum value of the green gain.
Definition peak_ipl_gain.hpp:522
float RedGainMin() const
Returns the minimum value of the red gain.
Definition peak_ipl_gain.hpp:473
float BlueGainMin() const
Returns the minimum value of the blue gain.
Definition peak_ipl_gain.hpp:551
float MasterGainMin() const
Returns the minimum value of the master gain.
Definition peak_ipl_gain.hpp:433
void SetGreenGainValue(float greenGainValue)
Sets the values of the green Gain.
Definition peak_ipl_gain.hpp:493
void SetBlueGainValue(float blueGainValue)
Sets the values of the blue Gain.
Definition peak_ipl_gain.hpp:533
float RedGainValue() const
Returns the value of the red gain.
Definition peak_ipl_gain.hpp:462
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gain supports the given pixel format.
Definition peak_ipl_gain.hpp:573
float RedGainMax() const
Returns the maximum value of the red gain.
Definition peak_ipl_gain.hpp:483
Gain()
Constructor for a new Gain instance.
Definition peak_ipl_gain.hpp:346
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:47
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:43
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
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