Renamed ColorTransform to RgbChannelTransform

Former-commit-id: 390b832ba2d463710d4a063692f00b83a8c6c8ad
This commit is contained in:
T. van der Zwan 2013-11-19 20:17:59 +00:00
parent f5f1019f72
commit c8ce23e652
7 changed files with 41 additions and 41 deletions

View File

@ -17,7 +17,7 @@
// Forward class declaration // Forward class declaration
class HsvTransform; class HsvTransform;
class ColorTransform; class RgbChannelTransform;
/// ///
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through /// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
@ -145,7 +145,7 @@ public:
static ColorOrder createColorOrder(const Json::Value & deviceConfig); static ColorOrder createColorOrder(const Json::Value & deviceConfig);
static LedString createLedString(const Json::Value & ledsConfig); static LedString createLedString(const Json::Value & ledsConfig);
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig); static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
static ColorTransform * createColorTransform(const Json::Value & colorConfig); static RgbChannelTransform * createColorTransform(const Json::Value & colorConfig);
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice); static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
private slots: private slots:
@ -173,11 +173,11 @@ private:
/// The HSV Transform for applying Saturation and Value transforms /// The HSV Transform for applying Saturation and Value transforms
HsvTransform * _hsvTransform; HsvTransform * _hsvTransform;
/// The RED-Channel (RGB) transform /// The RED-Channel (RGB) transform
ColorTransform * _redTransform; RgbChannelTransform * _redTransform;
/// The GREEN-Channel (RGB) transform /// The GREEN-Channel (RGB) transform
ColorTransform * _greenTransform; RgbChannelTransform * _greenTransform;
/// The BLUE-Channel (RGB) transform /// The BLUE-Channel (RGB) transform
ColorTransform * _blueTransform; RgbChannelTransform * _blueTransform;
/// Value with the desired color byte order /// Value with the desired color byte order
ColorOrder _colorOrder; ColorOrder _colorOrder;

View File

@ -12,21 +12,21 @@
/// 4) finally, in case of a weird choice of parameters, the output is clamped between [0:1] /// 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 /// All configuration values are doubles and assume the color value to be between 0 and 1
class ColorTransform class RgbChannelTransform
{ {
public: public:
/// Default constructor /// Default constructor
ColorTransform(); RgbChannelTransform();
/// Constructor /// Constructor
/// @param threshold /// @param threshold The minimum threshold
/// @param gamma /// @param gamma The gamma of the gamma-curve correction
/// @param blacklevel /// @param blacklevel The minimum value for the RGB-Channel
/// @param whitelevel /// @param whitelevel The maximum value for the RGB-Channel
ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel); RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel);
/// Destructor /// Destructor
~ColorTransform(); ~RgbChannelTransform();
/// @return The current threshold value /// @return The current threshold value
double getThreshold() const; double getThreshold() const;

View File

@ -24,7 +24,7 @@
#include "LinearColorSmoothing.h" #include "LinearColorSmoothing.h"
#include <utils/ColorTransform.h> #include <utils/RgbChannelTransform.h>
#include <utils/HsvTransform.h> #include <utils/HsvTransform.h>
LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig) LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig)
@ -163,14 +163,14 @@ HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
return new HsvTransform(saturationGain, valueGain); return new HsvTransform(saturationGain, valueGain);
} }
ColorTransform* Hyperion::createColorTransform(const Json::Value& colorConfig) RgbChannelTransform* Hyperion::createColorTransform(const Json::Value& colorConfig)
{ {
const double threshold = colorConfig.get("threshold", 0.0).asDouble(); const double threshold = colorConfig.get("threshold", 0.0).asDouble();
const double gamma = colorConfig.get("gamma", 1.0).asDouble(); const double gamma = colorConfig.get("gamma", 1.0).asDouble();
const double blacklevel = colorConfig.get("blacklevel", 0.0).asDouble(); const double blacklevel = colorConfig.get("blacklevel", 0.0).asDouble();
const double whitelevel = colorConfig.get("whitelevel", 1.0).asDouble(); const double whitelevel = colorConfig.get("whitelevel", 1.0).asDouble();
ColorTransform* transform = new ColorTransform(threshold, gamma, blacklevel, whitelevel); RgbChannelTransform* transform = new RgbChannelTransform(threshold, gamma, blacklevel, whitelevel);
return transform; return transform;
} }
@ -322,7 +322,7 @@ void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, c
void Hyperion::setTransform(Hyperion::Transform transform, Hyperion::Color color, double value) void Hyperion::setTransform(Hyperion::Transform transform, Hyperion::Color color, double value)
{ {
// select the transform of the requested color // select the transform of the requested color
ColorTransform * t = nullptr; RgbChannelTransform * t = nullptr;
switch (color) switch (color)
{ {
case RED: case RED:
@ -396,7 +396,7 @@ void Hyperion::clearall()
double Hyperion::getTransform(Hyperion::Transform transform, Hyperion::Color color) const double Hyperion::getTransform(Hyperion::Transform transform, Hyperion::Color color) const
{ {
// select the transform of the requested color // select the transform of the requested color
ColorTransform * t = nullptr; RgbChannelTransform * t = nullptr;
switch (color) switch (color)
{ {
case RED: case RED:

View File

@ -4,8 +4,6 @@
#include <hyperion/ImageToLedsMap.h> #include <hyperion/ImageToLedsMap.h>
#include <hyperion/BlackBorderProcessor.h> #include <hyperion/BlackBorderProcessor.h>
#include <utils/ColorTransform.h>
using namespace hyperion; using namespace hyperion;
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) : ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) :

View File

@ -11,11 +11,11 @@ add_library(hyperion-utils
${CURRENT_HEADER_DIR}/ColorRgba.h ${CURRENT_HEADER_DIR}/ColorRgba.h
${CURRENT_SOURCE_DIR}/ColorRgba.cpp ${CURRENT_SOURCE_DIR}/ColorRgba.cpp
${CURRENT_HEADER_DIR}/Image.h ${CURRENT_HEADER_DIR}/Image.h
${CURRENT_HEADER_DIR}/ColorTransform.h
${CURRENT_HEADER_DIR}/HsvTransform.h
${CURRENT_SOURCE_DIR}/ColorTransform.cpp ${CURRENT_HEADER_DIR}/HsvTransform.h
${CURRENT_SOURCE_DIR}/HsvTransform.cpp ${CURRENT_SOURCE_DIR}/HsvTransform.cpp
${CURRENT_HEADER_DIR}/RgbChannelTransform.h
${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp
${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h ${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h
${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h ${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h

View File

@ -1,9 +1,10 @@
// STL includes // STL includes
#include <cmath> #include <cmath>
#include <utils/ColorTransform.h> // Utils includes
#include <utils/RgbChannelTransform.h>
ColorTransform::ColorTransform() : RgbChannelTransform::RgbChannelTransform() :
_threshold(0), _threshold(0),
_gamma(1.0), _gamma(1.0),
_blacklevel(0.0), _blacklevel(0.0),
@ -12,7 +13,7 @@ ColorTransform::ColorTransform() :
initializeMapping(); initializeMapping();
} }
ColorTransform::ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel) : RgbChannelTransform::RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel) :
_threshold(threshold), _threshold(threshold),
_gamma(gamma), _gamma(gamma),
_blacklevel(blacklevel), _blacklevel(blacklevel),
@ -21,55 +22,55 @@ ColorTransform::ColorTransform(double threshold, double gamma, double blacklevel
initializeMapping(); initializeMapping();
} }
ColorTransform::~ColorTransform() RgbChannelTransform::~RgbChannelTransform()
{ {
} }
double ColorTransform::getThreshold() const double RgbChannelTransform::getThreshold() const
{ {
return _threshold; return _threshold;
} }
void ColorTransform::setThreshold(double threshold) void RgbChannelTransform::setThreshold(double threshold)
{ {
_threshold = threshold; _threshold = threshold;
initializeMapping(); initializeMapping();
} }
double ColorTransform::getGamma() const double RgbChannelTransform::getGamma() const
{ {
return _gamma; return _gamma;
} }
void ColorTransform::setGamma(double gamma) void RgbChannelTransform::setGamma(double gamma)
{ {
_gamma = gamma; _gamma = gamma;
initializeMapping(); initializeMapping();
} }
double ColorTransform::getBlacklevel() const double RgbChannelTransform::getBlacklevel() const
{ {
return _blacklevel; return _blacklevel;
} }
void ColorTransform::setBlacklevel(double blacklevel) void RgbChannelTransform::setBlacklevel(double blacklevel)
{ {
_blacklevel = blacklevel; _blacklevel = blacklevel;
initializeMapping(); initializeMapping();
} }
double ColorTransform::getWhitelevel() const double RgbChannelTransform::getWhitelevel() const
{ {
return _whitelevel; return _whitelevel;
} }
void ColorTransform::setWhitelevel(double whitelevel) void RgbChannelTransform::setWhitelevel(double whitelevel)
{ {
_whitelevel = whitelevel; _whitelevel = whitelevel;
initializeMapping(); initializeMapping();
} }
void ColorTransform::initializeMapping() void RgbChannelTransform::initializeMapping()
{ {
// initialize the mapping as a linear array // initialize the mapping as a linear array
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)

View File

@ -2,13 +2,14 @@
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
#include <utils/ColorTransform.h> // Utils includes
#include <utils/RgbChannelTransform.h>
int main() int main()
{ {
{ {
std::cout << "Testing linear transform" << std::endl; std::cout << "Testing linear transform" << std::endl;
ColorTransform t; RgbChannelTransform t;
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
uint8_t input = i; uint8_t input = i;
@ -29,7 +30,7 @@ int main()
{ {
std::cout << "Testing threshold" << std::endl; std::cout << "Testing threshold" << std::endl;
ColorTransform t(.10, 1.0, 0.0, 1.0); RgbChannelTransform t(.10, 1.0, 0.0, 1.0);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
uint8_t input = i; uint8_t input = i;
@ -50,7 +51,7 @@ int main()
{ {
std::cout << "Testing blacklevel and whitelevel" << std::endl; std::cout << "Testing blacklevel and whitelevel" << std::endl;
ColorTransform t(0, 1.0, 0.2, 0.8); RgbChannelTransform t(0, 1.0, 0.2, 0.8);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
uint8_t input = i; uint8_t input = i;
@ -71,7 +72,7 @@ int main()
{ {
std::cout << "Testing gamma" << std::endl; std::cout << "Testing gamma" << std::endl;
ColorTransform t(0, 2.0, 0.0, 1.0); RgbChannelTransform t(0, 2.0, 0.0, 1.0);
for (int i = 0; i < 256; ++i) for (int i = 0; i < 256; ++i)
{ {
uint8_t input = i; uint8_t input = i;