From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- SD-VBS/common/toolbox/ikkjin/getANMS.m | 30 +++++++++++++++++++++ SD-VBS/common/toolbox/ikkjin/getImgGrad.m | 7 +++++ SD-VBS/common/toolbox/ikkjin/harris.m | 43 +++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100755 SD-VBS/common/toolbox/ikkjin/getANMS.m create mode 100755 SD-VBS/common/toolbox/ikkjin/getImgGrad.m create mode 100755 SD-VBS/common/toolbox/ikkjin/harris.m (limited to 'SD-VBS/common/toolbox/ikkjin') 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 @@ +function [interestPnts]=getANMS(x, y, v, r, dataDir) +MAX_LIMIT=100000; +C_ROBUST=1; +r_sq=r^2; +points=[x y v]; +[n temp]=size(v); +[srtdV srtdVIdx]=sort(v,'descend'); +srtdPnts=points(srtdVIdx,:); + +interestPnts=zeros(0,3); + +suppressR=ones(n,1)*MAX_LIMIT; +supId=find(suppressR>r_sq); + +iter = 0; +while length(supId)>0 + + interestPnts=[interestPnts; srtdPnts(supId(1),:)]; + srtdPnts=srtdPnts(supId(2:end),:); + suppressR=suppressR(supId(2:end),:); + + suppressR=min(suppressR,... + (C_ROBUST*interestPnts(end,3)>=srtdPnts(:,3)).*... + ((srtdPnts(:,1)-interestPnts(end,1)).^2 + (srtdPnts(:,2)-interestPnts(end,2)).^2)... + +(C_ROBUST*interestPnts(end,3)r_sq); +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 @@ +function Ig=getImgGrad(imgroi) +im = double(rgb2gray(imgroi)); +g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d +img1 = conv2(im,g1,'same'); % blur image with sigma_d +Ix = conv2(img1,[-1 0 1],'same'); % take x derivative +Iy = conv2(img1,[-1;0;1],'same'); % take y derivative +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 @@ + +% Sample code for detecting Harris corners, following +% Brown et al, CVPR 2005 +% by Alyosha Efros, so probably buggy... +% slightly modified by ikkjin + +function [x,y,v] = harris(imrgb); +[nr nc nb]=size(imrgb); +if nb==3 + im=rgb2gray(imrgb); +else + im=imrgb; +end + +im = im2double(im); +g1 = fspecial('gaussian', 9,1); % Gaussian with sigma_d +g2 = fspecial('gaussian', 11,1.5); % Gaussian with sigma_i +img1 = conv2(im,g1,'same'); % blur image with sigma_d +Ix = conv2(img1,[-1 0 1],'same'); % take x derivative +Iy = conv2(img1,[-1;0;1],'same'); % take y derivative + +% Compute elements of the Harris matrix H +%%% we can use blur instead of the summing window +Ix2 = conv2(Ix.*Ix,g2,'same'); +Iy2 = conv2(Iy.*Iy,g2,'same'); +IxIy = conv2(Ix.*Iy,g2,'same'); +R = (Ix2.*Iy2 - IxIy.*IxIy) ... % det(H) + ./ (Ix2 + Iy2 + eps); % trace(H) + epsilon + +% don't want corners close to image border +R([1:15, end-16:end], :) = 0; +R(:,[1:15,end-16:end]) = 0; + +% non-maxima supression within 3x3 windows +nonmax = inline('max(x)'); +Rmax = colfilt(R,[3 3],'sliding',nonmax); % find neighbrhood max +Rnm = R.*(R == Rmax); % supress non-max + +% extract all interest points +[y,x,v] = find(Rnm); + + + -- cgit v1.2.2