summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/ikkjin/harris.m
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/ikkjin/harris.m
parent601ed25a4c5b66cb75315832c15613a727db2c26 (diff)
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/toolbox/ikkjin/harris.m')
-rwxr-xr-xSD-VBS/common/toolbox/ikkjin/harris.m43
1 files changed, 43 insertions, 0 deletions
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