summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/ikkjin
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/ikkjin')
-rwxr-xr-xSD-VBS/common/toolbox/ikkjin/getANMS.m30
-rwxr-xr-xSD-VBS/common/toolbox/ikkjin/getImgGrad.m7
-rwxr-xr-xSD-VBS/common/toolbox/ikkjin/harris.m43
3 files changed, 80 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/ikkjin/getANMS.m b/SD-VBS/common/toolbox/ikkjin/getANMS.m
new file mode 100755
index 0000000..a40d50c
--- /dev/null
+++ b/SD-VBS/common/toolbox/ikkjin/getANMS.m
@@ -0,0 +1,30 @@
1function [interestPnts]=getANMS(x, y, v, r, dataDir)
2MAX_LIMIT=100000;
3C_ROBUST=1;
4r_sq=r^2;
5points=[x y v];
6[n temp]=size(v);
7[srtdV srtdVIdx]=sort(v,'descend');
8srtdPnts=points(srtdVIdx,:);
9
10interestPnts=zeros(0,3);
11
12suppressR=ones(n,1)*MAX_LIMIT;
13supId=find(suppressR>r_sq);
14
15iter = 0;
16while length(supId)>0
17
18 interestPnts=[interestPnts; srtdPnts(supId(1),:)];
19 srtdPnts=srtdPnts(supId(2:end),:);
20 suppressR=suppressR(supId(2:end),:);
21
22 suppressR=min(suppressR,...
23 (C_ROBUST*interestPnts(end,3)>=srtdPnts(:,3)).*...
24 ((srtdPnts(:,1)-interestPnts(end,1)).^2 + (srtdPnts(:,2)-interestPnts(end,2)).^2)...
25 +(C_ROBUST*interestPnts(end,3)<srtdPnts(:,3))*...
26 MAX_LIMIT);
27
28 iter = iter + 1;
29 supId=find(suppressR>r_sq);
30end
diff --git a/SD-VBS/common/toolbox/ikkjin/getImgGrad.m b/SD-VBS/common/toolbox/ikkjin/getImgGrad.m
new file mode 100755
index 0000000..90fae28
--- /dev/null
+++ b/SD-VBS/common/toolbox/ikkjin/getImgGrad.m
@@ -0,0 +1,7 @@
1function Ig=getImgGrad(imgroi)
2im = double(rgb2gray(imgroi));
3g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d
4img1 = conv2(im,g1,'same'); % blur image with sigma_d
5Ix = conv2(img1,[-1 0 1],'same'); % take x derivative
6Iy = conv2(img1,[-1;0;1],'same'); % take y derivative
7Ig=Ix.^2+Iy.^2; \ No newline at end of file
diff --git a/SD-VBS/common/toolbox/ikkjin/harris.m b/SD-VBS/common/toolbox/ikkjin/harris.m
new file mode 100755
index 0000000..92a6543
--- /dev/null
+++ b/SD-VBS/common/toolbox/ikkjin/harris.m
@@ -0,0 +1,43 @@
1
2% Sample code for detecting Harris corners, following
3% Brown et al, CVPR 2005
4% by Alyosha Efros, so probably buggy...
5% slightly modified by ikkjin
6
7function [x,y,v] = harris(imrgb);
8[nr nc nb]=size(imrgb);
9if nb==3
10 im=rgb2gray(imrgb);
11else
12 im=imrgb;
13end
14
15im = im2double(im);
16g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d
17g2 = fspecial('gaussian', 11,1.5); % Gaussian with sigma_i
18img1 = conv2(im,g1,'same'); % blur image with sigma_d
19Ix = conv2(img1,[-1 0 1],'same'); % take x derivative
20Iy = conv2(img1,[-1;0;1],'same'); % take y derivative
21
22% Compute elements of the Harris matrix H
23%%% we can use blur instead of the summing window
24Ix2 = conv2(Ix.*Ix,g2,'same');
25Iy2 = conv2(Iy.*Iy,g2,'same');
26IxIy = conv2(Ix.*Iy,g2,'same');
27R = (Ix2.*Iy2 - IxIy.*IxIy) ... % det(H)
28 ./ (Ix2 + Iy2 + eps); % trace(H) + epsilon
29
30% don't want corners close to image border
31R([1:15, end-16:end], :) = 0;
32R(:,[1:15,end-16:end]) = 0;
33
34% non-maxima supression within 3x3 windows
35nonmax = inline('max(x)');
36Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max
37Rnm = R.*(R == Rmax); % supress non-max
38
39% extract all interest points
40[y,x,v] = find(Rnm);
41
42
43