IDS peak IPL v1.17.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
28
29namespace peak
30{
31namespace ipl
32{
33
37class Gain final
38{
39public:
46 Gain();
47
54 ~Gain();
55
67 Gain(const Gain& other);
68
80 Gain& operator=(const Gain& other);
81
90 Gain(Gain&& other) noexcept;
91
100 Gain& operator=(Gain&& other) noexcept;
101
111 void SetMasterGainValue(float masterGainValue);
112
121
130
139
149 void SetRedGainValue(float redGainValue);
150
158 PEAK_IPL_NO_DISCARD float RedGainValue() const;
159
167 PEAK_IPL_NO_DISCARD float RedGainMin() const;
168
176 PEAK_IPL_NO_DISCARD float RedGainMax() const;
177
187 void SetGreenGainValue(float greenGainValue);
188
197
205 PEAK_IPL_NO_DISCARD float GreenGainMin() const;
206
214 PEAK_IPL_NO_DISCARD float GreenGainMax() const;
215
225 void SetBlueGainValue(float blueGainValue);
226
235
243 PEAK_IPL_NO_DISCARD float BlueGainMin() const;
244
252 PEAK_IPL_NO_DISCARD float BlueGainMax() const;
253
264
278 void ProcessInPlace(Image& image) const;
279
294 PEAK_IPL_NO_DISCARD Image Process(const Image& inputImage) const;
295
296private:
297 friend GainBackendAccessor;
298 explicit Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept;
299 PEAK_IPL_GAIN_HANDLE m_backendHandle{};
300};
301
302} /* namespace ipl */
303} /* namespace peak */
304
305namespace
306{
307
309class GainBackendAccessor
310{
311public:
319 static PEAK_IPL_GAIN_HANDLE BackendHandle(const peak::ipl::Gain& gain)
320 {
321 return gain.m_backendHandle;
322 }
323
333 static peak::ipl::Gain CreateGain(PEAK_IPL_GAIN_HANDLE gainHandle)
334 {
335 return peak::ipl::Gain(gainHandle);
336 }
337};
338
339} /* namespace */
340
341namespace peak
342{
343namespace ipl
344{
346{
348}
349
350inline Gain::Gain(PEAK_IPL_GAIN_HANDLE gainHandle) noexcept
351 : m_backendHandle{ gainHandle }
352{
354}
355
357{
358 if (m_backendHandle)
359 {
360 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
361 }
362}
363
364inline Gain::Gain(Gain&& other) noexcept
365{
366 *this = std::move(other);
367}
368
369inline Gain::Gain(const Gain& other)
370{
371 if (other.m_backendHandle)
372 {
373 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
374 }
375
376 m_backendHandle = other.m_backendHandle;
377}
378
379inline Gain& Gain::operator=(const Gain& other)
380{
381 if (this != &other)
382 {
383 if (m_backendHandle)
384 {
385 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
386 }
387
388 if (other.m_backendHandle)
389 {
390 ExecuteAndMapReturnCodes([&] { return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Acquire(other.m_backendHandle); });
391 }
392 }
393
394 m_backendHandle = other.m_backendHandle;
395
396 return *this;
397}
398
399inline Gain& Gain::operator=(Gain&& other) noexcept
400{
401 if (this != &other)
402 {
403 if (m_backendHandle != nullptr)
404 {
405 (void)PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_Destruct(m_backendHandle);
406 }
407
408 m_backendHandle = other.m_backendHandle;
409 other.m_backendHandle = nullptr;
410 }
411
412 return *this;
413}
414inline void Gain::SetMasterGainValue(float masterGainValue)
415{
418 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
419 });
420}
421inline float Gain::MasterGainValue() const
422{
423 float masterGainValue;
424
427 m_backendHandle, reinterpret_cast<float*>(&masterGainValue));
428 });
429
430 return masterGainValue;
431}
432inline float Gain::MasterGainMin() const
433{
434 float masterGainMin;
435
438 m_backendHandle, reinterpret_cast<float*>(&masterGainMin));
439 });
440
441 return masterGainMin;
442}
443inline float Gain::MasterGainMax() const
444{
445 float masterGainMax;
446
449 m_backendHandle, reinterpret_cast<float*>(&masterGainMax));
450 });
451
452 return masterGainMax;
453}
454inline void Gain::SetRedGainValue(float redGainValue)
455{
458 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
459 });
460}
461inline float Gain::RedGainValue() const
462{
463 float redGainValue;
464
467 m_backendHandle, reinterpret_cast<float*>(&redGainValue));
468 });
469
470 return redGainValue;
471}
472inline float Gain::RedGainMin() const
473{
474 float redGainMin;
475
477 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMin(m_backendHandle, reinterpret_cast<float*>(&redGainMin));
478 });
479
480 return redGainMin;
481}
482inline float Gain::RedGainMax() const
483{
484 float redGainMax;
485
487 return PEAK_IPL_C_ABI_PREFIX PEAK_IPL_Gain_GetRedGainMax(m_backendHandle, reinterpret_cast<float*>(&redGainMax));
488 });
489
490 return redGainMax;
491}
492inline void Gain::SetGreenGainValue(float greenGainValue)
493{
496 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
497 });
498}
499inline float Gain::GreenGainValue() const
500{
501 float greenGainValue;
502
505 m_backendHandle, reinterpret_cast<float*>(&greenGainValue));
506 });
507
508 return greenGainValue;
509}
510inline float Gain::GreenGainMin() const
511{
512 float greenGainMin;
513
516 m_backendHandle, reinterpret_cast<float*>(&greenGainMin));
517 });
518
519 return greenGainMin;
520}
521inline float Gain::GreenGainMax() const
522{
523 float greenGainMax;
524
527 m_backendHandle, reinterpret_cast<float*>(&greenGainMax));
528 });
529
530 return greenGainMax;
531}
532inline void Gain::SetBlueGainValue(float blueGainValue)
533{
536 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
537 });
538}
539inline float Gain::BlueGainValue() const
540{
541 float blueGainValue;
542
545 m_backendHandle, reinterpret_cast<float*>(&blueGainValue));
546 });
547
548 return blueGainValue;
549}
550inline float Gain::BlueGainMin() const
551{
552 float blueGainMin;
553
556 m_backendHandle, reinterpret_cast<float*>(&blueGainMin));
557 });
558
559 return blueGainMin;
560}
561inline float Gain::BlueGainMax() const
562{
563 float blueGainMax;
564
567 m_backendHandle, reinterpret_cast<float*>(&blueGainMax));
568 });
569
570 return blueGainMax;
571}
572inline bool Gain::IsPixelFormatSupported(PixelFormatName pixelFormatName) const
573{
574 PEAK_IPL_BOOL8 isPixelFormatSupported = 0;
575
578 static_cast<PEAK_IPL_PIXEL_FORMAT>(pixelFormatName),
579 reinterpret_cast<PEAK_IPL_BOOL8*>(&isPixelFormatSupported));
580 });
581
582 return isPixelFormatSupported > 0;
583}
584inline void Gain::ProcessInPlace(Image& image) const
585{
588 m_backendHandle, ImageBackendAccessor::BackendHandle(image));
589 });
590}
591inline Image Gain::Process(const Image& inputImage) const
592{
593 PEAK_IPL_IMAGE_HANDLE outputImageHandle = nullptr;
596 m_backendHandle, ImageBackendAccessor::BackendHandle(inputImage), &outputImageHandle);
597 });
598
599 return ImageBackendAccessor::CreateImage(outputImageHandle);
600}
601
602} /* namespace ipl */
603} /* namespace peak */
Applies gain to the data.
Definition peak_ipl_gain.hpp:38
float GreenGainMin() const
Returns the minimum value of the green gain.
Definition peak_ipl_gain.hpp:510
float GreenGainValue() const
Returns the value of the green gain.
Definition peak_ipl_gain.hpp:499
~Gain()
Destructor for the Gain instance.
Definition peak_ipl_gain.hpp:356
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:584
float BlueGainValue() const
Returns the value of the blue gain.
Definition peak_ipl_gain.hpp:539
Image Process(const Image &inputImage) const
Applies the gain on the given image.
Definition peak_ipl_gain.hpp:591
float MasterGainMax() const
Returns the maximum value of the master gain.
Definition peak_ipl_gain.hpp:443
Gain & operator=(const Gain &other)
Copy assigment for Gain instance.
Definition peak_ipl_gain.hpp:379
float MasterGainValue() const
Returns the value of the master gain.
Definition peak_ipl_gain.hpp:421
void SetRedGainValue(float redGainValue)
Sets the values of the red Gain.
Definition peak_ipl_gain.hpp:454
float BlueGainMax() const
Returns the maximum value of the blue gain.
Definition peak_ipl_gain.hpp:561
void SetMasterGainValue(float masterGainValue)
Sets the values of the master Gain.
Definition peak_ipl_gain.hpp:414
float GreenGainMax() const
Returns the maximum value of the green gain.
Definition peak_ipl_gain.hpp:521
float RedGainMin() const
Returns the minimum value of the red gain.
Definition peak_ipl_gain.hpp:472
float BlueGainMin() const
Returns the minimum value of the blue gain.
Definition peak_ipl_gain.hpp:550
float MasterGainMin() const
Returns the minimum value of the master gain.
Definition peak_ipl_gain.hpp:432
void SetGreenGainValue(float greenGainValue)
Sets the values of the green Gain.
Definition peak_ipl_gain.hpp:492
void SetBlueGainValue(float blueGainValue)
Sets the values of the blue Gain.
Definition peak_ipl_gain.hpp:532
float RedGainValue() const
Returns the value of the red gain.
Definition peak_ipl_gain.hpp:461
bool IsPixelFormatSupported(PixelFormatName pixelFormatName) const
Returns whether the gain supports the given pixel format.
Definition peak_ipl_gain.hpp:572
float RedGainMax() const
Returns the maximum value of the red gain.
Definition peak_ipl_gain.hpp:482
Gain()
Constructor for a new Gain instance.
Definition peak_ipl_gain.hpp:345
Stores the pixel format, width and height of an image and the pointer to the image buffer.
Definition peak_ipl_image.hpp:46
The "peak::ipl" namespace contains the whole image processing library.
PixelFormatName
Enum holding the possible pixel format names.
Definition peak_ipl_simple_types.hpp:41
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
Definition peak_ipl_exception.hpp:271
#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