diff options
| author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
|---|---|---|
| committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
| commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
| tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/ikkjin/harris.m | |
| parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (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-x | SD-VBS/common/toolbox/ikkjin/harris.m | 43 |
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 | |||
| 7 | function [x,y,v] = harris(imrgb); | ||
| 8 | [nr nc nb]=size(imrgb); | ||
| 9 | if nb==3 | ||
| 10 | im=rgb2gray(imrgb); | ||
| 11 | else | ||
| 12 | im=imrgb; | ||
| 13 | end | ||
| 14 | |||
| 15 | im = im2double(im); | ||
| 16 | g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d | ||
| 17 | g2 = fspecial('gaussian', 11,1.5); % Gaussian with sigma_i | ||
| 18 | img1 = conv2(im,g1,'same'); % blur image with sigma_d | ||
| 19 | Ix = conv2(img1,[-1 0 1],'same'); % take x derivative | ||
| 20 | Iy = 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 | ||
| 24 | Ix2 = conv2(Ix.*Ix,g2,'same'); | ||
| 25 | Iy2 = conv2(Iy.*Iy,g2,'same'); | ||
| 26 | IxIy = conv2(Ix.*Iy,g2,'same'); | ||
| 27 | R = (Ix2.*Iy2 - IxIy.*IxIy) ... % det(H) | ||
| 28 | ./ (Ix2 + Iy2 + eps); % trace(H) + epsilon | ||
| 29 | |||
| 30 | % don't want corners close to image border | ||
| 31 | R([1:15, end-16:end], :) = 0; | ||
| 32 | R(:,[1:15,end-16:end]) = 0; | ||
| 33 | |||
| 34 | % non-maxima supression within 3x3 windows | ||
| 35 | nonmax = inline('max(x)'); | ||
| 36 | Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max | ||
| 37 | Rnm = R.*(R == Rmax); % supress non-max | ||
| 38 | |||
| 39 | % extract all interest points | ||
| 40 | [y,x,v] = find(Rnm); | ||
| 41 | |||
| 42 | |||
| 43 | |||
