I have read that convolution and cross-correlation are the same thing, but convolution flips 180 degrees (images), or time reverses (sequences) the kernel, before performing the elementwise multiplication of the input and the kernel.

I understand how this works on 1D signals, however I do not know how to perform these two operations for 2D images, and it's been really hard to find any good example on the web.

I would very much appreciate an example, showing both Convolution and Cross-correlation of an image. Clearly specifying what the indexes stand for and how the output image is calculated.

For example (feel free to use any other example if you think it would be better):

enter image description here


1 Answer 1


If as you said you understand well the 1-D convolution/cross-correlation functioning (the Wikipedia first graph explains it in a clear way), the 2-D version is very similar!

This website explains 2-D convolution in a simple way with clear indicies and examples. In a nutshell, the kernel has to be flipped for convolution and this means your kernel example would become [M L; K J] (sorry for the formatting). Then you multiply elementwise and sum the results, as you would do in the 1-D case.

Cross-correlation functioning is the same without flipping the kernel.


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.