| 36 | // using YIQ NTSC transmission color space in mobile applications" by Y. Kotsarenko and F. Ramos |
| 37 | |
| 38 | double colorDelta(const U8* img1, const U8* img2, U32 k, U32 m, bool yOnly = false) { |
| 39 | double a1 = 1.0; |
| 40 | double a2 = 1.0; |
| 41 | |
| 42 | U8 r1 = blend(img1[k + 0], a1); |
| 43 | U8 g1 = blend(img1[k + 1], a1); |
| 44 | U8 b1 = blend(img1[k + 2], a1); |
| 45 | |
| 46 | U8 r2 = blend(img2[m + 0], a2); |
| 47 | U8 g2 = blend(img2[m + 1], a2); |
| 48 | U8 b2 = blend(img2[m + 2], a2); |
| 49 | |
| 50 | double y = rgb2y(r1, g1, b1) - rgb2y(r2, g2, b2); |
| 51 | |
| 52 | if (yOnly) return y; // brightness difference only |
| 53 | |
| 54 | double i = rgb2i(r1, g1, b1) - rgb2i(r2, g2, b2); |
| 55 | double q = rgb2q(r1, g1, b1) - rgb2q(r2, g2, b2); |
| 56 | |
| 57 | return 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q; |
| 58 | } |
| 59 | |
| 60 | void drawPixel(U8* output, U32 pos, U8 r, U8 g, U8 b) { |
| 61 | output[pos + 0] = r; |
no test coverage detected