diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 5026ef08..ade46e24 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -17,7 +17,7 @@ // Forward class declaration class HsvTransform; -class ColorTransform; +class RgbChannelTransform; /// /// 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 LedString createLedString(const Json::Value & ledsConfig); 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); private slots: @@ -173,11 +173,11 @@ private: /// The HSV Transform for applying Saturation and Value transforms HsvTransform * _hsvTransform; /// The RED-Channel (RGB) transform - ColorTransform * _redTransform; + RgbChannelTransform * _redTransform; /// The GREEN-Channel (RGB) transform - ColorTransform * _greenTransform; + RgbChannelTransform * _greenTransform; /// The BLUE-Channel (RGB) transform - ColorTransform * _blueTransform; + RgbChannelTransform * _blueTransform; /// Value with the desired color byte order ColorOrder _colorOrder; diff --git a/include/utils/ColorTransform.h b/include/utils/RgbChannelTransform.h similarity index 81% rename from include/utils/ColorTransform.h rename to include/utils/RgbChannelTransform.h index c89b3916..7f524d81 100644 --- a/include/utils/ColorTransform.h +++ b/include/utils/RgbChannelTransform.h @@ -12,21 +12,21 @@ /// 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 +class RgbChannelTransform { public: /// Default constructor - ColorTransform(); + RgbChannelTransform(); /// Constructor - /// @param threshold - /// @param gamma - /// @param blacklevel - /// @param whitelevel - ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel); + /// @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); /// Destructor - ~ColorTransform(); + ~RgbChannelTransform(); /// @return The current threshold value double getThreshold() const; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index b7c71183..ce4bd9ab 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -24,7 +24,7 @@ #include "LinearColorSmoothing.h" -#include +#include #include LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig) @@ -163,14 +163,14 @@ HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig) 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 gamma = colorConfig.get("gamma", 1.0).asDouble(); const double blacklevel = colorConfig.get("blacklevel", 0.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; } @@ -322,7 +322,7 @@ void Hyperion::setColors(int priority, const std::vector& ledColors, c void Hyperion::setTransform(Hyperion::Transform transform, Hyperion::Color color, double value) { // select the transform of the requested color - ColorTransform * t = nullptr; + RgbChannelTransform * t = nullptr; switch (color) { case RED: @@ -396,7 +396,7 @@ void Hyperion::clearall() double Hyperion::getTransform(Hyperion::Transform transform, Hyperion::Color color) const { // select the transform of the requested color - ColorTransform * t = nullptr; + RgbChannelTransform * t = nullptr; switch (color) { case RED: diff --git a/libsrc/hyperion/ImageProcessor.cpp b/libsrc/hyperion/ImageProcessor.cpp index d3bfba3d..a0af2077 100644 --- a/libsrc/hyperion/ImageProcessor.cpp +++ b/libsrc/hyperion/ImageProcessor.cpp @@ -4,8 +4,6 @@ #include #include -#include - using namespace hyperion; ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) : diff --git a/libsrc/utils/CMakeLists.txt b/libsrc/utils/CMakeLists.txt index 18dfd98c..52094a61 100644 --- a/libsrc/utils/CMakeLists.txt +++ b/libsrc/utils/CMakeLists.txt @@ -11,11 +11,11 @@ add_library(hyperion-utils ${CURRENT_HEADER_DIR}/ColorRgba.h ${CURRENT_SOURCE_DIR}/ColorRgba.cpp ${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_HEADER_DIR}/RgbChannelTransform.h + ${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp ${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h ${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h diff --git a/libsrc/utils/ColorTransform.cpp b/libsrc/utils/RgbChannelTransform.cpp similarity index 60% rename from libsrc/utils/ColorTransform.cpp rename to libsrc/utils/RgbChannelTransform.cpp index abe7bded..bdd4ec1b 100644 --- a/libsrc/utils/ColorTransform.cpp +++ b/libsrc/utils/RgbChannelTransform.cpp @@ -1,9 +1,10 @@ // STL includes #include -#include +// Utils includes +#include -ColorTransform::ColorTransform() : +RgbChannelTransform::RgbChannelTransform() : _threshold(0), _gamma(1.0), _blacklevel(0.0), @@ -12,7 +13,7 @@ ColorTransform::ColorTransform() : initializeMapping(); } -ColorTransform::ColorTransform(double threshold, double gamma, double blacklevel, double whitelevel) : +RgbChannelTransform::RgbChannelTransform(double threshold, double gamma, double blacklevel, double whitelevel) : _threshold(threshold), _gamma(gamma), _blacklevel(blacklevel), @@ -21,55 +22,55 @@ ColorTransform::ColorTransform(double threshold, double gamma, double blacklevel initializeMapping(); } -ColorTransform::~ColorTransform() +RgbChannelTransform::~RgbChannelTransform() { } -double ColorTransform::getThreshold() const +double RgbChannelTransform::getThreshold() const { return _threshold; } -void ColorTransform::setThreshold(double threshold) +void RgbChannelTransform::setThreshold(double threshold) { _threshold = threshold; initializeMapping(); } -double ColorTransform::getGamma() const +double RgbChannelTransform::getGamma() const { return _gamma; } -void ColorTransform::setGamma(double gamma) +void RgbChannelTransform::setGamma(double gamma) { _gamma = gamma; initializeMapping(); } -double ColorTransform::getBlacklevel() const +double RgbChannelTransform::getBlacklevel() const { return _blacklevel; } -void ColorTransform::setBlacklevel(double blacklevel) +void RgbChannelTransform::setBlacklevel(double blacklevel) { _blacklevel = blacklevel; initializeMapping(); } -double ColorTransform::getWhitelevel() const +double RgbChannelTransform::getWhitelevel() const { return _whitelevel; } -void ColorTransform::setWhitelevel(double whitelevel) +void RgbChannelTransform::setWhitelevel(double whitelevel) { _whitelevel = whitelevel; initializeMapping(); } -void ColorTransform::initializeMapping() +void RgbChannelTransform::initializeMapping() { // initialize the mapping as a linear array for (int i = 0; i < 256; ++i) diff --git a/test/TestColorTransform.cpp b/test/TestColorTransform.cpp index b52c941c..21af454b 100644 --- a/test/TestColorTransform.cpp +++ b/test/TestColorTransform.cpp @@ -2,13 +2,14 @@ #include #include -#include +// Utils includes +#include int main() { { std::cout << "Testing linear transform" << std::endl; - ColorTransform t; + RgbChannelTransform t; for (int i = 0; i < 256; ++i) { uint8_t input = i; @@ -29,7 +30,7 @@ int main() { 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) { uint8_t input = i; @@ -50,7 +51,7 @@ int main() { 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) { uint8_t input = i; @@ -71,7 +72,7 @@ int main() { 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) { uint8_t input = i;