0

picture_1 : Gaussian function(Placing the peak at the top-left element and wrapping around)

picture_2: Gaussian function(Placing the peak in the middle)

There are two square 2-D signals with the same size $m \times m$, if the result of convolution of those two signals is first picture, And the result of cross-correlation of those two signals is second picture.How to prove it in mathematics?

robert bristow-johnson
  • 20,661
  • 4
  • 38
  • 76
  • seems like there is an offset issue of $\frac{m}{2}$ to me. they should be the same except one would be upside-down of the other. that means both left-right and up-down are flipped. but with the symmetry you have, flipping is not an issue. so the two should be the same. – robert bristow-johnson May 02 '18 at 04:57
  • are you performing circular cross-correlation and circular convolution? that is, with the assumption in both the $x$ and $y$ dimensions, that both 2-D signals repeat with a period of $m$? that is

    $$ f(x+m, y) = f(x, y) \qquad \forall x,y $$ and $$ f(x, y+m) = f(x, y) \qquad \forall x,y $$ ?

    – robert bristow-johnson May 02 '18 at 05:05
  • @robertbristow-johnson Thanks for your comment.Yes, the response of picture_1 can be reversed to the response of picture_2.But I don't know why the convolution result is picture_1 while the cross-correlation result is picture_2? I want to prove it in mathematics but I failed. – yang9264 May 02 '18 at 05:11
  • @robertbristow-johnson Yes,the convolution is circular convolution,but the cross-correlation is something like the convolution layer in CNN, pading and sliding window. – yang9264 May 02 '18 at 05:16
  • it's not just reversed. if $m$ is the width and height of the pictures, the pics you have shown are offset by $\frac{m}{2}$ in each of the $x$ and $y$ dimensions. – robert bristow-johnson May 02 '18 at 05:17
  • is the origin coordinates in the top figure at the corners and the origin of the bottom in the middle? – robert bristow-johnson May 02 '18 at 05:20
  • @robertbristow-johnson Convolutional Neural Networks – yang9264 May 02 '18 at 05:20
  • someone will have to define what "Convolutional Neural Networks" is. – robert bristow-johnson May 02 '18 at 05:21
  • @robertbristow-johnson yes,it is in the middle.I'm sorry to use CNN to try to explain the cross-correlation operation.Every signal I mentioned is picture signal. And I do cross-correlation like this : two signals w and f with the same size m×m,I add zeros around w and finally the size of w is (2(m-1) + m)×((2(m-1)+m) and then f slides in w with a stride of 1. In every position I compute sum of the dot product of f and the patch of w and the sum is the value of cross-correlation at this position.And finally I get a result with the size of m×m,that's the result of cross-correlation. – yang9264 May 02 '18 at 05:39
  • Yes there is. But the way this is stated, it is easily found in a standard textbook. You might find this useful. – A_A May 02 '18 at 07:41
  • @yang9264 See also this question. – MBaz May 02 '18 at 13:45
  • Although this question is about two-dimensional convolutions and cross-correlations, it is essentially a duplicate of this question about one-dimensional convolutions and cross-correlations. – Dilip Sarwate May 03 '18 at 02:29

1 Answers1

1

okay, let's associate the symbols $u$ and $v$ with the dimensions of $x$ and $y$ with respect to each.

and let's assume periodicity in both the $x$ and $y$ dimensions for both pictures. $f(x,y)$ and $g(x,y)$.

$$ f(x+m,y) = f(x,y) \qquad \forall x,y $$ $$ f(x,y+m) = f(x,y) \qquad \forall x,y $$ $$ g(x+m,y) = g(x,y) \qquad \forall x,y $$ $$ g(x,y+m) = g(x,y) \qquad \forall x,y $$

then 2-D Cross-Correlation is:

$$ R_{f,g}(u,v) = \sum\limits_{x=0}^{m-1} \sum\limits_{y=0}^{m-1} f(x,y) \cdot g(x+u,y+v) $$

and 2-D circular convolution is:

$$ (f\circledast \hat{g})(u,v) = \sum\limits_{x=0}^{m-1} \sum\limits_{y=0}^{m-1} f(x,y) \cdot \hat{g}(u-x,v-y) $$

if $\hat{g}(x,y) = g(-x,-y)$, then the cross-correlation and the circular convolution are the same. if $\hat{g}$ is an upside-down copy of $g$, the the correlation and convolution are the same.

or maybe they are upside-down of each other. i think it's:

if $\hat{g}(x,y) = g(-x,-y)$, then

$$ (f\circledast \hat{g})(u,v) = R_{f,g}(-u,-v) $$

that looks about right. someone needs to check this.

robert bristow-johnson
  • 20,661
  • 4
  • 38
  • 76