$f$ has finite support in the set $\mathcal M = \{0, \ldots, M - 1\}$, i.e. for all $m \in \mathbb Z \setminus \mathcal M$, $f[m] = 0$, or equivalently $f : \{ 0, \ldots, M-1 \} \to \mathbb R$
Discrete convolution is commutative, i.e. $f \ast g = \class{cloze}{g \ast f}$. This is the algebraic reason the kernel is “flipped” (right-to-left) in the sum: it makes the kernel and signal interchangeable.
At the boundary of a finite signal, the simplest convention for evaluating $g[x]$ outside its support is zero-padding: define $g[x] = 0$ for $x$ outside the support. Other common conventions are reflection, replication, and circular wrap-around (the latter implicit in DFT-based convolution).
Source: Lecture 2, Convolution Example boundary-cases discussion.
The naive cost of convolving a 1D signal of length $N$ with a filter of length $M$ is $\mathcal{O}(NM)$ multiply-adds. For 2D with $N \times N$ input and $M \times M$ kernel, the cost is $\mathcal O(N^2 M^2)$. (FFT-based convolution reduces this to $\mathcal O(N^2 \log N)$ for large kernels — see Notes - Computer Vision MT25, Fourier transformU.)
There is a well-defined centre pixel, so the output at $(x, y)$ can be aligned with a single input pixel.
A “same-size” output needs zero-padding of $\tfrac{M-1}{2}$ on each side; this is an integer only when $M$ is odd, so symmetric padding works cleanly.
The output pixel $(x, y)$ then corresponds to a symmetric neighbourhood of the input.
Even-size kernels break this symmetry and require either asymmetric padding or a half-pixel output offset.
Source Lecture 2, Discrete Convolution with Finite Support slide.
Following the lecture’s convention, in $f \ast g$, $f$ is the kernel (filter) and $g$ is the input signal (image). Although mathematically $f \ast g = g \ast f$, this naming reflects which object is being slid over the other in implementation.
Source: Lecture 2, Discrete Convolution with Finite Support slide.