Created
December 4, 2020 10:08
-
-
Save syaffers/2c8fe35c532d8ee388ed35492f1dff4d to your computer and use it in GitHub Desktop.
Color distance c++ code from compuphase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct { | |
unsigned char r, g, b; | |
} RGB; | |
double ColourDistance(RGB e1, RGB e2) | |
{ | |
long rmean = ( (long)e1.r + (long)e2.r ) / 2; | |
long r = (long)e1.r - (long)e2.r; | |
long g = (long)e1.g - (long)e2.g; | |
long b = (long)e1.b - (long)e2.b; | |
return sqrt((((512+rmean)*r*r)>>8) + 4*g*g + (((767-rmean)*b*b)>>8)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment