ACF $AcfVersion:0$
List of all members
icmm::IColorTransformation Class Reference

Basic interface for color transformations between color models. More...

#include <IColorTransformation.h>

Inheritance diagram for icmm::IColorTransformation:
imath::TIMathFunction< icmm::CVarColor, icmm::CVarColor > istd::IPolymorphic icmm::CCmykToRgbTransformation icmm::CHsvToRgbTransformation icmm::CRgbToCmykTransformation icmm::CRgbToHsvTranformation icmm::CRgbToXyzTransformation icmm::CXyzToCieLabTransformation icmm::TColorGradient< GradientFunction > icmm::TComposedColorGradient< Gradient >

Additional Inherited Members

- Public Types inherited from imath::TIMathFunction< icmm::CVarColor, icmm::CVarColor >
typedef icmm::CVarColor ArgumentType
 
typedef icmm::CVarColor ResultType
 
- Public Member Functions inherited from imath::TIMathFunction< icmm::CVarColor, icmm::CVarColor >
virtual bool GetValueAt (const icmm::CVarColor &argument, icmm::CVarColor &result) const=0
 Get function value for specified argument value.
 
virtual icmm::CVarColor GetValueAt (const icmm::CVarColor &argument) const=0
 Get function value for specified argument value.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Detailed Description

Basic interface for color transformations between color models.

Purpose

IColorTransformation defines a mathematical function that converts colors from one color model to another. It extends TIMathFunction to provide color-specific transformation capabilities, taking a CVarColor as input and producing a CVarColor as output.

Transformation Types

Common color transformations include:

Usage Examples

// Example 1: Basic color transformation
void ConvertRgbToHsv(const icmm::CRgb& rgb)
{
// Get source and target models
icmm::CHsvColorModel hsvModel;
// Create transformation
const IColorTransformation* transform =
rgbModel.CreateColorTranformation(hsvModel);
if (transform) {
// Convert RGB to CVarColor
icmm::CVarColor rgbColor(3);
rgbColor.SetElement(0, rgb.GetRed());
rgbColor.SetElement(1, rgb.GetGreen());
rgbColor.SetElement(2, rgb.GetBlue());
// Apply transformation
icmm::CVarColor hsvColor;
if (transform->Calculate(rgbColor, hsvColor)) {
// Extract HSV components
double hue = hsvColor.GetElement(0);
double saturation = hsvColor.GetElement(1);
double value = hsvColor.GetElement(2);
qDebug() << "H:" << hue
<< "S:" << saturation
<< "V:" << value;
}
delete transform;
}
}
// Example 2: Batch color conversion
void ConvertColorPalette(const QList<icmm::CVarColor>& sourceColors,
{
// Create transformation once
const IColorTransformation* transform =
sourceModel->CreateColorTranformation(*targetModel);
if (!transform) {
qWarning() << "No transformation available";
return;
}
// Convert all colors using same transformation
QList<icmm::CVarColor> results;
for (const icmm::CVarColor& color : sourceColors) {
if (transform->Calculate(color, result)) {
results.append(result);
}
}
delete transform;
// Process converted colors
ProcessColors(results);
}
// Example 3: Color space conversion chain
icmm::CVarColor ConvertRgbToLab(const icmm::CVarColor& rgb)
{
// RGB -> XYZ -> Lab (common conversion path)
icmm::CXyzColorModel xyzModel; // Hypothetical
// First: RGB to XYZ
const IColorTransformation* rgbToXyz =
rgbModel.CreateColorTranformation(xyzModel);
if (rgbToXyz && rgbToXyz->Calculate(rgb, xyz)) {
delete rgbToXyz;
// Second: XYZ to Lab
const IColorTransformation* xyzToLab =
xyzModel.CreateColorTranformation(labModel);
if (xyzToLab && xyzToLab->Calculate(xyz, lab)) {
delete xyzToLab;
return lab;
}
delete xyzToLab;
} else {
delete rgbToXyz;
}
return icmm::CVarColor(); // Return empty on failure
}
// Example 4: Transformation with error handling
bool TransformColor(const icmm::CVarColor& input,
icmm::CVarColor& output,
const IColorTransformation* transform)
{
if (!transform) {
qWarning() << "Null transformation";
return false;
}
if (!transform->Calculate(input, output)) {
qWarning() << "Transformation failed";
return false;
}
// Validate output
int components = output.GetElementsCount();
if (components == 0) {
qWarning() << "Invalid output color";
return false;
}
return true;
}
CCieLabColorModel implements the CIE Lab color model.
Concrete RGB color model implementation.
virtual const icmm::IColorTransformation * CreateColorTranformation(const IColorModel &otherColorModel, const QByteArray &transformationId) const override
Creates a color transformation for conversion to another color model.
Primitive for representation of RGB color values.
Definition CRgb.h:168
double GetBlue() const
Definition CRgb.h:256
double GetGreen() const
Definition CRgb.h:244
double GetRed() const
Definition CRgb.h:232
Generic color implementation with variable number of color components.
Definition CVarColor.h:176
Basic interface for color transformations between color models.
double GetElement(int index) const
Get element at specified index.
Definition CVarVector.h:409
int GetElementsCount() const
Get number of elements.
Definition CVarVector.h:387
std::shared_ptr< const IColorModel > ConstColorModelPtr

Performance Considerations

Accuracy Considerations

See also
icmm::IColorModel, icmm::CVarColor, imath::TIMathFunction, icmm::CRgbToHsvTranformation, icmm::CRgbToCmykTransformation

Definition at line 174 of file IColorTransformation.h.


The documentation for this class was generated from the following file: