C / C ++ library for calculating color difference (delta E) and color space conversion

I googled but couldn't find anything. I am using colormath library for python but it is quite slow.

+1


source to share


4 answers


I wrote the code for this in Javascript. It's very easy to translate to C!



See deltaE2000()

which takes colors in LCHab and possibly functions for converting RGB -> Linear RGB -> XYZ -> Lab -> LCHab. Code and UI demo .

+2


source


OpenCV will probably do.



+1


source


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


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







All Articles