What is wrong with my code - Harris corner detector
Afficher commentaires plus anciens
Hi, when I am trying to implement the Harris corner detector, but when I run this code, all that is printing is a straight line. I don't know what the problem is.
function [y, r, c] = part2(threshold, sigma, radius)
im = 'einstein.jpg';
im = double(im);
e = 2.71828;
%threshold = 5*e - 4;
%sigma = 3;
%radius = 3;
k = 0.04;
%Definition of filters used to computer the image derivatives by utilizing
%the Sobel operator
dx = [-1 0 1; -2 0 2; -1 0 1];
dy = dx';
%Computation of image derivatives Ix and Iy using convolution
Ix = conv2(im, dx, 'same');
Iy = conv2(im, dy, 'same');
%Generation of Gaussian smoothing filter w(u,v)
w = fspecial('gaussian', 6*sigma, sigma);
%Computation of Ix2, Iy2, and Ixy
Ix2 = Ix.^2;
Iy2 = Iy.^2;
Ixy = Ix.*Iy;
%Computation of smoothed versions of Ix2, Iy2, and Ixy
Ix2smooth = conv2(Ix2, w, 'same');
Iy2smooth = conv2(Iy2, w, 'same');
Ixysmooth = conv2(Ixy, w, 'same');
%Computation of cornerness measure M
det = (Ix2smooth.*Iy2smooth) - Ixysmooth.^2;
trace =Ix2smooth + Iy2smooth;
y = det - k*(trace).^2;
%Performance of non-maximal suppression
suppress = ordfilt2(y, radius, threshold);
[r, c] = find(y);
imshow(im);
plot(c, r);
%end
Réponses (1)
Image Analyst
le 2 Mar 2013
0 votes
Why not just use the built-in corner() function?
Catégories
En savoir plus sur Image Category Classification dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!