Hessian matrix 的理解计算和实现(matlab)

Hessian矩阵的计算需要计算图像的二阶偏导数。一般地,线性尺度空间理论被用来计算Hessian矩阵的微分算子。在这个理论下,微分通常被定义为原始数据和高斯滤波器导数的卷积。二阶方向导数定义为:

function [Dxx,Dxy,Dyy] = Hessian2D(I,Sigma)
%  This function Hessian2 Filters the image with 2nd derivatives of a 
%  Gaussian with parameter Sigma.
% 
% [Dxx,Dxy,Dyy] = Hessian2(I,Sigma);
% 
% inputs,
%   I : The image, class preferable double or single
%   Sigma : The sigma of the gaussian kernel used
%
% outputs,
%   Dxx, Dxy, Dyy: The 2nd derivatives
%
% example,
%   I = im2double(imread('moon.tif'));
%   [Dxx,Dxy,Dyy] = Hessian2(I,2);
%   figure, imshow(Dxx,[]);

    if nargin < 2, Sigma = 1; end

    % Make kernel coordinates
    [X,Y]   = ndgrid(-round(3*Sigma):round(3*Sigma));

    % Build the gaussian 2nd derivatives filters
    DGaussxx = 1/(2*pi*Sigma^4) * (X.^2/Sigma^2 - 1) .* exp(-(X.^2 + Y.^2)/(2*Sigma^2));
    DGaussxy = 1/(2*pi*Sigma^6) * (X .* Y)           .* exp(-(X.^2 + Y.^2)/(2*Sigma^2));
    DGaussyy = DGaussxx';

    Dxx = imfilter(I,DGaussxx,'conv');
    Dxy = imfilter(I,DGaussxy,'conv');
    Dyy = imfilter(I,DGaussyy,'conv');
    % Dxx = imfilter(I,DGaussxx);
    % Dxy = imfilter(I,DGaussxy);
    % Dyy = imfilter(I,DGaussyy);
end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值