Page 1 of 1

Why do we need to flip the kernel in 2D convolution?

Posted: 2013-05-01T13:57:37-07:00
by jonmuchnick
Why do we need to flip the kernel in 2D convolution in the first place?
What's the benefit of this?
So, why can't we leave it unflipped? What kind of terrible thing can happen if you don't flip it?
You can include the convolution theorem in you answer ;)

SEE:
"First, flip the kernel, which is the shaded box, in both horizontal and vertical direction"

http://www.songho.ca/dsp/convolution/co ... ample.html

Re: Why do we need to flip the kernel in 2D convolution?

Posted: 2013-05-01T17:08:28-07:00
by fmw42
This post and my reply should be moved to the User's forum.

The answer is that convolution and correlation are 180 rotations for the kernel from each other as Anthony correctly points out at http://www.imagemagick.org/Usage/convol ... _correlate. A convolution detect the same shape in a point image. A correlation will rotate that shape. See Anthony's examples at the link above.

However, for a symmetric kernel, the rotation makes no difference.

For non-symmetric kernels such as the sobel directional derivative convolution of

-1 0 1
-1 0 1
-1 0 1

the correlation with the same kernel will produce different edge image results. However, the correlation will produce the same result as the convolution if you rotate the kernel 180 degrees to

1 0 -1
1 0 -1
1 0 -1