Mathematica provides built-in functions for generating standard structure matrices and convolution kernels in any number of dimensions, in a form that can be used directly in image processing, linear algebra or other applications.
GaussianMatrix — Gaussian and Gaussian derivatives