17#include <peak_icv_c/algorithms/preprocessing/peak_icv_gain.h>
182 void SetRed(
float value)
override;
205 void SetGreen(
float value)
override;
228 void SetBlue(
float value)
override;
295 void Apply(peak_icv_gain_type type,
float value)
const;
299 static constexpr int moduleVersion = 1;
300 static constexpr auto masterGainKey =
"MasterGain";
301 static constexpr auto redGainKey =
"RedGain";
302 static constexpr auto greenGainKey =
"GreenGain";
303 static constexpr auto blueGainKey =
"BlueGain";
305 peak_icv_gain_handle m_handle{};
306 bool m_enabled{
true };
312 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_Create(&m_handle);
318 if (m_handle !=
nullptr)
320 std::ignore = PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_Destroy(m_handle);
326 m_handle = std::exchange(other.m_handle,
nullptr);
327 m_enabled = other.m_enabled;
334 if (m_handle !=
nullptr)
337 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_Destroy(m_handle);
341 m_handle = std::exchange(other.m_handle,
nullptr);
342 m_enabled = other.m_enabled;
360 archive.
SetInt(
"Version", moduleVersion);
363 archive.
SetDouble(masterGainKey, Fetch(PEAK_ICV_GAIN_TYPE_MASTER));
364 archive.
SetDouble(redGainKey, Fetch(PEAK_ICV_GAIN_TYPE_RED));
365 archive.
SetDouble(greenGainKey, Fetch(PEAK_ICV_GAIN_TYPE_GREEN));
366 archive.
SetDouble(blueGainKey, Fetch(PEAK_ICV_GAIN_TYPE_BLUE));
371 const auto version = archive.
GetInt(
"Version");
376 Apply(PEAK_ICV_GAIN_TYPE_MASTER,
static_cast<float>(archive.
GetDouble(masterGainKey)));
378 Apply(PEAK_ICV_GAIN_TYPE_RED,
static_cast<float>(archive.
GetDouble(redGainKey)));
379 Apply(PEAK_ICV_GAIN_TYPE_GREEN,
static_cast<float>(archive.
GetDouble(greenGainKey)));
380 Apply(PEAK_ICV_GAIN_TYPE_BLUE,
static_cast<float>(archive.
GetDouble(blueGainKey)));
390 Apply(PEAK_ICV_GAIN_TYPE_MASTER, 1.0F);
392 Apply(PEAK_ICV_GAIN_TYPE_RED, 1.0F);
393 Apply(PEAK_ICV_GAIN_TYPE_GREEN, 1.0F);
394 Apply(PEAK_ICV_GAIN_TYPE_BLUE, 1.0F);
399 Apply(PEAK_ICV_GAIN_TYPE_MASTER, value);
404 return Fetch(PEAK_ICV_GAIN_TYPE_MASTER);
409 Apply(PEAK_ICV_GAIN_TYPE_RED, value);
414 return Fetch(PEAK_ICV_GAIN_TYPE_RED);
419 Apply(PEAK_ICV_GAIN_TYPE_GREEN, value);
424 return Fetch(PEAK_ICV_GAIN_TYPE_GREEN);
429 Apply(PEAK_ICV_GAIN_TYPE_BLUE, value);
434 return Fetch(PEAK_ICV_GAIN_TYPE_BLUE);
439 peak_common_interval_f cRange{};
441 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_GetRange(m_handle, &cRange);
444 return { cRange.minimum, cRange.maximum };
454 auto needsProcessing = [&] {
457 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_NeedsProcessing(m_handle, &value);
468 auto*
const inputImageHandle = peak::common::detail::BackendAccessor<peak::icv::Image>::BackendHandle(inputImage);
471 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_ProcessInplace(m_handle, inputImageHandle);
477inline void GainModule::Apply(peak_icv_gain_type type,
const float value)
const
480 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_SetValue(m_handle, type, value);
484inline float GainModule::Fetch(peak_icv_gain_type type)
const
488 return PEAK_ICV_C_ABI_PREFIX peak_icv_Preprocessing_Gain_GetValue(m_handle, type, &value);
A type-erased container for any copyable value.
T & AnyCast()
Casts the stored value to the specified type.
Represents a continuous numeric interval with inclusive lower and upper bounds.
Interface for a hierarchical key-value archive system.
virtual void SetBool(const std::string &key, bool value)=0
Stores a boolean value.
virtual double GetDouble(const std::string &key) const =0
Retrieves a double-precision number by key.
virtual void SetInt(const std::string &key, int64_t value)=0
Stores a 64-bit signed integer.
virtual int64_t GetInt(const std::string &key) const =0
Retrieves a 64-bit signed integer by key.
virtual bool GetBool(const std::string &key) const =0
Retrieves a boolean value by key.
virtual void SetDouble(const std::string &key, double value)=0
Stores a double-precision floating point number.
For detailed information about the use of ids_peak_icv Image refer to the Image Guide.
Image pipeline module for applying gain to the image.
float GetGreen() const override
Returns the current green gain.
const char * GetType() const override
Returns the type of the module for serialization purposes.
peak::common::IntervalF GetRange() const
Returns the valid range for the master or color gains.
void SetBlue(float value) override
Sets the blue gain value.
float GetMaster() const override
Returns the current master gain.
void SetGreen(float value) override
Sets the green gain value.
GainModule()
Creates an instance of class GainModule with default values.
GainModule(const GainModule &other)=delete
Copy constructor for class GainModule is deleted.
void SetRed(float value) override
Sets the red gain value.
float GetBlue() const override
Returns the current blue gain.
float GetRed() const override
Returns the current red gain.
void Serialize(peak::common::serialization::IArchive &archive) const override
Serializes the object's internal state into the provided archive.
peak::icv::Image Process(const peak::icv::Image &input) const
Applies the gains to the input image in place and returns a reference to the modified image.
void SetEnabled(bool enabled) override
Sets the enabled state of this module.
void SetMaster(float value) override
Sets the master gain value.
void Deserialize(const peak::common::serialization::IArchive &archive) override
Restores the object's state from the provided archive.
GainModule & operator=(const GainModule &other)=delete
Copy assignment for class GainModule is deleted.
void ResetToDefault() override
Resets the gain values to their defaults.
bool IsEnabled() const override
Checks if the module is currently enabled.
Interface for modules that provide gain control functionality.
#define PEAK_COMMON_NO_DISCARD
Compatability macro for the nodiscard attribute.
void ExecuteAndMapReturnCodes(const CallableType &callableObject)
void ValidateVersion(int64_t version, const std::string &moduleName)