summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/stitch/src/matlab/harris.m
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/stitch/src/matlab/harris.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/stitch/src/matlab/harris.m')
-rwxr-xr-xSD-VBS/benchmarks/stitch/src/matlab/harris.m37
1 files changed, 37 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/stitch/src/matlab/harris.m b/SD-VBS/benchmarks/stitch/src/matlab/harris.m
new file mode 100755
index 0000000..423330e
--- /dev/null
+++ b/SD-VBS/benchmarks/stitch/src/matlab/harris.m
@@ -0,0 +1,37 @@
1
2% Sample code for detecting Harris corners, following
3% Brown et al, CVPR 2005
4% by Alyosha Efros, so probably buggy...
5
6function [x,y,v] = harris(im, dataDir);
7
8g1 = [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;
9g2 = [1,2,1;2,4,2;1,2,1]/16;
10
11img1 = conv2(im,g1,'same'); % blur image with sigma_d
12
13Ix = conv2(img1,[-0.5 0 0.5],'same'); % take x derivative
14Iy = 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
18Ix2 = conv2(Ix.*Ix,g2,'same');
19Iy2 = conv2(Iy.*Iy,g2,'same');
20IxIy = conv2(Ix.*Iy,g2,'same');
21
22R = (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
29nonmax = inline('max(x)');
30Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max
31Rnm = R.*(R == Rmax); % supress non-max
32
33% extract all interest points
34[y,x,v] = find(Rnm);
35
36
37