用MATLAB实现,结果第一步就不大对劲,是什么原因呢?
function [ linePixel, direction] = z_lineCenterPts(im, sigma)
%
%
if nargin <2
sigma = 1.5;
end
% derivative masks
s_D = 0.7*sigma;
x = -round(3*s_D):round(3*s_D);
dx = x .* exp(-x.*x/(2*s_D*s_D)) ./ (s_D*s_D*s_D*sqrt(2*pi));
dy = dx';
% image derivatives
Dx = conv2(im, dx, 'same');
Dy = conv2(im, dy, 'same');
% sum of the Auto-correlation matrix
s_I = sigma;
g = fspecial('gaussian',max(1,fix(6*s_I+1)), s_I);
Dxx = conv2(Dx.^2, g, 'same'); % Smoothed squared image derivatives
Dyy = conv2(Dy.^2, g, 'same');
Dxy = conv2(Dx.*Dy, g, 'same');
[eigenvalue1, eigenvalue2, eigenvectorx, eigenvectory]=eig2image(Dxx, Dxy, Dyy);
%判断(px, py)是否在[-1/2,1/2]X[-1/2,1/2]范围内
t = (Dx.*eigenvectorx + Dy .* eigenvectory) ./...
(Dxx .* eigenvectorx.^2 + 2*Dxy.*eigenvectorx.*eigen