C / C ++ library for calculating color difference (delta E) and color space conversion
4 answers
Try http://github.com/dmilos/color
Sample code:
typedef ::color::rgb<double> color_t; // or lab or hsv or any other available model
color_t a = ::color::constant::orange_t{};
color_t b = ::color::constant::chocolate_t{};
std::cout << ::color::operation::distance< ::color::constant::distance::CIE94_textile_entity >( a, b ) << std::endl;
std::cout << ::color::operation::distance< ::color::constant::distance::CIEDE2000_entity >( a, b ) << std::endl;
More examples with other algorithms: https://github.com/dmilos/color/tree/master/example/less-than-1k/operation/distance
The color model doesn't matter. It will be automatically converted internally.
All formulas are documented at: http://en.wikipedia.org/wiki/Color_difference
0
source to share
I wrote this library for personal use:
https://github.com/ThunderStruct/Color-Utilities
Both header and cpp files are less than 5kb, so this might be useful if you don't want to clutter your project with a larger library
Here's an example:
// Colors' construction
ColorUtils::rgbColor c1(1.0, 1.0, 1.0), c2(0.5, 0.5, 0.5);
// Calculate Delta-E using CIE76
std::cout << ColorUtils::getColorDeltaE(c1, c2) << '\n';
This outputs 46.8072
(you can check the results using this converter)
0
source to share