2013-08-05 23:49:17 +02:00
|
|
|
#pragma once
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
// STL includes
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace hyperion
|
|
|
|
{
|
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:
|
2013-08-13 11:10:45 +02:00
|
|
|
ColorTransform();
|
|
|
|
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel);
|
|
|
|
~ColorTransform();
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
double getThreshold() const;
|
|
|
|
void setThreshold(double threshold);
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
double getGamma() const;
|
|
|
|
void setGamma(double gamma);
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
double getBlacklevel() const;
|
|
|
|
void setBlacklevel(double blacklevel);
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
double getWhitelevel() const;
|
|
|
|
void setWhitelevel(double whitelevel);
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +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:
|
2013-08-13 11:10:45 +02:00
|
|
|
void initializeMapping();
|
2013-08-05 23:49:17 +02:00
|
|
|
|
|
|
|
private:
|
2013-08-13 11:10:45 +02:00
|
|
|
double _threshold;
|
|
|
|
double _gamma;
|
|
|
|
double _blacklevel;
|
|
|
|
double _whitelevel;
|
2013-08-05 23:49:17 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
uint8_t _mapping[256];
|
2013-08-05 23:49:17 +02:00
|
|
|
};
|
2013-08-13 11:10:45 +02:00
|
|
|
|
|
|
|
} // end namespace hyperion
|