Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Return gamma-corrected value of a color component byte*/
- float GCRGB(byte component) {
- static float GCRGBTable[256] = {0.0f};
- static int loaded = 0;
- if(!loaded) {
- int i;
- for(i = 0; i < 256; ++i) {
- GCRGBTable[i] = pow(i/255.0f, 2.2f);
- }
- loaded = 1;
- }
- return GCRGBTable[component];
- }
- float difference(Color c1, Color c2) {
- float r, g, b;
- r = GCRGB(c1.r) - GCRGB(c2.r);
- g = GCRGB(c1.g) - GCRGB(c2.g);
- b = GCRGB(c1.b) - GCRGB(c2.b);
- return r*r + g*g + b*b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement