Sobes.tech
Junior — Senior

What is the difference between convolution and cross-correlation?

sobes.tech AI

Answer from AI

Convolution and cross-correlation are operations frequently used in signal processing and computer vision, especially in convolutional neural networks (CNNs).

Main difference:

  • In convolution, the kernel (filter) is rotated by 180 degrees before being applied to the input signal or image.
  • In cross-correlation, the kernel is applied without rotation.

That is, if we denote the input signal as ( f ), and the kernel as ( g ), then:

  • Convolution: ( (f * g)(t) = , \sum_{\tau} f(\tau) , g(t - \tau) )
  • Cross-correlation: ( (f \star g)(t) = , \sum_{\tau} f(\tau) , g(t + \tau) )

In practice, in machine learning, the operation that is more commonly used is similar to cross-correlation, but it is called convolution.

Example:

If you have a filter:

1 0
0 -1
  • During convolution, it will be rotated by 180°, i.e.,
-1 0
0 1
  • During cross-correlation, the filter is used without changes.

Most deep learning libraries (e.g., PyTorch, TensorFlow) implement the convolution operation as cross-correlation, i.e., without rotating the kernel.

Thus, the difference is technical and important for theoretical understanding, but in practice, in ML, cross-correlation (called convolution) is more often used.