1.1 What are Filters, Filter Types & 2D Convolution
Why Do We Use Filters? (6 Core Uses)
- Removing noise (cleaning grainy pixels from a low-light phone photo)
- Smoothing / blurring (softening skin or hiding tiny specks before edge detection)
- Sharpening (making blurry text crisp)
- Detecting edges (finding object outlines)
- Detecting corners (finding distinct anchor points for tracking)
- Enhancing fine details
Linear Filters vs Non-Linear Filters
| Type | How It Computes Output | Everyday Example | Algorithms / Filters |
|---|---|---|---|
| Linear Filter | Output pixel is a weighted sum (or average) of neighbouring pixels. | Taking the weighted average of today's, yesterday's, and tomorrow's temperature to smooth a weather graph. | Mean (Average), Gaussian, Sobel, Prewitt, Laplacian, High-pass, Low-pass |
| Non-Linear Filter | Output is NOT a weighted sum; uses ranking/comparison instead. | Sorting 9 students' heights and picking the middle student (Median) so one giant outlier doesn't skew the result. | Median Filter, Maximum Filter, Minimum Filter |
[50, 50, 50, 50, 255, 50, 50, 50, 50] where one pixel got corrupted by a bright white "salt" speck (255).• Mean Filter:
(8×50 + 255)/9 = 72.8 → The white speck smears into a grey smudge!• Median Filter: Sort values →
[50,50,50,50,50,50,50,50,255] → Middle value = 50 → The noise speck vanishes completely!
Complete Filter Reference Table (From Module 2 Notes)
| Filter | Type | Purpose |
|---|---|---|
| Mean (Box) Filter | Linear | Smooths image by equally averaging neighbouring pixels |
| Gaussian Filter | Linear | Smooths while preserving edges better than mean filter (center pixel gets highest weight) |
| Median Filter | Non-Linear | Removes salt-and-pepper noise cleanly |
| Sobel Filter | Linear | Detects horizontal/vertical edges (weighted gradient) |
| Prewitt Filter | Linear | Detects edges (uniform gradient weighting) |
| Laplacian Filter | Linear | Detects edges in all directions (2nd derivative) |
| High-pass Filter | Linear | Enhances fine details and edges |
| Low-pass Filter | Linear | Removes high-frequency noise and smooths the image |
What is Convolution? (Step-by-Step)
Convolution (written G = F ∗ H) is the exact mathematical operation used to apply a kernel H to an image F:
- Place the small kernel (e.g. 3×3) centered over a pixel in the image.
- Multiply each kernel weight by the corresponding underlying image pixel.
- Add all the products together.
- Store that total in the output image G, then slide one pixel to the right (and down row by row).