qualpal 3.3.0
Loading...
Searching...
No Matches
qualpal Namespace Reference

Qualitative color palette generation library. More...

Namespaces

namespace  colors
 Color representation classes for various color spaces.
 
namespace  metrics
 Color difference metrics for perceptual color comparison.
 

Classes

class  FixedMatrix
 Fixed-size matrix class with compile-time dimensions. More...
 
class  Matrix
 Dynamic matrix class with runtime-determined dimensions. More...
 
struct  PaletteAnalysis
 Holds analysis results for a color palette under a specific vision condition. More...
 
class  Qualpal
 Builder for qualitative color palette generation. More...
 
class  Threads
 Centralized management of thread settings for parallel computations. More...
 

Typedefs

using PaletteAnalysisMap = std::map< std::string, PaletteAnalysis >
 Map from vision deficiency type to palette analysis results.
 

Enumerations

enum class  ColorspaceType { HSL , LCHab }
 Supported cylindrical color spaces for input colors. More...
 

Functions

PaletteAnalysisMap analyzePalette (const std::vector< colors::RGB > &colors, const metrics::MetricType &metric=metrics::MetricType::CIEDE2000, const std::map< std::string, double > &cvd={ { "deutan", 1.0 }, { "protan", 1.0 }, { "tritan", 1.0 } }, const std::optional< colors::RGB > &bg=std::nullopt, double max_memory=1.0)
 Analyze a color palette for normal and simulated color vision deficiencies (CVD).
 
template<typename ColorType , typename Metric = metrics::DIN99d>
Matrix< double > colorDifferenceMatrix (const std::vector< ColorType > &colors, const Metric &metric=Metric{}, const double max_memory=1)
 Generate a symmetric color difference matrix for a set of colors.
 
Matrix< double > colorDifferenceMatrix (const std::vector< colors::XYZ > &colors, const metrics::MetricType &metric_type, const double max_memory=1)
 Generate a color difference matrix for XYZ colors with runtime metric selection.
 

Detailed Description

Qualitative color palette generation library.

Typedef Documentation

◆ PaletteAnalysisMap

using qualpal::PaletteAnalysisMap = typedef std::map<std::string, PaletteAnalysis>

Map from vision deficiency type to palette analysis results.

The key is a string representing the vision type:

  • "normal" : Normal color vision (no simulation)
  • "deutan" : Deuteranomaly simulation
  • "protan" : Protanomaly simulation
  • "tritan" : Tritanomaly simulation

The value is a PaletteAnalysis struct with results for that vision type.

Definition at line 59 of file analyze.h.

Enumeration Type Documentation

◆ ColorspaceType

enum class qualpal::ColorspaceType
strong

Supported cylindrical color spaces for input colors.

This enum defines the available cylindrical color spaces that can be used for generating palettes. Currently, it supports HSL (Hue, Saturation, Lightness) and LCHab (Lightness, Chroma, Hue in CIE Lab).

Definition at line 63 of file qualpal.h.

Function Documentation

◆ analyzePalette()

PaletteAnalysisMap qualpal::analyzePalette ( const std::vector< colors::RGB > &  colors,
const metrics::MetricType metric = metrics::MetricType::CIEDE2000,
const std::map< std::string, double > &  cvd = { { "deutan", 1.0 }, { "protan", 1.0 }, { "tritan", 1.0 } },
const std::optional< colors::RGB > &  bg = std::nullopt,
double  max_memory = 1.0 
)

Analyze a color palette for normal and simulated color vision deficiencies (CVD).

Computes color difference matrices and minimum color distances for the input palette, for normal vision as well as common color vision deficiencies ("deutan", "protan", "tritan") at the specified severity. Results are returned as a map keyed by vision type.

For each vision type:

  • Simulates the palette (and optional background) under the specified CVD severity.
  • Computes the pairwise color difference matrix using the selected metric.
  • Computes the minimum distance to any other color for each palette color.
  • Computes the minimum distance from the background (if provided) to the palette.
Parameters
colorsVector of RGB colors to analyze. Each channel should be in [0, 1].
metricColor difference metric to use (e.g., CIEDE2000, DIN99d, CIE76).
cvdMap of CVD type ("deutan", "protan", "tritan") to severity [0, 1]. If a type is omitted or severity is 0, simulation is skipped for that type.
bgOptional background color to include in the analysis (RGB in [0, 1]).
max_memoryMaximum memory (in GB) allowed for the difference matrix computation.
Returns
Map from vision type string to PaletteAnalysis for each simulated vision.
Exceptions
std::invalid_argumentif input parameters are invalid.
See also
PaletteAnalysis, PaletteAnalysisMap

◆ colorDifferenceMatrix() [1/2]

Matrix< double > qualpal::colorDifferenceMatrix ( const std::vector< colors::XYZ > &  colors,
const metrics::MetricType metric_type,
const double  max_memory = 1 
)

Generate a color difference matrix for XYZ colors with runtime metric selection.

Computes the pairwise color differences between all colors in the input vector, using the specified color difference metric (selected at runtime via MetricType). Internally converts XYZ colors to the appropriate color space for the selected metric.

Parameters
colorsVector of colors::XYZ colors to compare.
metric_typeColor difference metric to use (DIN99d, CIEDE2000, or CIE76).
max_memoryMaximum memory (in GB) allowed for the matrix (default: 1.0).
Returns
Matrix<double> Symmetric matrix of pairwise color differences [size: n x n].
Exceptions
std::invalid_argumentif the metric type is unsupported or input is invalid.
std::runtime_errorif the estimated matrix size exceeds max_memory.
See also
metrics::MetricType

◆ colorDifferenceMatrix() [2/2]

template<typename ColorType , typename Metric = metrics::DIN99d>
Matrix< double > qualpal::colorDifferenceMatrix ( const std::vector< ColorType > &  colors,
const Metric &  metric = Metric{},
const double  max_memory = 1 
)

Generate a symmetric color difference matrix for a set of colors.

Computes the pairwise perceptual color differences between all colors in the input vector, using the specified color difference metric (e.g., DIN99d, CIEDE2000, CIE76). The result is a symmetric matrix where element (i, j) is the distance between colors[i] and colors[j].

Template Parameters
ColorTypeAny color class convertible to the required color space (e.g., colors::RGB, colors::HSL, colors::XYZ, colors::Lab, colors::DIN99d).
MetricColor difference metric functor (defaults to metrics::DIN99d).
Parameters
colorsVector of colors to compare.
metricColor difference metric to use (optional; default is DIN99d).
max_memoryMaximum memory (in GB) allowed for the matrix (default: 1.0).
Returns
Matrix<double> Symmetric matrix of pairwise color differences [size: n x n].
Exceptions
std::invalid_argumentif fewer than one color is provided.
std::runtime_errorif the estimated matrix size exceeds max_memory.
See also
metrics::DIN99d, metrics::CIEDE2000, metrics::CIE76

Definition at line 65 of file color_difference.h.