/* L1_match.c */ #include #include #include"mypgm.h" void copy_image1_image2() { int x, y; x_size2 = x_size1; y_size2 = y_size1; printf("Now, the first image is stored.\n\n"); for ( y = 0; y < y_size2; y ++ ) for ( x = 0; x < x_size2; x ++ ) image2[y][x] = image1[y][x]; } void L1_match( ) /* Input: image1[y][x]&image2[y][x] ---- Output: L1 matching score for two gray-scale images */ { int x, y, value; double sum, L1_score; printf("Now, L1 matching is performed\n\n"); sum = 0.0; for ( y = 0; y < y_size2; y ++ ) for ( x = 0; x < x_size2; x ++ ){ value = image1[y][x] - image2[y][x]; value = value < 0 ? -value : value; sum += value; } L1_score = sum / (x_size2*y_size2); printf("L1 matching score is %.3f\n\n", L1_score); } main( ) { load_image_data( ); /* Input of first image */ copy_image1_image2(); /* Storing image1 into image2 */ load_image_data( ); /* Input of second image */ L1_match( ); /* L1 matching of two images */ return 0; }