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
    $\begingroup$ "usually"? By whom? Also the title does not match the body of the question, since the body is only about the $3\times3$ kernel. $\endgroup$ – Rahul Apr 19 at 16:35
  • $\begingroup$ It doesn't take long to do a google search to confirm this is usually how it's represented - google.com/search?q=3x3+gaussian+kernel&tbm=isch This is pretty commonly written out without really an explanation on how this number was 'achieved'. This post tries to explain that and not just show magical numbers to someone learning it. $\endgroup$ – Amir Omidi Apr 19 at 17:00
  • $\begingroup$ The body is about a $3*3$ kernel, but this applies for any n sized kernel using the pascal approximation. $\endgroup$ – Amir Omidi Apr 19 at 17:01
  • $\begingroup$ It's unfortunate that there are many people who put incorrect images on the internet. The correct way to parametrize a Gaussian kernel is not by its size but by its standard deviation $\sigma$; the 2D array it is discretized into is then truncated at about $3\sigma$ to keep the computational cost finite. $\endgroup$ – Rahul Apr 19 at 18:13

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.

  • $\begingroup$ Instead of downvoting, I would like clarification on why this answer is bad. Or maybe edits on making the answer better. $\endgroup$ – Amir Omidi Apr 19 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.