3
$\begingroup$

I've always thought that image convolution is a weighted sum of the nearby pixels using the convolution kernel as weights. But from the description on Wikipedia, this is what cross correlation does. Convolution seems to be equivalent to 1) reversing the convolution kernel 2) doing cross correlation with this reversed kernel.

If I understand it correctly – why is image blurring called convolution? What's the point of reversing the kernel?

$\endgroup$
3
  • $\begingroup$ Probably a duplicate of this question. $\endgroup$
    – Matt L.
    Commented Jun 25, 2013 at 19:34
  • $\begingroup$ I found the answer here: scicomp.stackexchange.com/questions/6962/… $\endgroup$
    – fhucho
    Commented Jun 25, 2013 at 19:43
  • 1
    $\begingroup$ @fhucho: can you please write out an answer and accept it then? In the case of blurring with a symmetrical function, they should be identical, no? $\endgroup$
    – endolith
    Commented Jun 25, 2013 at 21:02

2 Answers 2

5
$\begingroup$

Broadly speaking, image blurring replaces each pixel value by a weighted sum of adjacent pixel values. Now, this weighted sum can be represented as convolution or as a correlation for the simple reason that a convolution of $I$ and $g$ (where $I$ is the image and $g$ the kernel) is the same as the correlation of $I$ and $\hat{g}$ where $\hat{g}$ is just $g$ "flipped over". As fhucho has already pointed out, if the kernel is symmetric, the flipping over has no effect.

It is easier to understand this idea in 1D rather than 2D. For each $n$, suppose that the result (weighted sum of adjacent values) that we need to get is $$\begin{align} \hat{I}[n] &= \quad I[n]a[0]\\ &\quad +\ I[n+1]a[1] + I[n+2]a[2] + \cdots + I[n+N]a[N]\\ &\quad +\ I[n-1]a[-1] + I[n-2]a[-2] + \cdots + I[n-N]a[-N]\\ &= \sum_{m=-N}^N I[n+m]a[m] \end{align}$$ We readily recognize as the correlation of $\mathbf I$ and the sequence $$\mathbf a =\left(a[-N], a[-N+1], \cdots, a[0], \cdots a[N-1], a[N]\right).$$ Now, define the sequence $\mathbf g$ as $\mathbf a$ flipped over, that is, $g[m] = a[-m]$ for all $m$. Note that $\mathbf a$ is just $\mathbf g$ flipped over (and is thus the $\hat{g}$ mentioned earlier). Then we have that $$\begin{align} \hat{I}[n] &= \sum_{m=-N}^N I[n+m]a[m]\\ &= \sum_{m=-N}^N I[n+m]g[-m]\\ &= \sum_{-i=-N}^N I[n-i]g[i] &\text{replace}~ m~\text{by} ~ -i\\ &= \sum_{i=-N}^N I[n-i]g[i] & \text{write sum in reverse order}\\ &= \mathbf I \star \mathbf g\bigr|_n \end{align}$$ A similar calculation can be carried out for 2D signals (images) but the details are messier and sometimes it is hard to see the forest because of the trees.

In summary, whether we choose to regard image blurring as correlation or convolution is entirely a matter of convenience and nomenclature. We can convolve the image and the "impulse response" or correlate the image with the "esnopser eslupmi", whichever we prefer, and in either case, we are replacing each pixel value with the same weighted sum of adjacent pixel values.

$\endgroup$
2
$\begingroup$

According to this answer, when doing image convolution, the kernel indeed needs to be be flipped. If the kernel is symmetric, flipping is not needed. Why is convolution used for image blurring instead of cross-correlation? Because convolution has some useful mathematical properties like commutativity and convolution theorem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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