hyperion.ng/include/utils/ColorTransform.h

51 lines
1.2 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 ColorTransform
{
public:
ColorTransform();
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel);
~ColorTransform();
2013-08-05 23:49:17 +02:00
double getThreshold() const;
void setThreshold(double threshold);
2013-08-05 23:49:17 +02:00
double getGamma() const;
void setGamma(double gamma);
2013-08-05 23:49:17 +02:00
double getBlacklevel() const;
void setBlacklevel(double blacklevel);
2013-08-05 23:49:17 +02:00
double getWhitelevel() const;
void setWhitelevel(double whitelevel);
2013-08-05 23:49:17 +02:00
/// get the transformed value for the given byte value
uint8_t transform(uint8_t input) const
{
return _mapping[input];
}
2013-08-05 23:49:17 +02:00
private:
void initializeMapping();
2013-08-05 23:49:17 +02:00
private:
double _threshold;
double _gamma;
double _blacklevel;
double _whitelevel;
2013-08-05 23:49:17 +02:00
uint8_t _mapping[256];
2013-08-05 23:49:17 +02:00
};