用于计算色差(delta E)和色彩空间转换的C / C ++库

我用谷歌搜索但没有找到任何东西。 我正在为python使用colormath库,但它相当慢。

我在Javascript中为此编写了代码。 转换为C非常容易!

请参阅deltaE2000() ,它采用LCHab中的颜色,也许还有转换RGB的function – >线性RGB – > XYZ-> Lab – > LCHab。 代码和UI演示 。

OpenCV可能会这样做。

试试http://github.com/dmilos/color

代码示例:

 typedef ::color::rgb 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; 

其他algorithams的其他例子: https : //github.com/dmilos/color/tree/master/example/less-than-1k/operation/distance

颜色模型无关紧要。 它将在内部自动转换。

所有公式都记录在: http : //en.wikipedia.org/wiki/Color_difference

我写这个图书馆供个人使用:

https://github.com/ThunderStruct/Color-Utilities

标头和cpp文件都小于5kb,因此如果您不希望使用更大的库混乱您的项目,这可能很有用

这是一个示例:

 // 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'; 

输出46.8072 (您可以使用此转换器validation结果)