~gerald-mwangi/+junk/ThesisMatlab

« back to all changes in this revision

Viewing changes to Matlab/ThesisCode/Visualization/OpticalFlow/curvatureToEPETV.m

  • Committer: gerald.mwangi at gmx
  • Date: 2016-10-14 11:46:28 UTC
  • Revision ID: gerald.mwangi@gmx.de-20161014114628-8h7jy6btvz0q2v5o
added curvature to epe plot 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function  curvatureToEPETV( dirname )
 
2
patchname='whale';
 
3
fname=strcat(dirname,'/frame-flowL1');
 
4
ufname=sprintf('%s_000000.txt',fname);%strcat(fname,'_000000.txt');
 
5
ugtname=strcat(fname,'-gt2_000000.txt');
 
6
vfname=sprintf('%s_000001.txt',fname);
 
7
vgtname=strcat(fname,'-gt2_000001.txt');
 
8
fname=strcat(dirname,'/frame-flowL1-','NEW');
 
9
u=csvread(ufname);
 
10
v=csvread(vfname);
 
11
 
 
12
ugt=csvread(ugtname);
 
13
vgt=csvread(vgtname);
 
14
 
 
15
image=double(imread(strcat(dirname,'frame07.png')));
 
16
 
 
17
epe=sqrt((u-ugt).^2+(v-vgt).^2);
 
18
 
 
19
[imx,imy]=gradient(image);
 
20
norm=sqrt(imx.^2+imy.^2)+0.001;
 
21
px=imx./norm;
 
22
py=imy./norm;
 
23
 
 
24
[pxx,d]=gradient(px);
 
25
[d,pyy]=gradient(py);
 
26
 
 
27
curv=pxx+pyy;
 
28
 
 
29
medepe=[];
 
30
medcurv=[];
 
31
 
 
32
wsize=100;
 
33
[w,h]=size(epe)
 
34
for y0=1:(h-wsize)
 
35
    for x0=1:(w-wsize)
 
36
       eperoi=epe(x0:(x0+wsize),y0:(y0+wsize)); 
 
37
       curvroi=curv(x0:(x0+wsize),y0:(y0+wsize));
 
38
       medepe=[medepe;median(median(eperoi))];
 
39
       medcurv=[medcurv;median(median(curvroi))];
 
40
    end
 
41
end
 
42
size(curv)
 
43
 
 
44
numcurvebin=20;
 
45
curvebinstep=(max(medcurv)-min(medcurv))/numcurvebin;
 
46
 
 
47
curvebins=(min(medcurv):curvebinstep:max(medcurv))';
 
48
min(medcurv)
 
49
max(medcurv)
 
50
 
 
51
barepe=[];
 
52
for i=1:(size(curvebins)-1)
 
53
    meanepeval=0;
 
54
    count=0;
 
55
    for j=1:size(medepe)
 
56
        if(medcurv(j)>=curvebins(i)&&medcurv(j)<curvebins(i+1))
 
57
            meanepeval=meanepeval+medepe(j);
 
58
            count=count+1;
 
59
        end
 
60
    end
 
61
    barepe=[barepe,meanepeval/count];
 
62
end
 
63
figure;
 
64
bar(curvebins,[barepe,0]);
 
65
curvebins
 
66
barepe
 
67
title('TV','Interpreter','Latex');
 
68
set(gca,'FontSize',30)
 
69
set( get( gca, 'Title' ), 'fontSize', 30 )
 
70
xlabel('$$\kappa$$','Interpreter','Latex','fontSize', 30)
 
71
ylabel('EPE','Interpreter','Latex','fontSize', 30)
 
72
axis([min(medcurv) max(medcurv) min(barepe) max(barepe)])
 
73
 
 
74
drawnow;
 
75
 
 
76
end
 
77