Multivariate Gaussian kernel in any derivative order

Generate an N-dimensional Gaussian kernel in any derivative order.
1,5K Descargas
Actualizado 27 may 2010

Ver licencia

NDGAUSS: create ND gaussian kernel in any derivative order.

g = ndgauss(hsize,sigma);
[g,xi,yi,..] = ndgauss(hsize,sigma);

Inputs:
- hsize is N-length of kernel size.
- sigma is N-length of standard deviations (gaussian widths).

Outputs:
- g is the kernel. The size of g is hsize(1) x hsize(2) x ... hsize(n).
- [xi,yi,..] is the grid to create the kernel.

Options:
1. 'der', <gaussian_derivatives>. Default is 0.
The option must be in N-length array. Each defines which derivative
order.
Example:
a. to create d^2G(x,y) / dxdy, then 'der' = [1 1].
b. to create d^2G(x,y) / dy^2, then 'der' = [0 2].

2. 'normalize', 1 | 0. Default is 0.
If this option is set to 1, the kernel will be divided by its sum that
makes the sum of kernel is 1.
Warning: gaussian derivative kernel may not be sum to 1, e.g.,
dG(x,y)/dxdy.

NOTE: a hermite function is needed. See the requirement below for the link to this function.

Examples:
1. To create 33x33 2D gaussian kernel with different sigma:
zi = ndgauss([33 33],[2*sqrt(2) 1.2]);
imagesc(zi); colormap(gray); axis image;

2. To create several 1D gaussian kernel in different derivative orders:
leg = cell(1,5);
for i=0:4
yi(:,i+1) = ndgauss(33,2*sqrt(2),'der',i);
leg{i+1} = sprintf('g%d(x)',i);
end
plot(yi);
legend(leg);

3. To create 15x15 Laplacian of Gaussian of width 2:
Lg = ndgauss([15 15],[2 2],'der',[2 0]) + ...
ndgauss([15 15],[2 2],'der',[0 2]);
figure; colormap(gray);
subplot(1,2,1); imagesc(Lg); axis image;
subplot(1,2,2); surf(Lg); axis vis3d;

More info: http://suinotes.wordpress.com/2010/05/27/generic-multivariate-gaussian-kernel-in-any-derivative-order/

Authors:
Avan Suinesiaputra - avan dot sp at gmail dot com.
Fadillah Z Tala - fadil dot tala at gmail dot com.

Citar como

Avan Suinesiaputra (2026). Multivariate Gaussian kernel in any derivative order (https://es.mathworks.com/matlabcentral/fileexchange/27763-multivariate-gaussian-kernel-in-any-derivative-order), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2007b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Chemistry en Help Center y MATLAB Answers.
Agradecimientos

Inspirado por: Hermite polynomials

Versión Publicado Notas de la versión
1.0.0.0