How to discretize and normalize an $n*n$ Gaussian kernel?

668 Views Asked by At

A 3x3 Gaussian kernel is usually shown as

$$\frac{1}{16} \begin{bmatrix}1 & 2 & 1\\ 2 & 4 & 2\\ 1 & 2 & 1\end{bmatrix}$$

But where does that actually come from?

1

There are 1 best solutions below

1
On

This is actually an approximation from pascal's triangle.

pascal's triangle

For a 3x3 kernel, you need to take the the third row of this triangle and create this operation:

$$\frac{1}{4} \begin{bmatrix}1\\ 2\\ 1\end{bmatrix} \circ \frac{1}{4} \begin{bmatrix}1 & 2 & 1\\ 1 & 2 & 1\\ 1 & 2 & 1\end{bmatrix} = \frac{1}{16} \begin{bmatrix}1 & 2 & 1\\ 2 & 4 & 2\\ 1 & 2 & 1\end{bmatrix}$$

The value of $\frac{1}{4}$ is actually just one over the sum of the pascal row.

This approximation can apply to any $n * n$ kernel, and will give a discretized and normalized matrix.