clc
clear

[file_name1,path_name1]=uigetfile('.bin','select the span image of the speckled data');
[file_name2,path_name2]=uigetfile('.bin','select the span image of the filtered data');
 config=textread(strcat(path_name1,'\config.txt'),'%s');y=str2num(config{2});x=str2num(config{5});

id1=fopen(strcat(path_name1,file_name1),'r');id2=fopen(strcat(path_name2,file_name2),'r');
I1=fread(id1,[x y],'float');I2=fread(id2,[x y],'float');
fclose('all');

I11=I1(1:x-1,1:y-1);I12=I1(2:x,2:y);
I21=I2(1:x-1,1:y-1);I22=I2(2:x,2:y);
   figure;imshow(I1./I2);
EPD_ROA=sum(sum(I21./I22))/sum(sum(I11./I12));
MOR=mean(mean(I1./I2));
title(strcat(  'EPD: ',num2str(EPD_ROA),'   MOR: ', num2str(MOR)   ));