필터 지우기
필터 지우기

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

조회 수: 156 (최근 30일)
jon
jon 2013년 5월 1일
댓글: Webi Dabuse 2020년 9월 29일
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"

채택된 답변

Matt J
Matt J 2013년 5월 2일
편집: Matt J 2013년 5월 2일
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
taa199
taa199 2015년 8월 20일
very good explaination
Vibhav Inna Kedege
Vibhav Inna Kedege 2020년 5월 11일
very good explanation!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 5월 2일
편집: Image Analyst 2013년 5월 2일
It doesn't need to be flipped, at least not by you. You pass in the array and the flipping is done internally, automatically, because that's the definition of convolution. If it didn't flip, it would be correlation, not convolution. If you flipped it before passing it into conv2(), then you'd be doing a correlation instead of a convolution because the internal flip in counteracted by your advance manual flip. If you want, you can use imfilter() or xcorr2() which do no flip internally.
  댓글 수: 3
Image Analyst
Image Analyst 2017년 9월 18일
Flip it left to right using fliplr(), then flip it top to bottom with flipud().
Webi Dabuse
Webi Dabuse 2020년 9월 29일
Or you can just rotate it by 180 degrees. rot90(image,2)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by