ソースです。
コンパイラは・・・GCC on Cygwin?かな?バージョンはちょっとわかりません。怒られて3つになってしまいました

#include<stdio.h>
#include<string.h>
#include<math.h>

#define X_SIZE 512
#define Y_SIZE 512

main(){
int i,j,m,n,p,q,rsc,rsr,dsc,dsr,mp,mq,RN,DN;
double min,dif;
unsigned char pic[X_SIZE][Y_SIZE];
char fnamein[100],fnameout[100];
FILE *fin,*fout;

RN=4; DN=2; //レンジとドメインの分割数

rsc=X_SIZE/RN; rsr=Y_SIZE/RN; dsc=X_SIZE/DN; dsr=Y_SIZE/DN;

int fr[RN][RN], fc[RN][RN]; //各レンジに対し、どのドメインを持ってくるか