
load tDun1
% edge detection
[gx,gy]=gradient(tDuncan1); 
gx=abs(gx); gy=abs(gy);
gtd1=gx+gy;
gtd1=abs(gtd1);
% make it 200x200
z=zeros(200);
s=size(gtd1);
z(1:s(1),1:s(2))=gtd1;
gtd1=z;
%figure; imagesc(gtd1); title('gtd1')
% take the dct and fft
ftd1=abs(fft2(gtd1));
figure; imagesc(ftd1); title('ftd1'); grid on
ctd1=abs(dct2(gtd1));
figure; imagesc((ctd1)); title('ctd1'); grid on

load rDun1
% edge detection
[gx,gy]=gradient(rDuncan1); 
gx=abs(gx); gy=abs(gy);
grd1=gx+gy;
grd1=abs(grd1);
% make it 200x200
z=zeros(200);
s=size(grd1);
z(1:s(1),1:s(2))=grd1;
grd1=z;
%figure; imagesc(grd1); title('grd1')
% take the dct and fft
frd1=abs(fft2(grd1));
figure; imagesc(frd1); title('frd1'); grid on
crd1=abs(dct2(grd1));
figure; imagesc((crd1)); title('crd1'); grid on

load tDun2
% edge detection
[gx,gy]=gradient(tDuncan2); 
gx=abs(gx); gy=abs(gy);
gtd2=gx+gy;
gtd2=abs(gtd2);
% make it 200x200
z=zeros(200);
s=size(gtd2);
z(1:s(1),1:s(2))=gtd2;
gtd2=z;
%figure; imagesc(gtd2); title('gtd2')
% take the dct and fft
ftd2=abs(fft2(gtd2));
figure; imagesc(ftd2); title('ftd2'); grid on
ctd2=abs(dct2(gtd2));
figure; imagesc((ctd2)); title('ctd2'); grid on

load rDun2
% edge detection
[gx,gy]=gradient(rDuncan2); 
gx=abs(gx); gy=abs(gy);
grd2=gx+gy;
grd2=abs(grd2);
% make it 200x200
z=zeros(200);
s=size(grd2);
z(1:s(1),1:s(2))=grd2;
grd2=z;
%figure; imagesc(grd2); title('grd2')
% take the dct and fft
frd2=abs(fft2(grd2));
figure; imagesc(frd2); title('frd2'); grid on
crd2=abs(dct2(grd2));
figure; imagesc((crd2)); title('crd2'); grid on

load tDun3
% edge detection
[gx,gy]=gradient(tDuncan3); 
gx=abs(gx); gy=abs(gy);
gtd3=gx+gy;
gtd3=abs(gtd3);
% make it 200x200
z=zeros(200);
s=size(gtd3);
z(1:s(1),1:s(2))=gtd3;
gtd3=z;
%figure; imagesc(gtd3); title('gtd3')
% take the dct and fft
ftd3=abs(fft2(gtd3));
figure; imagesc(ftd3); title('ftd3'); grid on
ctd3=abs(dct2(gtd3));
figure; imagesc((ctd3)); title('ctd3'); grid on

load rDun3
% edge detection
[gx,gy]=gradient(rDuncan3); 
gx=abs(gx); gy=abs(gy);
grd3=gx+gy;
grd3=abs(grd3);
% make it 200x200
z=zeros(200);
s=size(grd3);
z(1:s(1),1:s(2))=grd3;
grd3=z;
%figure; imagesc(grd3); title('grd3')
% take the dct and fft
frd3=abs(fft2(grd3));
figure; imagesc(frd3); title('frd3'); grid on
crd3=abs(dct2(grd3));
figure; imagesc((crd3)); title('crd3'); grid on


% nomalize
m1=max(max(ctd2)); ct2=ctd2./m1*100;
m2=max(max(crd2)); cr2=crd2./m2*100;
m3=max(max(ctd1)); ct1=ctd1./m3*100;
m4=max(max(crd1)); cr1=crd1./m4*100;
m5=max(max(ctd3)); ct3=ctd3./m5*100;
m6=max(max(crd3)); cr3=crd3./m6*100;


% get rid of the top part
size_ct2=size(ct2);
ct2(1:round(.05*size_ct2(1)),1:round(.05*size_ct2(2))) = 0;
size_cr2=size(cr2);
cr2(1:round(.05*size_cr2(1)),1:round(.05*size_cr2(2))) = 0;
size_ct1=size(ct1);
ct1(1:round(.05*size_ct1(1)),1:round(.05*size_ct1(2))) = 0;
size_cr1=size(cr1);
cr1(1:round(.05*size_cr1(1)),1:round(.05*size_cr1(2))) = 0;
size_ct3=size(ct3);
ct3(1:round(.05*size_ct3(1)),1:round(.05*size_ct3(2))) = 0;
size_cr3=size(cr3);
cr3(1:round(.05*size_cr3(1)),1:round(.05*size_cr3(2))) = 0;


p_ct2=length( find(ct2>20) )
p_ct1=length( find(ct1>20) )
p_ct3=length( find(ct3>20) )
p_cr2=length( find(cr2>20) )
p_cr1=length( find(cr1>20) )
p_cr3=length( find(cr3>20) )
