mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Renamed ColorTransform to RgbChannelTransform
Former-commit-id: 390b832ba2d463710d4a063692f00b83a8c6c8ad
This commit is contained in:
parent
f5f1019f72
commit
c8ce23e652
@ -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;
|
||||
|
@ -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;
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "LinearColorSmoothing.h"
|
||||
|
||||
#include <utils/ColorTransform.h>
|
||||
#include <utils/RgbChannelTransform.h>
|
||||
#include <utils/HsvTransform.h>
|
||||
|
||||
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<ColorRgb>& 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:
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <hyperion/ImageToLedsMap.h>
|
||||
#include <hyperion/BlackBorderProcessor.h>
|
||||
|
||||
#include <utils/ColorTransform.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
ImageProcessor::ImageProcessor(const LedString& ledString, bool enableBlackBorderDetector) :
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,10 @@
|
||||
// STL includes
|
||||
#include <cmath>
|
||||
|
||||
#include <utils/ColorTransform.h>
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelTransform.h>
|
||||
|
||||
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)
|
@ -2,13 +2,14 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#include <utils/ColorTransform.h>
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelTransform.h>
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user