for i1=5:1:15
for j1=5:1:20
sum1=0;
sum1=int8(img1gray(i1,j1))
for k1=1:1:4
printf("\n%d",int8(img1gray(i1,j1-k1)));
printf("\n%d",img1gray(i1,j1+k1));
printf("\n%d",img1gray(i1-k1,j1));
printf("\n%d\n",img1gray(i1+k1,j1));sum1
a=int8(img1gray(i1,j1-k1));
b=int8(img1gray(i1,j1+k1));
c=int8(img1gray(i1-k1,j1));
d=int8(img1gray(i1+k1,j1));
#sum1=sum1+int8(img1gray(i1,j1-k1))+int8(img1gray(i1,j1+k1))+int8(img1gray(i1-k1,j1))+int8(img1gray(i1+k1,j1))
sum1=sum1+a+b+c+d
endfor
printf("\nSum for img1gray(%d,%d):%d",i1,j1,sum1)
avg1=0;
avg1=sum1/17;
printf("\nAverage for img1gray(%d,%d)=%d",i1,j1,avg1)
for i2=5:1:15
for j2=5:1:20
sum2=0;
sum2=img2gray(i2,j2);
for k2=1:1:4
sum2=sum2+img2gray(i2,j2-k2)+img2gray(i2,j2+k2)+img2gray(i2-k2,j2)+img2gray(i2+k2,j2);
endfor
printf("\nSum for img2gray(%d,%d):%d",i2,j2,sum2)
avg2=0;
avg2=sum2/17;
printf("\nAverage for img1gray(%d,%d)=%d",i2,j2,avg2)
#sub=avg2-avg1;
#printf("\nSubtarcting result for average of img2gray(%d,%d) and average of img1gray(%d,%d):sub",i2,j2,i1,j1,sub)
#if sub <15 & sub > 0 || sub > -15 & sub < 0
#printf("\nimg1gray(%d,%d) is in comparision to img2gray(%d,%d)",i1,j1,i2,j2);
#else
#printf("\nnot matched\n");
#endif
endfor
endfor
endfor
endfor