hyperion.ng/include/utils/RgbChannelTransform.h

80 lines
2.1 KiB
C
Raw Normal View History

2013-08-05 23:49:17 +02:00
#pragma once
// STL includes
#include <cstdint>
2013-08-05 23:49:17 +02:00
/// Transform for a single color byte value
///
/// Transforms are applied in the following order:
/// 1) a threshold is applied. All values below threshold will be set to zero
/// 2) gamma color correction is applied
/// 3) the output value is scaled from the [0:1] to [blacklevel:whitelevel]
/// 4) finally, in case of a weird choice of parameters, the output is clamped between [0:1]
///
/// All configuration values are doubles and assume the color value to be between 0 and 1
class RgbChannelTransform
2013-08-05 23:49:17 +02:00
{
public:
2013-09-09 04:54:13 +02:00
/// Default constructor
RgbChannelTransform();
2013-08-31 14:36:54 +02:00
2013-09-09 04:54:13 +02:00
/// Constructor
/// @param threshold The minimum threshold
/// @param gamma The gamma of the gamma-curve correction
/// @param blacklevel The minimum value for the RGB-Channel
/// @param whitelevel The maximum value for the RGB-Channel
RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel);
2013-08-31 14:36:54 +02:00
2013-09-09 04:54:13 +02:00
/// Destructor
~RgbChannelTransform();
2013-08-05 23:49:17 +02:00
2013-08-31 14:36:54 +02:00
/// @return The current threshold value
double getThreshold() const;
2013-08-31 14:36:54 +02:00
/// @param threshold New threshold value
void setThreshold(double threshold);
2013-08-05 23:49:17 +02:00
2013-08-31 14:36:54 +02:00
/// @return The current gamma value
double getGamma() const;
2013-08-31 14:36:54 +02:00
/// @param gamma New gamma value
void setGamma(double gamma);
2013-08-05 23:49:17 +02:00
2013-08-31 14:36:54 +02:00
/// @return The current blacklevel value
double getBlacklevel() const;
2013-08-31 14:36:54 +02:00
/// @param blacklevel New blacklevel value
void setBlacklevel(double blacklevel);
2013-08-05 23:49:17 +02:00
2013-08-31 14:36:54 +02:00
/// @return The current whitelevel value
double getWhitelevel() const;
2013-08-31 14:36:54 +02:00
/// @param whitelevel New whitelevel value
void setWhitelevel(double whitelevel);
2013-08-05 23:49:17 +02:00
2013-09-09 04:54:13 +02:00
/// Transform the given byte value
2013-08-31 14:36:54 +02:00
/// @param input The input color byte
/// @return The transformed byte value
uint8_t transform(uint8_t input) const
{
return _mapping[input];
}
2013-08-05 23:49:17 +02:00
private:
2013-09-09 04:54:13 +02:00
/// (re)-initilize the color mapping
void initializeMapping();
2013-08-05 23:49:17 +02:00
private:
2013-09-09 04:54:13 +02:00
/// The threshold value
double _threshold;
2013-09-09 04:54:13 +02:00
/// The gamma value
double _gamma;
2013-09-09 04:54:13 +02:00
/// The blacklevel
double _blacklevel;
2013-09-09 04:54:13 +02:00
/// The whitelevel
double _whitelevel;
2013-08-05 23:49:17 +02:00
2013-09-09 04:54:13 +02:00
/// The mapping from input color to output color
uint8_t _mapping[256];
2013-08-05 23:49:17 +02:00
};