Referring to the answer here: <https://www.quora.com/Why-are-convolutional-nets-called-so-when-they-are-actually-doing-correlations>, the equation for a discrete 2D convolution is specified as:

$$C(x,y)=\sum\_{m=1}^M\sum\_{n=1}^NI(m,n)K(x-m,y-n)$$

or

$$C'(x,y)=\sum\_{m=1}^M\sum\_{n=1}^NI(x-m,y-n)K(m,n)$$

where $I$ is the image and $K$ is the kernel or filter. I can't understand how the indices work. Let's say I have the image:

$\begin{bmatrix}I\_{11} & I\_{12} & I\_{13} & I\_{14} & I\_{15}\\
I\_{21} & I\_{22} & I\_{23} & I\_{24} & I\_{25}\\
I\_{31} & I\_{32} & I\_{33} & I\_{34} & I\_{35}\\
I\_{41} & I\_{42} & I\_{43} & I\_{44} & I\_{45}\\
I\_{51} & I\_{52} & I\_{53} & I\_{54} & I\_{55}
\end{bmatrix}$ and kernel $\begin{bmatrix}K\_{11} & K\_{12} & K\_{13}\\
K\_{21} & K\_{22} & K\_{23}\\
K\_{31} & K\_{32} & K\_{33}\end{bmatrix}$

Now by the above definition (in this case $M=3$ and $N=3$)
$$C\_{11} = I\_{11}K\_{00}+I\_{12}K\_{0,-1}+I\_{13}K\_{0,-2}\\
+I\_{21}K\_{-1,0}+I\_{22}K\_{-1,-1}+I\_{23}K\_{-1,-2}+\\
+I\_{31}K\_{-2,0}+I\_{32}K\_{-2,-1}+I\_{33}K\_{-2,-2}$$

or

$$C'\_{11} = I\_{00}K\_{11}+I\_{0,-1}K\_{12}+I\_{0,-2}K\_{13}\\
+I\_{-1,0}K\_{21}+I\_{-1,-1}K\_{22}+I\_{-1,-2}K\_{23}+\\
+I\_{-2,0}K\_{31}+I\_{-2,-1}K\_{32}+I\_{-2,-2}K\_{33}$$

Even if I assume that the indices for $C$ or $C'$ run from $2$ to $4$ (instead of $1$ to $3$), then
$$C\_{22} = I\_{11}K\_{11}+I\_{12}K\_{1,0}+I\_{13}K\_{1,-1}\\
+I\_{21}K\_{0,1}+I\_{22}K\_{0,0}+I\_{23}K\_{0,-1}+\\
+I\_{31}K\_{-1,1}+I\_{32}K\_{-1,0}+I\_{33}K\_{-1,-1}$$

or

$$C'\_{22} = I\_{11}K\_{11}+I\_{1,0}K\_{12}+I\_{1,-1}K\_{13}\\
+I\_{0,1}K\_{21}+I\_{0,0}K\_{22}+I\_{0,-1}K\_{23}+\\
+I\_{-1,1}K\_{31}+I\_{-1,0}K\_{32}+I\_{-1,-1}K\_{33}$$

So no matter how the indices are defined, the indices for either $I$ or $K$ go out of bounds in the expression for convolution. How do I make sense of this? What's meant by terms with negative indices like $I\_{-1,-2}$ or $K\_{0,-1}$?

---

**Follow-up doubt**: So assuming zero-padding, all terms with non-positive indices are assumed to be $0$. From that, given the two formulas for $C\_{22}$ and $C'\_{22}$ above, they evaluate to just $I\_{11}K\_{11}$, since all terms involving non-positive indices vanish. But that doesn't sound right, since from my understanding, it should evaluate to:

$$\begin{bmatrix}I\_{11} & I\_{12} & I\_{13}\\
I\_{21} & I\_{22} & I\_{23}\\
I\_{31} & I\_{32} & I\_{33}\end{bmatrix}:
\begin{bmatrix}K\_{33} & K\_{32} & K\_{31}\\
K\_{23} & K\_{22} & K\_{21}\\
K\_{13} & K\_{12} & K\_{11}\end{bmatrix}$$

(where $:$ represents Frobenius inner product) since convolution is the same as cross-correlation with a flipped kernel. So I still can't make sense of the formulas for $C\_{22}$ and $C'\_{22}$ as I wrote above.