diff options
Diffstat (limited to 'SD-VBS/benchmarks/stitch/src/matlab')
16 files changed, 0 insertions, 325 deletions
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m b/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m deleted file mode 100755 index caefd74..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/calculateH.m +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | function retH=calculateH(pnt1, pnt2) | ||
2 | |||
3 | [n temp]=size(pnt1); | ||
4 | |||
5 | X=zeros(0,8); | ||
6 | b=zeros(0,1); | ||
7 | |||
8 | for i=1:n | ||
9 | X=[X; pnt1(i,1) pnt1(i,2) 1 0 0 0 -pnt2(i,1)*pnt1(i,1) -pnt2(i,1)*pnt1(i,2);0, 0, 0, pnt1(i,1), pnt1(i,2), 1, -pnt2(i,2)*pnt1(i,1), -pnt2(i,2)*pnt1(i,2)]; | ||
10 | b=[b; pnt2(i,1); pnt2(i,2)]; | ||
11 | end | ||
12 | |||
13 | if n==4 | ||
14 | %if abs(det(X)~=0 | ||
15 | H=X^(-1)*b; | ||
16 | %else | ||
17 | % H=[0 0 0; 0 0 0; 0 0 1]; | ||
18 | %end | ||
19 | else | ||
20 | Xt = X'; | ||
21 | H=(Xt*X)^(-1)*Xt*b; | ||
22 | end | ||
23 | |||
24 | retH=[H(1) H(2) H(3);H(4) H(5) H(6);H(7) H(8) 1]; | ||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/dist2.m b/SD-VBS/benchmarks/stitch/src/matlab/dist2.m deleted file mode 100755 index 89116ac..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/dist2.m +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | function n2 = dist2(x, c) | ||
2 | %DIST2 Calculates squared distance between two sets of points. | ||
3 | % | ||
4 | % Description | ||
5 | % D = DIST2(X, C) takes two matrices of vectors and calculates the | ||
6 | % squared Euclidean distance between them. Both matrices must be of | ||
7 | % the same column dimension. If X has M rows and N columns, and C has | ||
8 | % L rows and N columns, then the result has M rows and L columns. The | ||
9 | % I, Jth entry is the squared distance from the Ith row of X to the | ||
10 | % Jth row of C. | ||
11 | % | ||
12 | % See also | ||
13 | % GMMACTIV, KMEANS, RBFFWD | ||
14 | % | ||
15 | |||
16 | % Copyright (c) Christopher M Bishop, Ian T Nabney (1996, 1997) | ||
17 | |||
18 | [ndata, dimx] = size(x); | ||
19 | [ncentres, dimc] = size(c); | ||
20 | if dimx ~= dimc | ||
21 | error('Data dimension does not match dimension of centres') | ||
22 | end | ||
23 | |||
24 | ct = c'; | ||
25 | opt = (x.^2)'; | ||
26 | op2t = (x.^2)'; | ||
27 | tempT = (ones(ncentres, 1) * sum(opt, 1))'; | ||
28 | n2 = tempT + ones(ndata, 1) * sum(op2t,1) - 2.*(x*ct); | ||
29 | |||
30 | |||
31 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m b/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m deleted file mode 100755 index 38d2f7c..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/extractFeatures.m +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | function vecF=extractFeatures(I, x, y, dataDir) | ||
2 | |||
3 | Igray = I; | ||
4 | w = (1/16)*[1 4 6 4 1]; | ||
5 | [n temp]=size(x); | ||
6 | |||
7 | %SUB sample rate s=5 | ||
8 | wt = w'; | ||
9 | Iconv=conv2(w, wt, Igray, 'same'); | ||
10 | Iconv=conv2(w, wt, Iconv, 'same'); | ||
11 | Isub=Iconv(1:5:end,1:5:end); | ||
12 | [nr nc]=size(Isub); | ||
13 | |||
14 | Xsub=min(floor(x/5)+1, nc-4); | ||
15 | Ysub=min(floor(y/5)+1, nr-4); | ||
16 | |||
17 | if(length(Xsub) < 6 || length(Ysub) < 10) | ||
18 | vecF = [Xsub Ysub]; | ||
19 | return; | ||
20 | end | ||
21 | |||
22 | newSize = 4; | ||
23 | [rows, cols] = size(I); | ||
24 | if(rows > 32 & cols >32) | ||
25 | newSize = 64; | ||
26 | end | ||
27 | |||
28 | for i=1:n | ||
29 | |||
30 | minValy = 3; | ||
31 | minValx = 3; | ||
32 | if( Ysub(i) < 4) | ||
33 | Ysub(i) = 4; | ||
34 | end | ||
35 | if( Xsub(i) < 4) | ||
36 | Xsub(i) = 4; | ||
37 | end | ||
38 | |||
39 | if( Ysub(i) > size(Isub,1)-4) | ||
40 | Ysub(i) = size(Isub,1)-4; | ||
41 | end | ||
42 | if( Xsub(i) > size(Isub,2)-4) | ||
43 | Xsub(i) = size(Isub,2)-4; | ||
44 | end | ||
45 | |||
46 | vecF(i,:)=reshape(Isub(Ysub(i)-minValy:Ysub(i)+4,Xsub(i)-minValx:Xsub(i)+4),1,newSize); | ||
47 | |||
48 | %normalization | ||
49 | vecF(i,:)=vecF(i,:)-mean(vecF(i,:)); | ||
50 | vecF(i,:)=vecF(i,:)/std(vecF(i,:)); | ||
51 | %imagesc(reshape(vecF(i,:),8,8)); colormap gray | ||
52 | %drawnow | ||
53 | %pause | ||
54 | end | ||
55 | |||
56 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m b/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m deleted file mode 100755 index caece31..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/getANMS.m +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | function [interestPnts]=getANMS(x, y, v, r, dataDir) | ||
2 | %interestPnts=[x y v] | ||
3 | MAX_LIMIT=100000000; | ||
4 | C_ROBUST=0.9; | ||
5 | r_sq=r^2; | ||
6 | points=[x y v]; | ||
7 | [n temp]=size(v); | ||
8 | [srtdV srtdVIdx]=sort(v,'descend'); | ||
9 | srtdPnts=points(srtdVIdx,:); | ||
10 | |||
11 | interestPnts=zeros(0,3); | ||
12 | |||
13 | suppressR=ones(n,1)*MAX_LIMIT; | ||
14 | supId=find(suppressR>r_sq); | ||
15 | |||
16 | iter = 0; | ||
17 | while length(supId)>0 | ||
18 | interestPnts=[interestPnts; srtdPnts(supId(1),:)]; | ||
19 | srtdPnts=srtdPnts(supId(2:end),:); | ||
20 | suppressR=suppressR(supId(2:end),:); | ||
21 | |||
22 | suppressR=min(suppressR,(C_ROBUST*interestPnts(end,3)>srtdPnts(:,3)).*((srtdPnts(:,1)-interestPnts(end,1)).^2 + (srtdPnts(:,2)-interestPnts(end,2)).^2)+(C_ROBUST*interestPnts(end,3)<=srtdPnts(:,3))*MAX_LIMIT); | ||
23 | supId=find(suppressR>r_sq); | ||
24 | iter = iter + 1; | ||
25 | end | ||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m b/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m deleted file mode 100755 index 7b36886..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/getDirParamLocal.m +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | function DIR_PARAM=getDirParam | ||
2 | DIR_PARAM.main_dir=pwd; | ||
3 | DIR_PARAM.data_dir=fullfile(DIR_PARAM.main_dir,'data'); | ||
4 | DIR_PARAM.report_dir=fullfile(DIR_PARAM.main_dir,'report'); | ||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/harris.m b/SD-VBS/benchmarks/stitch/src/matlab/harris.m deleted file mode 100755 index 423330e..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/harris.m +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | |||
2 | % Sample code for detecting Harris corners, following | ||
3 | % Brown et al, CVPR 2005 | ||
4 | % by Alyosha Efros, so probably buggy... | ||
5 | |||
6 | function [x,y,v] = harris(im, dataDir); | ||
7 | |||
8 | g1 = [1,4,6,4,1; 4,16,24,16,4;6,24,36,24,6;4,16,24,16,4;1,4,6,4,1]/256; | ||
9 | g2 = [1,2,1;2,4,2;1,2,1]/16; | ||
10 | |||
11 | img1 = conv2(im,g1,'same'); % blur image with sigma_d | ||
12 | |||
13 | Ix = conv2(img1,[-0.5 0 0.5],'same'); % take x derivative | ||
14 | Iy = conv2(img1,[-0.5;0;0.5],'same'); % take y derivative | ||
15 | |||
16 | % Compute elements of the Harris matrix H | ||
17 | %%% we can use blur instead of the summing window | ||
18 | Ix2 = conv2(Ix.*Ix,g2,'same'); | ||
19 | Iy2 = conv2(Iy.*Iy,g2,'same'); | ||
20 | IxIy = conv2(Ix.*Iy,g2,'same'); | ||
21 | |||
22 | R = (Ix2.*Iy2 - IxIy.*IxIy) ... % det(H) | ||
23 | ./ (Ix2 + Iy2 + eps); % trace(H) + epsilon | ||
24 | |||
25 | % don't want corners close to image border | ||
26 | [rows, cols] = size(im); | ||
27 | |||
28 | % non-maxima supression within 3x3 windows | ||
29 | nonmax = inline('max(x)'); | ||
30 | Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max | ||
31 | Rnm = R.*(R == Rmax); % supress non-max | ||
32 | |||
33 | % extract all interest points | ||
34 | [y,x,v] = find(Rnm); | ||
35 | |||
36 | |||
37 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/main.m b/SD-VBS/benchmarks/stitch/src/matlab/main.m deleted file mode 100755 index 9be8504..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/main.m +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | Icur_list=readData('capitol'); | ||
2 | Icur=Icur_list{1}; | ||
3 | %Icur=Icur(1:150,:,:); | ||
4 | [x y v]=harris(Icur); | ||
5 | interestPntsCur=getANMS(x, y, v, 24); | ||
6 | Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2)); | ||
7 | |||
8 | for id=2:length(Icur_list) | ||
9 | Iprev=Icur; | ||
10 | Fprev=Fcur; | ||
11 | interestPntsPrev=interestPntsCur; | ||
12 | Icur=Icur_list{id}; | ||
13 | %Icur=Icur(1:150,:,:); | ||
14 | [x y v]=harris(Icur); | ||
15 | %showInterestPoints(I, x, y) | ||
16 | interestPntsCur=getANMS(x, y, v, 16); | ||
17 | %showInterestPoints(I, interestPnts(:,1), interestPnts(:,2)) | ||
18 | Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2)); | ||
19 | matchedPntsIdx=matchFeatures(Fprev, Fcur); | ||
20 | matchedPntsPrev=interestPntsPrev(matchedPntsIdx(:,1),:); | ||
21 | matchedPntsCur=interestPntsCur(matchedPntsIdx(:,2),:); | ||
22 | |||
23 | %subplot(1,2,1);showInterestPoints(Iprev, matchedPntsPrev(:,1), matchedPntsPrev(:,2));axis image | ||
24 | %subplot(1,2,2);showInterestPoints(Icur, matchedPntsCur(:,1), matchedPntsCur(:,2));axis image | ||
25 | %drawnow | ||
26 | %pause; | ||
27 | %printImage(['featureMatching' int2str(id-1) '_' int2str(id)]); | ||
28 | [retH retPntsIdx]=ransac(matchedPntsPrev, matchedPntsCur, 10000, 100); | ||
29 | subplot(2,2,1);showInterestPoints(Iprev, matchedPntsPrev(retPntsIdx,1), matchedPntsPrev(retPntsIdx,2));axis image | ||
30 | subplot(2,2,2);showInterestPoints(Icur, matchedPntsCur(retPntsIdx,1), matchedPntsCur(retPntsIdx,2));axis image | ||
31 | T=maketform('projective', retH'); | ||
32 | Tfn_Mat=T; | ||
33 | [nr nc nd]=size(Iprev); | ||
34 | Itrans=imtransform(Iprev,T,'XData', [1 nc], 'YData', [1 nr],'FillValues',[0;0;0]); | ||
35 | subplot(2,2,3);imshow(Itrans) | ||
36 | subplot(2,2,4);imagesc(rgb2gray(abs(Icur-Itrans))) | ||
37 | drawnow | ||
38 | pause; | ||
39 | printImage(['ransac' int2str(id-1) '_' int2str(id)]); | ||
40 | end | ||
41 | |||
42 | %[Itrans2 XData YData]=imtransform(Iprev,T,'FillValues',[0;0;0]); | ||
43 | %for the fast iteration | ||
44 | %[Itrans2 XData2 YData2]=imtransform(Iprev,T,'XData', [-2*nc 2*nc], 'YData', [-2*nr 2*nr],'FillValues',[0;0;0]); | ||
45 | |||
46 | %h=imshow(Itrans); | ||
47 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m b/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m deleted file mode 100755 index 7af77e0..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/matchFeatures.m +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | function retMatch=matchFeatures(vecF1, vecF2) | ||
2 | [n1 temp]=size(vecF1); | ||
3 | [n2 temp]=size(vecF2); | ||
4 | |||
5 | retMatch=zeros(0,2); | ||
6 | |||
7 | for i=1:n1 | ||
8 | [val id]=sort(dist2(vecF1(i,:),vecF2)); | ||
9 | if val(2)~=0 & val(1)/val(2)<0.65 | ||
10 | retMatch=[retMatch; i id(1)]; | ||
11 | end | ||
12 | end | ||
13 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg b/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg deleted file mode 100644 index a4bd68b..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/pics/matched_base_cur.jpg +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg b/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg deleted file mode 100644 index 821ca11..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/pics/ransaced_feat.jpg +++ /dev/null | |||
Binary files differ | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/printImage.m b/SD-VBS/benchmarks/stitch/src/matlab/printImage.m deleted file mode 100755 index 82e74f0..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/printImage.m +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | function printImage(fname, DIR_PARAM) | ||
2 | print('-djpeg', fullfile(DIR_PARAM, [fname '.jpg'])); | ||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/ransac.m b/SD-VBS/benchmarks/stitch/src/matlab/ransac.m deleted file mode 100755 index 4a3c364..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/ransac.m +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | function [retH retPntsIdx]=ransac(pntsPrev, pntsCur, k, epsilon) | ||
2 | [n temp]=size(pntsPrev); | ||
3 | pntsPrev=[pntsPrev(:,1:2) ones(n,1)]; | ||
4 | pntsCur=[pntsCur(:,1:2) ones(n,1)]; | ||
5 | |||
6 | inlierIdx=cell(k,1); | ||
7 | inlierNum=zeros(k,1); | ||
8 | for i=1:k | ||
9 | seed=randperm(n); | ||
10 | H=calculateH(pntsPrev(seed(1:4),:), pntsCur(seed(1:4),:)); | ||
11 | err=(pntsCur-transformH(H,pntsPrev)); | ||
12 | inlierIdx{i}=find(sum(err(:,1:2).^2,2) < epsilon); | ||
13 | inlierNum=length(inlierIdx{i}); | ||
14 | end | ||
15 | |||
16 | [v maxIdx]=max(inlierNum); | ||
17 | retPntsIdx=inlierIdx{maxIdx}; | ||
18 | retH=calculateH(pntsPrev(retPntsIdx,:), pntsCur(retPntsIdx,:)); | ||
19 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/readData.m b/SD-VBS/benchmarks/stitch/src/matlab/readData.m deleted file mode 100755 index 19643bb..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/readData.m +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | function retImgs=readData(imgName, dataDir) | ||
2 | fn=fullfile(dataDir, imgName, '*.jpg'); | ||
3 | filelist=dir(fn); | ||
4 | |||
5 | retImgs=cell(length(filelist),1); | ||
6 | for i=1:length(filelist) | ||
7 | retImgs{i}=imread(fullfile(dataDir, imgName, filelist(i).name)); | ||
8 | end | ||
9 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m b/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m deleted file mode 100755 index f2ca68b..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/script_run_profile.m +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | function script_run_profile(dataDir, resultDir, type, common, toolDir) | ||
2 | |||
3 | path(path, common); | ||
4 | image_list = 1; | ||
5 | |||
6 | elapsed = zeros(1,2); | ||
7 | for i=1:image_list | ||
8 | Icur = readImage([dataDir, '/', num2str(i) ,'.bmp']); | ||
9 | rows = size(Icur,1); | ||
10 | cols = size(Icur,2); | ||
11 | fprintf(1,'Input size\t\t- (%dx%d)\n', rows, cols); | ||
12 | |||
13 | %% Self check params | ||
14 | tol = 1; | ||
15 | |||
16 | %% Timing | ||
17 | start = photonStartTiming; | ||
18 | |||
19 | [x y v]=harris(Icur,dataDir); | ||
20 | interestPntsCur=getANMS(x, y, v, 24, dataDir); | ||
21 | Fcur=extractFeatures(Icur, interestPntsCur(:,1), interestPntsCur(:,2), dataDir); | ||
22 | |||
23 | %% Timing | ||
24 | stop = photonEndTiming; | ||
25 | |||
26 | temp = photonReportTiming(start, stop); | ||
27 | elapsed(1) = elapsed(1) + temp(1); | ||
28 | elapsed(2) = elapsed(2) + temp(2); | ||
29 | |||
30 | |||
31 | end | ||
32 | |||
33 | %% Self checking | ||
34 | fWriteMatrix(Fcur, dataDir); | ||
35 | |||
36 | %% Timing | ||
37 | photonPrintTiming(elapsed); | ||
38 | |||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m b/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m deleted file mode 100755 index 487cae4..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/showInterestPoints.m +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | function showInterestPoints(im, x, y) | ||
2 | % show 'em | ||
3 | imagesc(im); | ||
4 | colormap(gray); | ||
5 | hold on; | ||
6 | plot(x,y,'r.'); | ||
7 | hold off; \ No newline at end of file | ||
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/transformH.m b/SD-VBS/benchmarks/stitch/src/matlab/transformH.m deleted file mode 100755 index 7a22eb8..0000000 --- a/SD-VBS/benchmarks/stitch/src/matlab/transformH.m +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | function retPnts=transformH(H, pnts) | ||
2 | MAX_LIMIT=10000000; | ||
3 | [n temp]=size(pnts); | ||
4 | |||
5 | pntsT = pnts'; | ||
6 | retPnts=(H*pntsT)'; | ||
7 | for i=1:n | ||
8 | if retPnts(i,3)~=0 | ||
9 | retPnts(i,:)=retPnts(i,:)./retPnts(i,3); | ||
10 | else | ||
11 | retPnts(i,:)=[MAX_LIMIT MAX_LIMIT 1]; | ||
12 | end | ||
13 | end | ||