The big picture
Topics 2–6 walk along the pipeline from Topic 1, from how light becomes pixels to finding whole shapes in them.
Each topic in four lines
Introduction to Computer Vision ›
- CV = image → meaning; IP = image → image; CG = model → image.
- Pipeline: capture → pre-process → features → analysis → decision.
- Digital image = I(x, y) with x, y and I finite and discrete; pixel; grey level.
- 5 resolutions: pixel · spatial · spectral · temporal · radiometric. RGB (additive) · CMY (subtractive) · HSI/HSV.
Visual perception & image sensing ›
- Light = visible EM; colour = reflected light. Radiance · luminance · brightness.
- Single sensor · strip · array. f = i · r.
- Sampling = coordinates; quantization = intensity; quantization error.
- Histogram h(rk) = nk. Contrast stretching (5th/95th %) · equalisation sk = Σni/n.
Arithmetic, logic & geometric ops ›
- Pixel by pixel: add min(255, ·) · subtract max(0, ·) / |A−B| · multiply = mask · divide A/(B+ε) · average.
- Logical AND/OR/NOT/XOR on binary masks.
- Scale · rotate · shear · reflect · translate; homogeneous coordinates → affine chains.
- Inverse mapping + nearest neighbour / bilinear; aliasing (jaggies, moiré).
Noise & filtering ›
- g = f + η. Gaussian (sensor) · Poisson (shot, mean = var = λ) · salt & pepper (impulse) · speckle (g = f·η).
- Mean blurs edges; Gaussian weights the centre; median beats salt & pepper and keeps edges.
- Convolution = flipped-kernel cross-correlation (same if symmetric).
- Borders: zero · replicate · reflect · valid · truncated.
Edge detection ›
- Edge = significant local intensity change.
- ∇I = [Ix, Iy], G = √(Ix²+Iy²), θ = tan⁻¹(Iy/Ix); edge ⟂ gradient.
- Prewitt [1 1 1]ᵀ vs Sobel [1 2 1]ᵀ smoothing; threshold T.
- Laplacian zero crossings · LoG = ∇²(Gσ∗I) · Canny: smooth → gradient → NMS → double threshold → hysteresis.
Hough transform ›
- Edges are local; Hough finds global lines despite gaps and noise.
- Polar form x cosθ + y sinθ = d (handles vertical lines).
- Point → sinusoid; collinear points → curves meet at (d, θ).
- Accumulator A(d, θ) votes → peak (≥ T) → line. Extensions: circles · probabilistic.
Formula sheet
| Topic | What | Formula / mask |
|---|---|---|
| T2 | Image formation | f(x,y) = i(x,y) · r(x,y) |
| T2 | Histogram | h(rk) = nk · p(rk) = nk/n |
| T2 | Contrast stretching | Iout = (Iin − c)(b − a)/(d − c) + a |
| T2 | Equalisation | sk = Σi=0..k ni/n · new = round(sk · m) |
| T3 | Add / subtract | min(255, A + B) · max(0, A − B) · |A − B| |
| T3 | Divide / average | A/(B + ε) · (1/N) Σ Ii |
| T3 | Rotation | [cosθ −sinθ; sinθ cosθ] |
| T3 | Reflection about a line at θ | [cos2θ sin2θ; sin2θ −cos2θ] |
| T3 | Translation (homogeneous) | [1 0 tx; 0 1 ty; 0 0 1] |
| T3 | Nearest neighbour | I′(x,y) = I(round x, round y) |
| T4 | Noise models | g = f + η, η ~ N(μ, σ²) · K ~ Poisson(λ) · speckle g = f · η |
| T4 | Mean / Gaussian 3 × 3 | (1/9)[1 1 1; 1 1 1; 1 1 1] · (1/16)[1 2 1; 2 4 2; 1 2 1] |
| T4 | Cross-corr. / convolution | Σ f[m+i, n+j] h[i,j] · Σ f[m−i, n−j] h[i,j] |
| T5 | Gradient | G = √(Ix² + Iy²) · θ = tan⁻¹(Iy/Ix) |
| T5 | Sobel Gx | [−1 0 1; −2 0 2; −1 0 1] |
| T5 | Laplacian (4-nbr) | [0 1 0; 1 −4 1; 0 1 0] · edge if L₁L₂ < 0 and |L₁ − L₂| ≥ T |
| T5 | LoG | ∇²(Gσ ∗ I) |
| T6 | Line, polar form | x cosθ + y sinθ = d |
Noise → filter (Topic 4)
| Noise | Model | Start with |
|---|---|---|
| Gaussian (sensor) | additive, N(μ, σ²) | Gaussian or mean filter; more advanced if fine detail matters |
| Poisson (shot) | K ~ Poisson(λ), mean = var = λ | Gaussian or mean filter, then Wiener |
| Salt & pepper | impulse, isolated extremes | Median |
| Speckle | multiplicative g = f · η | Lee or Frost filters |
Edge detectors compared (Topic 5)
| Detector | Looks for | Good | Weak |
|---|---|---|---|
| Prewitt / Sobel | gradient peak | simple; Sobel a little more noise-robust | thick edges, noise |
| Laplacian | zero crossing | one isotropic mask | very noisy, no orientation |
| LoG | zero crossing after Gaussian | noise handled by σ | σ to choose |
| Canny | gradient peak + NMS + hysteresis | thin, connected, low-noise | two thresholds to tune |
One worked example through the whole pipeline
One tiny grey image with one straight edge, carried from capture to a line equation: Topic 2 → Topic 4 → Topic 5 → Topic 6. Every number below was computed and checked. Each step cites its slides (Topic 2 uses the PDF page numbers, as on the LO2 page). The example image and the choices of T are ours; other parts marked added are study aids, not lecture content.
1 · Sample the scene (T2) Topic 2 · slides 10–13, 19
The sensor output is continuous in x, y and amplitude, so making a digital image takes two steps: sampling, then quantization (slides 10–11). Sampling digitises the coordinates: lay a grid and take one value per cell. Slide 12 uses 10 × 10 = 100 samples; we use 5 × 5 = 25 so the numbers stay small.
Our scene is dark on the left and bright on the right, the same in every row. One row of samples: 0.12, 0.15, 0.47, 0.86, 0.90. The middle sample (0.47) is where the boundary falls inside a cell. The result is the image as a 2-D array (slide 19).
added We write pixels as (x, y) with x = column and y = row, origin top-left, as Topic 6 slide 11 draws it. Slide 19 lists f(row, column), so read its indices the other way round.
2 · Quantize to 3 bits (T2) Topic 2 · slides 14–18 · Topic 1 · slide 15
Quantization digitises the amplitude (slides 14–16). Slide 17: divide black-to-white into equal parts and give each sample the nearest discrete value. We keep 8 levels, 0–7 (Topic 1 slide 15 shows an 8-level strip), which need 3 bits: codes 000…111, like the binary labels on slide 18.
Step by step: multiply by 7, take the nearest level. 0.84 → 1, 1.05 → 1, 3.29 → 3, 6.02 → 6, 6.30 → 6. The gaps are the quantization error (slide 18): 0.16, 0.05, 0.29, 0.02, 0.30, all at most half a step. Every row of the image is now 1 1 3 6 6.
added “Multiply by 7 and round” is our way of writing slide 17’s nearest level; 0 = black and the top level = white as on Topic 2 slide 23.
3 · Salt-and-pepper noise hits two pixels (T4) Topic 4 · slides 4, 14–16, 20
A transmission or storage error sets two pixels to extremes (slides 14–15): salt at (1, 1) goes 1 → 7 (white, the top level) and pepper at (3, 3) goes 6 → 0 (black). This is impulse noise; the other 23 pixels are untouched. We now only see g(x, y), and the task is to estimate f(x, y) without losing detail (slide 4).
Why it matters (slide 20): random intensity changes are picked up as false edges.
added Checked: running step 5 on this noisy image with the same T = 16 loses the whole true edge (G at x = 2 drops to 8–15.2) and marks two false edge pixels at (3, 2) and (3, 4) with G = 17.
4 · Remove it with a 3 × 3 median (T4) Topic 4 · slides 26, 31–33, 38
The median filter sorts the 9 values and keeps the middle one (slide 31). At the salt pixel (1, 1): window 1 1 3 / 1 7 3 / 1 1 3 → sorted 1 1 1 1 1 3 3 3 7 → 5th = 1. At the pepper pixel (3, 3): 3 6 6 / 3 0 6 / 3 6 6 → 0 3 3 3 6 6 6 6 6 → 6. The extremes sit at the ends of the list and never reach the middle.
On the edge pixel (2, 2) the window is 1 3 6 three times → 1 1 1 3 3 3 6 6 6 → 3, so the edge stays: the median preserves edges (slide 31). The output is exactly the clean image 1 1 3 6 6 again. Compare a 3 × 3 mean at (1, 1): 21/9 = 2.33, the salt is smeared, not removed (slide 26). Slide 33: salt and pepper → median.
Border pixels use replication padding (slide 38). added Getting the clean image back exactly is a property of this simple example.
5 · Sobel gradient and a threshold (T5) Topic 5 · slides 13–14, 17–18, 22
Sobel = the derivative mask [−1 0 1] across × the smoothing vector [1 2 1]ᵀ down; Gy uses the transpose (slide 17). At (2, 2) the window rows are all 1 3 6, so Gx = (6 − 1)·1 + (6 − 1)·2 + (6 − 1)·1 = 20 and Gy = 0 (the row below equals the row above).
Slide 13: G = √(Gx² + Gy²) = 20, θ = tan⁻¹(0/20) = 0°: the gradient points along +x (dark → bright) and the edge runs perpendicular, at 90°, a vertical edge (slide 14). The columns give G = 0, 8, 20, 12, 0. With a manual threshold T = 16 (slides 18, 22), E = 1 only at x = 2: five edge pixels (2, 0) … (2, 4).
added T = 16 is our choice. Masks are laid on the image without flipping (cross-correlation, Topic 4 slide 35) and borders are replicated.
6 · Hough: vote, find the peak, write the line (T6) Topic 6 · slides 10, 13, 18–25, 27
Each edge pixel (x0, y0) votes for every line through it, x0 cosθ + y0 sinθ = d (slide 13), at θ = 0°, 45°, 90°, 135° as in the slide example (slide 21). With x = 2: at 0° every pixel gives d = 2; at 45° d = 1.41 … 4.24, at 90° d = y, at 135° d = −1.41 … 1.41, all different.
Accumulator A(d, θ) (slide 18): 5 pixels × 4 angles = 20 votes over 16 cells. A(2, 0°) = 5, every other cell 1. It is max(A) (slide 25) and passes a threshold such as T = 3 (slide 27). Rebuild the line (slide 23): x cos0° + y sin0° = 2 → x = 2, the vertical boundary. This is the line y = mx + c cannot write (slide 9), and the reason for the polar form (slide 10).
added The Sobel θ = 0° at the edge pixels equals the Hough θ of the line: both describe the direction perpendicular to the line. T = 3 is our choice.
Likely exam questions
- Distinguish computer vision, image processing and computer graphics. LO1 ›
- Explain sampling and quantization; define quantization error. LO2 ›
- Histogram-equalise a given 8-level histogram (worked table). LO2 ›
- Contrast stretching: apply the formula; why do outliers break it? LO2 ›
- Define the arithmetic operations and give applications (motion detection, masking, averaging). LO3 ›
- Why does translation need homogeneous coordinates? LO3 ›
- Forward vs inverse mapping; nearest-neighbour vs bilinear (scale a 2 × 2 by 2). LO3 ›
- Describe the four noise types, their models and the filter for each. LO4 ›
- Mean vs Gaussian vs median: which for salt & pepper, and why? LO4 ›
- Convolution vs cross-correlation; boundary handling options. LO4 ›
- Compute G, θ and the edge orientation from Ix, Iy. LO5 ›
- Prewitt vs Sobel; Laplacian zero crossings; LoG. LO5 ›
- The five steps of Canny and why each is needed. LO5 ›
- Why polar form? Give (d, θ) for a line such as y = x + 1 or x = 3. LO6 ›
- Run a Hough accumulator on a few edge pixels and recover the line. LO6 ›