diff options
Diffstat (limited to 'SD-VBS/common/toolbox/ikkjin')
-rwxr-xr-x | SD-VBS/common/toolbox/ikkjin/getANMS.m | 30 | ||||
-rwxr-xr-x | SD-VBS/common/toolbox/ikkjin/getImgGrad.m | 7 | ||||
-rwxr-xr-x | SD-VBS/common/toolbox/ikkjin/harris.m | 43 |
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 @@ | |||
1 | function [interestPnts]=getANMS(x, y, v, r, dataDir) | ||
2 | MAX_LIMIT=100000; | ||
3 | C_ROBUST=1; | ||
4 | r_sq=r^2; | ||
5 | points=[x y v]; | ||
6 | [n temp]=size(v); | ||
7 | [srtdV srtdVIdx]=sort(v,'descend'); | ||
8 | srtdPnts=points(srtdVIdx,:); | ||
9 | |||
10 | interestPnts=zeros(0,3); | ||
11 | |||
12 | suppressR=ones(n,1)*MAX_LIMIT; | ||
13 | supId=find(suppressR>r_sq); | ||
14 | |||
15 | iter = 0; | ||
16 | while 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); | ||
30 | end | ||
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 @@ | |||
1 | function Ig=getImgGrad(imgroi) | ||
2 | im = double(rgb2gray(imgroi)); | ||
3 | g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d | ||
4 | img1 = conv2(im,g1,'same'); % blur image with sigma_d | ||
5 | Ix = conv2(img1,[-1 0 1],'same'); % take x derivative | ||
6 | Iy = conv2(img1,[-1;0;1],'same'); % take y derivative | ||
7 | Ig=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 | |||
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 | |||