13 int main(int argc, char ** argv)
15 SDL_Surface * orig = SDL_LoadBMP(argv[1]);
16 SDL_Surface * diff = SDL_LoadBMP(argv[2]);
18 assert(orig->w == diff->w && orig->h == diff->h);
22 uint8_t * a = (uint8_t*)orig->pixels;
23 uint8_t * b = (uint8_t*)diff->pixels;
30 for (int x = 0; x < w; ++x)
32 for (int y = 0; y < h; ++y)
34 if (a[4*(x + w*y)] == 0)
36 if (b[4*(x + w*y)] == 0)
39 if (a[4*(x + w*y)] != b[4*(x + w*y)] && b[4*(x+w*y)] == 0)
45 for (r=1; r+x < w; ++r)
47 if (a[4*(x+r + w*y)] == 0)
51 for (l=1; x-l >= 0; ++l)
53 if (a[4*(x-l + w*y)] == 0)
57 for (u=1; y-u >= 0; ++u)
59 if (a[4*(x + w*(y-u))] == 0)
64 for (d=1; y+d < h; ++d)
66 if (a[4*(x + w*(y+d))] == 0)
70 mean_dist += min(min(d,u), min(r,l));
74 printf("%d\t%d\t%d\t%lf\n", count_a, count_b, total_diff, (double)mean_dist / (double)count_b);