diff options
author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
---|---|---|
committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/stitch/src/matlab/harris.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (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-x | SD-VBS/benchmarks/stitch/src/matlab/harris.m | 37 |
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 | |||
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 | |||