Code covered by the BSD License  

Highlights from
SDGD Edge Detection Filter

from SDGD Edge Detection Filter by Sergei Koptenko
Second-Derivative-in-the-Gradient-Direction edge detection filter

GaussDx2(GDsize, mu, sigma, sigma_width)
function GaussKernel_2D = GaussDx2(GDsize, mu, sigma, sigma_width)
% Function GaussKernel_2D = GaussDx2(GDsize, mu, sigma, sigma_width) computes
% 2D Gaussian Derivative 
%INPUTS:
%   GDSIZE      - size of Gaussian kernel.
%   MU          - mean of the Gaussian
%   SIGMA       - standard deviation of a Gaussian function
%   SIGMA_WIDTH - defines where to cut the Gaussian kernel tail (or width of the kernel in sigma).
%   Bigger number- more of Gaussian included in the kernel. Defaul value= 3 or 98% of Gaussian 
%
%OUTPUT:
%   GAUSSKERNEL_2D - derivative kernel used by  plus_filt2D.m, sdged_filt2D.m

sigma_width = ceil(sigma_width * sigma);
x = linspace(-sigma_width, sigma_width, GDsize); 

Gaussian = exp(- 0.5*(((x - mu)/ sigma) .^2)) /(sigma * realsqrt(2 * pi)); 
Gaussian = Gaussian / sum(Gaussian); % normalize the sum of samples to 1

GaussKernel_1D = (mu - x) .* Gaussian / sigma^2;
GaussKernel_1D  = GaussKernel_1D  /sum(GaussKernel_1D .* (mu-x)); % normalize kernel
GaussKernel_2D = conv2(GaussKernel_1D, Gaussian', 'full');

Contact us at files@mathworks.com