/* max_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 max_match( ) /* Input: image1[y][x]&image2[y][x] ---- Output: maximum difference of gray levels */ { int x, y, value, max; int xm, ym; printf("Now, detection of maximum difference is performed\n\n"); max = 0; xm = 0; ym = 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; if( max < value ) { max = value; xm = x; ym = y; } } printf("Maximum value of difference is %d at (%d, %d)\n\n", max, xm, ym); } main( ) { load_image_data( ); /* Input of first image */ copy_image1_image2(); /* Storing image1 into image2 */ load_image_data( ); /* Input of second image */ max_match( ); /* Maximum difference of two images */ return 0; }