Structure Matrices and Convolution Kernels
Structure Matrices and Convolution Kernels
| DiskMatrix[r] | a radius r disk of 1s inside a (2r+1)×(2r+1) matrix of 0s |
| DiskMatrix[{r1,…}] | an ellipsoid of 1s with radii r1, … inside an array of dimension (2r1+1)× … |
| DiskMatrix[{r1, …},{n1, …}] | an ellipsoid with radii r1, … inside an array of dimension n1× … |
| DiamondMatrix[{r1,…},{n1,…}] | a diamond of 1s with radii r1, … inside an array of dimension n1× … |
| BoxMatrix[{r1,…},{n1,…}] | a box of 1s with radii r1, … inside an array of dimension n1× … |
| CrossMatrix[{r1,…},{n1,…}] | a cross of 1s with radii r1, … inside an array of dimension n1× … |
DiamondMatrix[4]//MatrixFormBoxMatrix[2, 10]//MatrixFormDiamondMatrix[7, {10, 20}]//MatrixFormArrayPlot[DiskMatrix[{100, 200}, {251, 501}]]Image[DiskMatrix[{100, 200}, {251, 501}]]Image /@ CrossMatrix[{3, 5, 10}]Graphics3D[Cuboid /@ Position[DiskMatrix[{12, 10, 8}], 1], BoxRatios -> Automatic]| GaussianMatrix[r] | a (2r+1)×(2r+1) matrix that samples a Gaussian |
| GaussianMatrix[{r,σ}] | a (2r+1)×(2r+1) matrix that samples a Gaussian with standard deviation σ |
| GaussianMatrix[{{r1,…},{σ1,…}}] | a (2r1+1)× … array that samples a Gaussian with standard deviation σi in the i th direction |
| GaussianMatrix[{{r1,…},{σ1,…}},{n1,…}] | a (2r1+1)× … array that samples the ni th discrete derivative in the i th direction of a Gaussian with standard deviation σi in the i th direction |
GaussianMatrix[2]//MatrixFormGaussianMatrix can construct arrays with any rank:
GaussianMatrix[{{2}}]By default, the matrix elements are numerical and constructed to behave optimally under discrete convolution. Using WorkingPrecision->Infinity will produce an exact representation:
GaussianMatrix[1, WorkingPrecision -> Infinity]//MatrixFormUse Method->"Gaussian" to sample a true Gaussian:
GaussianMatrix[2, Method -> "Gaussian", WorkingPrecision -> Infinity]//MatrixFormListLinePlot[{GaussianMatrix[{{10}}, Method -> "Bessel"], GaussianMatrix[{{10}}, Method -> "Gaussian"]}, DataRange -> {-10, 10}, PlotStyle -> {Blue, Red}]GaussianMatrix[{{3, 2}, 1}]//MatrixFormListPlot3D[GaussianMatrix[10, {2, 0}], DataRange -> {{-10, 10}, {-10, 10}}]Sum derivatives by using nested List objects in the second argument. For example, this plots the Laplacian:
ListDensityPlot[GaussianMatrix[10, {{2, 0}, {0, 2}}], DataRange -> {{-10, 10}, {-10, 10}}]This finds the length of the vector which has a minimum of 95% of the integrated fraction of the Gaussian with standard deviation 1:
Dimensions[GaussianMatrix[{{Automatic}, {1}, {.95}}]]This finds the dimensions of the matrix which, in each direction, has a minimum of 95% of the integrated fraction of the Gaussian with standard deviation 1:
Dimensions[GaussianMatrix[{Automatic, 1, .95}]]Dimensions[GaussianMatrix[{Automatic, 1, {.85, .95, .99}}]]