HARRIS Corner detector explained
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
im = imread('chessboard.jpg'); im = double(rgb2gray(im))/255; sigma = 5; g = fspecial('gaussian', 2*sigma*3+1, sigma); dx = [-1 0 1;-1 0 1; -1 0 1]; Ix = imfilter(im, dx, 'symmetric', 'same'); Iy = imfilter(im, dx', 'symmetric', 'same'); Ix2 = imfilter(Ix.^2, g, 'symmetric', 'same'); Iy2 = imfilter(Iy.^2, g, 'symmetric', 'same'); Ixy = imfilter(Ix.*Iy, g, 'symmetric', 'same'); k = 0.04; % k is between 0.04 and 0.06 % --- r = Det(M) - kTrace(M)^2 --- r = (Ix2.*Iy2 - Ixy.^2) - k*(Ix2 + Iy2).^2; norm_r = r - min(r(:)); norm_r = norm_r ./ max(norm_r(:)); subplot(1,2,1), imshow(im) subplot(1,2,2), imshow(norm_r) %hLocalMax = vision.LocalMaximaFinder; %hLocalMax.MaximumNumLocalMaxima = 100; %hLocalMax.NeighborhoodSize = [3 3]; %hLocalMax.Threshold = 0.05; %location = step(hLocalMax, norm_r); |
HARRIS Corner detector explained Read More »