第一次发文很多地方不了解,请多见谅
以Matlab内建extractFeatures
[FEATURES, VALID_POINTS]=extractFeatures(grayImage, detectPoint);
想请问如何以featureHarris的output: featureX, featureY, and R
(featureX, featureY分别表读出feature matrix的row和column的系数, R是value)
当做extractFeatures的output: FEATURES, VALID_POINTS呢?
Reference Code:
function [featureX, featureY, R] = featureHarris(im, w, sigma, threshold,
radius, k)
disp('Harris corner detector.');
if( ~exist('w') )
w = 5;
elseif(rem(w, 2) == 0)
w = w + 1;
end
if( ~exist('sigma') )
sigma = 1;
end
if( ~exist('threshold') )
threshold = 3;
end
if( ~exist('radius') )
radius = 1;
end
if( ~exist('k') )
k = 0.04;
end
% convert the image into luminance
dim = ndims(im);
if( dim == 3 )
I = rgb2gray(im);
else
I = im;
end
[row, col] = size(I);
% convert the im to double
if( ~isa(I, 'double'))
I = double(I);
end
% smooth the image to remove noise
sI = filterGaussian(I, sigma, w); %w=window size
% derivatives
[Ix, Iy] = gradient(sI);
% products of derivatives
Ix2 = Ix .^ 2;
Iy2 = Iy .^ 2;
Ixy = Ix .* Iy;
% elements for the matrix M
Sx2 = filterGaussian(Ix2, sigma, w);
Sy2 = filterGaussian(Iy2, sigma, w);
Sxy = filterGaussian(Ixy, sigma, w);
R = (Sx2 .* Sy2 - Sxy .^ 2) - k * (Sx2 + Sy2) .^ 2;
R2 = (R > threshold);
R2 = R2 & (R > imdilate(R, [1 1 1; 1 0 1; 1 1 1]));
%Output
[featureY, featureX] = find(R2);
end