GaussianMatrix
✖
GaussianMatrix
gives a matrix corresponding to a Gaussian kernel with radius r and standard deviation σ.
gives a matrix formed from the n1 derivative of the Gaussian with respect to rows and the n2 derivative with respect to columns.
gives a matrix formed from the sums of the ni1 and ni2 derivatives.
gives an array corresponding to a Gaussian kernel with radius ri in the i index direction.
Details and Options
- GaussianMatrix[r] gives values that approximate at index position from the center, where σ=r/2.
- By default, the elements of GaussianMatrix[r] sum to 1.
- GaussianMatrix[…,{n1,n2}] by default constructs discrete derivatives as finite differences.
- GaussianMatrix[r,{{2,0},{0,2}}] gives a matrix formed from the Laplacian of a Gaussian.
- GaussianMatrix[{Automatic,σ,f},…] constructs a matrix just large enough to include at least a fraction f of the discrete integral of a Gaussian in each direction.
- Any of the r, σ, and f can be lists, specifying different values for different directions.
- For integer r, GaussianMatrix[r,…] yields a × matrix.
- For noninteger r, the value of r is effectively rounded to an integer.
- The following options can be specified:
-
Method "Bessel" how to determine matrix elements Standardized True whether to rescale and shift the matrix to account for truncation WorkingPrecision Automatic the precision with which to compute matrix elements - Possible settings for the Method option are "Bessel" and "Gaussian".
- With the default option setting Method->"Bessel", GaussianMatrix[r] has elements proportional to , yielding a kernel with optimal discrete convolution properties.
- For Method->"Bessel", derivatives of the Gaussian are obtained by the finite difference operator. GaussianMatrix[{r,}] satisfies the finite difference equation .
- With Method->"Gaussian", GaussianMatrix[r] has elements proportional to the raw continuous functional form .
- For Method->"Gaussian", derivatives of the Gaussian are proportional to the partial derivatives of the functional form. The GaussianMatrix[{r,}] approximately satisfies the differential equation .
- With Standardized->True, the proportionality factor ensures that the elements of GaussianMatrix[r] sum to 1. However, the elements of GaussianMatrix[r,{n1,n2,…}] with at least one nonzero ni will sum to 0, and the sum of the elements, weighted in each direction by times the distance from the origin to the power of ni, will be 1.
- With Standardized->False, no proportionality factor is used.
Background & Context
- GaussianMatrix is a constructor function that returns a matrix having a Gaussian profile. Such matrices are typically used as kernels in image convolution for smoothing or taking derivatives of images.
- The function ImageConvolve can be used to perform convolution on an image using a Gaussian matrix kernel. Other functions that create smoothing or derivative kernel matrices include ShenCastanMatrix and SavitzkyGolayMatrix. Note that non-smooth kernels can also be used to smooth images. Binary kernels commonly used for this purpose include DiskMatrix, DiamondMatrix, and other similar functions.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Compute and plot a Gaussian matrix:
https://wolfram.com/xid/0btn95uoco0i-1nvad2
Compute and plot a Gaussian vector:
https://wolfram.com/xid/0btn95uoco0i-qgxvnv
First derivative of a Gaussian matrix in the horizontal dimension:
https://wolfram.com/xid/0btn95uoco0i-6yfkpd
Scope (6)Survey of the scope of standard use cases
https://wolfram.com/xid/0btn95uoco0i-8lv33w
https://wolfram.com/xid/0btn95uoco0i-gj8km0
Gaussian matrix with varying standard deviations:
https://wolfram.com/xid/0btn95uoco0i-lxhmcl
First derivative of a Gaussian matrix in the vertical dimension:
https://wolfram.com/xid/0btn95uoco0i-jowcy7
First derivative of a Gaussian matrix in the horizontal dimension:
https://wolfram.com/xid/0btn95uoco0i-bfxl94
3D visualization of the matrix:
https://wolfram.com/xid/0btn95uoco0i-111eap
Create and visualize a 3D Gaussian array:
https://wolfram.com/xid/0btn95uoco0i-g1jvg0
https://wolfram.com/xid/0btn95uoco0i-h4ns0e
A 3D derivative kernel along the first dimension:
https://wolfram.com/xid/0btn95uoco0i-ilcb8h
Generalizations & Extensions (4)Generalized and extended use cases
Generate an exact symbolic Gaussian matrix:
https://wolfram.com/xid/0btn95uoco0i-cf468j
Use a radius of twice the standard deviation:
https://wolfram.com/xid/0btn95uoco0i-q46xtt
https://wolfram.com/xid/0btn95uoco0i-usf3g2
Use a radius sufficient to at least fill the desired fraction of the Gaussian:
https://wolfram.com/xid/0btn95uoco0i-55sxf1
Using a smaller radius would not have provided the desired fraction:
https://wolfram.com/xid/0btn95uoco0i-sqn505
Use a standard deviation such that a specified radius provides a desired fraction of the Gaussian:
https://wolfram.com/xid/0btn95uoco0i-4eb28y
Options (10)Common values & functionality for each option
Method (4)
With Method->"Bessel", the derivative is computed using a finite difference:
https://wolfram.com/xid/0btn95uoco0i-kj9qce
https://wolfram.com/xid/0btn95uoco0i-07ra9i
https://wolfram.com/xid/0btn95uoco0i-ne4skk
With Method->"Gaussian", the continuous derivative is used:
https://wolfram.com/xid/0btn95uoco0i-y27jjp
https://wolfram.com/xid/0btn95uoco0i-f41dem
https://wolfram.com/xid/0btn95uoco0i-ehz8ne
A Gaussian matrix appropriate for discrete convolution:
https://wolfram.com/xid/0btn95uoco0i-s8qqbq
A Gaussian matrix sampled from the continuum:
https://wolfram.com/xid/0btn95uoco0i-ncwkde
Standardized (5)
https://wolfram.com/xid/0btn95uoco0i-c66dsb
https://wolfram.com/xid/0btn95uoco0i-jxaj18
An unnormalized Gaussian vector:
https://wolfram.com/xid/0btn95uoco0i-vmrmyn
The total of the unnormalized matrix approaches 1 as the ratio of its size to its standard deviation increases:
https://wolfram.com/xid/0btn95uoco0i-cv5ttm
A shifted Gaussian derivative:
https://wolfram.com/xid/0btn95uoco0i-bw7xz8
A shifted Gaussian derivative is also rescaled:
https://wolfram.com/xid/0btn95uoco0i-evp199
https://wolfram.com/xid/0btn95uoco0i-yfn2jf
A Gaussian derivative that is not standardized:
https://wolfram.com/xid/0btn95uoco0i-1q5o2v
https://wolfram.com/xid/0btn95uoco0i-iwbb9h
Shifts and rescalings are performed using a discrete normalization for all methods:
https://wolfram.com/xid/0btn95uoco0i-g4sqe
https://wolfram.com/xid/0btn95uoco0i-okvhlh
https://wolfram.com/xid/0btn95uoco0i-6g0nwx
https://wolfram.com/xid/0btn95uoco0i-p8crum
Applications (3)Sample problems that can be solved with this function
https://wolfram.com/xid/0btn95uoco0i-zdrqj2
https://wolfram.com/xid/0btn95uoco0i-un4axi
Apply Gaussian blur to an image:
https://wolfram.com/xid/0btn95uoco0i-3tzbx
Compute vertical derivative of an image:
https://wolfram.com/xid/0btn95uoco0i-6duj7t
Wolfram Research (2008), GaussianMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/GaussianMatrix.html (updated 2015).
Text
Wolfram Research (2008), GaussianMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/GaussianMatrix.html (updated 2015).
Wolfram Research (2008), GaussianMatrix, Wolfram Language function, https://reference.wolfram.com/language/ref/GaussianMatrix.html (updated 2015).
CMS
Wolfram Language. 2008. "GaussianMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GaussianMatrix.html.
Wolfram Language. 2008. "GaussianMatrix." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/GaussianMatrix.html.
APA
Wolfram Language. (2008). GaussianMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GaussianMatrix.html
Wolfram Language. (2008). GaussianMatrix. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GaussianMatrix.html
BibTeX
@misc{reference.wolfram_2024_gaussianmatrix, author="Wolfram Research", title="{GaussianMatrix}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/GaussianMatrix.html}", note=[Accessed: 07-January-2025
]}
BibLaTeX
@online{reference.wolfram_2024_gaussianmatrix, organization={Wolfram Research}, title={GaussianMatrix}, year={2015}, url={https://reference.wolfram.com/language/ref/GaussianMatrix.html}, note=[Accessed: 07-January-2025
]}