diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-04-12 15:42:04 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-04-12 15:42:04 +0000 |
commit | 4f9f95a05a41bfbcc9965eaaf7f2d14c6af9f261 (patch) | |
tree | c5d3d649d36e6102708d0f86edb87499e1ff8c3e /libdimension/color.c | |
parent | 510c9a95fb5f3f4a40a19ce66c95344c2013085f (diff) | |
download | dimension-4f9f95a05a41bfbcc9965eaaf7f2d14c6af9f261.tar.xz |
Write C++ libdimension-png wrapper.
Diffstat (limited to 'libdimension/color.c')
-rw-r--r-- | libdimension/color.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libdimension/color.c b/libdimension/color.c index 4caf53b..e2a4df9 100644 --- a/libdimension/color.c +++ b/libdimension/color.c @@ -19,7 +19,7 @@ *************************************************************************/ #include "dimension.h" -#include <math.h> /* For pow() */ +#include <math.h> /* For pow(), sqrt() */ /* sRGB white point (D50) */ const dmnsn_CIE_XYZ dmnsn_whitepoint = { .X = 0.9504060171449392, @@ -253,3 +253,17 @@ dmnsn_color_add(dmnsn_color color1, dmnsn_color color2) return ret; } + +double +dmnsn_color_difference(dmnsn_color color1, dmnsn_color color2) +{ + dmnsn_CIE_Lab Lab, Lab1, Lab2; + dmnsn_color ret; + + Lab1 = dmnsn_Lab_from_color(color1, dmnsn_whitepoint); + Lab2 = dmnsn_Lab_from_color(color2, dmnsn_whitepoint); + + return sqrt((Lab1.L - Lab2.L)*(Lab1.L - Lab2.L) + + (Lab1.a - Lab2.a)*(Lab1.a - Lab2.a) + + (Lab1.b - Lab2.b)*(Lab1.b - Lab2.b)); +} |