1-D Convolution

The convolution operation in 1-D can be denoted as:

2-D Convolution

  • For an LSI 2-D system, the output is a weighted sum of shifted impulse responses
  • The 2-D Convolution can be denoted as:

Flip, Slide, Multiply, Sum

There are 4 steps mechanical process for computing 2D image convolution:

  1. Flipping: Rotate the filter/kernel matrix by 180 degrees (horizontally and vertically)
  2. Sliding: Slide the kernel window over the input image and align its center at
  3. Multiply: Perform element-wise multiplication
  4. Sum: Sum them up together

Correlation vs Convolution

Spatial Correlation is when we slide the filter matrix over an image to calculate the sum of element-wise products without flipping the kernel 180 degrees first.

  • the '' sign shows us the flipping process
  • For Symmetric Kernels (Gaussian, box average), flipping doesn't change the kernel
  • For Derivative Kernals, flipping changes the sign/orientation
  • Convolution:
  • Correlation:

Convolution models Linear and Shift-Invariant (LSI) system responses and spatial filtering, whereas correlation is primarily used for template matching to detect where a specific sub-image pattern matches within a larger image.

Common Kernels

Kernel NameMatrix Representation h(i,j)Primary Function / Visual EffectSum of Weights
IdentityLeaves the input image unchanged.
SharpenEnhances edges and high-frequency spatial details.
LaplacianComputes second-order spatial derivatives to detect edges.
Gaussian BlurApplies a weighted bell-curve smoothing to reduce noise softly.
Mean BlurComputes a uniform box average across all neighborhood pixels.
  • Commutativity: The order of convolution does not affect the output.
  • Associativity: Cascaded operations can be grouped in any order, allowing complex filters to be combined into a single pre-calculated kernel.
  • Distributivity: Convolution distributes directly over addition.
  • Shifted Impulse: Convolving an image with a shifted unit impulse shifts the entire input image by offset .
  • Separability: A 2D filter that can be factored into two 1D filters () reduces computational complexity from to per pixel.

Padding

Zero Padding means that if the filter/sliding window/kernel is at the edge where there are no other pixels, we treat it as 0. In otherwords, every neighbour that falls outside the image counts as 0, and you still divide by the given amount. The divisor never changes.

Example of Image Convolution

The boxed up element in the array represents the origin.

We are given an input image of a matrix, and a filter, .

1. We first flip kernel to

2. Now we shift the Kernel from to

3. We overlap matrix for

4. Output Convolution Array