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

142 views (last 30 days)

Show older comments

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?

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

##### 0 Comments

### Accepted Answer

Matt J
on 2 May 2013

Edited: Matt J
on 2 May 2013

It's not meant to be a "benefit" or to avoid disastrous consequences. It's meant to be a definition. If you don't flip, then you violate the agreed upon definition of convolution. Convolution without the flip has a name of its own: correlation.

What motivated people to define convolution with a flip? Well in 1D, it means, for example that the convolution of causal signals will also be causal. Also, when you flip, then the convolution with an impulse response function of a system gives you the response of that system. If you don't flip, the response comes out backwards.

Why do the same in 2D? Using a different definition in 2D would make it inconsistent with 1D.

##### 5 Comments

### More Answers (1)

Image Analyst
on 2 May 2013

Edited: Image Analyst
on 2 May 2013

##### 3 Comments

Image Analyst
on 18 Sep 2017

Flip it left to right using fliplr(), then flip it top to bottom with flipud().

### See Also

### Categories

### Products

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!