MCS4304 · Summaryall topics on one page
Computer Vision · module summaryAll six lecture topics on one page: where each one sits in the pipeline, the key points of each, a formula sheet, a noise-to-filter table, and the likely exam questions with links to the worked answers. From Topic 1–6 lecture slides. Practise everything All notes (PDF)

The big picture

Where each topic sits in the CV pipeline (Topic 1)CaptureT2 sensing · sampling · quantizationPre-processT2 histogram · T3 arithmetic/geometric · T4 denoiseFeaturesT5 edgesAnalysisT6 Hough: lines, circlesDecisionlater topicsraw light → clean pixels → edges → whole shapes

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

TOPIC 1 · LO1
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.
TOPIC 2 · LO2
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.
TOPIC 3 · LO3
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é).
TOPIC 4 · LO4
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.
TOPIC 5 · LO5
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.
TOPIC 6 · LO6
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

TopicWhatFormula / mask
T2Image formationf(x,y) = i(x,y) · r(x,y)
T2Histogramh(rk) = nk · p(rk) = nk/n
T2Contrast stretchingIout = (Iin − c)(b − a)/(d − c) + a
T2Equalisationsk = Σi=0..k ni/n · new = round(sk · m)
T3Add / subtractmin(255, A + B) · max(0, A − B) · |A − B|
T3Divide / averageA/(B + ε) · (1/N) Σ Ii
T3Rotation[cosθ −sinθ; sinθ cosθ]
T3Reflection about a line at θ[cos2θ sin2θ; sin2θ −cos2θ]
T3Translation (homogeneous)[1 0 tx; 0 1 ty; 0 0 1]
T3Nearest neighbourI′(x,y) = I(round x, round y)
T4Noise modelsg = f + η, η ~ N(μ, σ²) · K ~ Poisson(λ) · speckle g = f · η
T4Mean / 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]
T4Cross-corr. / convolutionΣ f[m+i, n+j] h[i,j] · Σ f[m−i, n−j] h[i,j]
T5GradientG = √(Ix² + Iy²) · θ = tan⁻¹(Iy/Ix)
T5Sobel Gx[−1 0 1; −2 0 2; −1 0 1]
T5Laplacian (4-nbr)[0 1 0; 1 −4 1; 0 1 0] · edge if L₁L₂ < 0 and |L₁ − L₂| ≥ T
T5LoG∇²(Gσ ∗ I)
T6Line, polar formx cosθ + y sinθ = d

Noise → filter (Topic 4)

NoiseModelStart 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 & pepperimpulse, isolated extremesMedian
Specklemultiplicative g = f · ηLee or Frost filters

Edge detectors compared (Topic 5)

DetectorLooks forGoodWeak
Prewitt / Sobelgradient peaksimple; Sobel a little more noise-robustthick edges, noise
Laplacianzero crossingone isotropic maskvery noisy, no orientation
LoGzero crossing after Gaussiannoise handled by σσ to choose
Cannygradient peak + NMS + hysteresisthin, connected, low-noisetwo 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

A continuous scene becomes a 5 × 5 grid of samplesscene: continuous in x, yand amplitude (slide 11)01234012345 × 5 = 25 samplesx = column, y = rowone row of samples (0 = black, 1 = white)x=00.12x=10.15x=20.47x=30.86x=40.9every row is the same(the scene does not change with y)
swipe to see the whole diagram

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.

→ LO2 deep part

2 · Quantize to 3 bits (T2) Topic 2 · slides 14–18 · Topic 1 · slide 15

Quantize to 3 bits = 8 levels, then read the error71116110510141003011201010010000level · codex01234v × 70.841.053.296.026.30level11366code001001011110110error0.160.050.290.020.30nearest level = vertical proximity (slide 17)11366113661136611366113660123401234the 5 × 5 image
swipe to see the whole diagram

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.

→ LO2 deep part

3 · Salt-and-pepper noise hits two pixels (T4) Topic 4 · slides 4, 14–16, 20

Two pixels hit by impulse noise11366113661136611366113660123401234clean (after step 2)11366173661136611306113660123401234noisy g(x, y)salt (1,1): 1 → 7 · pepper (3,3): 6 → 0

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.

→ LO4 deep part

4 · Remove it with a 3 × 3 median (T4) Topic 4 · slides 26, 31–33, 38

3 × 3 median: sort the window, keep the 5th value11366173661136611306113660123401234noisy image + two windowswindow at (1,1), sorted1111133375th = 1window at (3,3), sorted0333666665th = 611366113661136611366113660123401234median output = clean again
swipe to see the whole diagram

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.

→ LO4 deep part

5 · Sobel gradient and a threshold (T5) Topic 5 · slides 13–14, 17–18, 22

Sobel at (2, 2), then every column, then threshold T = 16window at (2,2)136136136×Gx mask−101−202−101Gx = 5·1 + 5·2 + 5·1 = 20Gy = (1+6+6) − (1+6+6) = 0G = √(20² + 0²) = 20θ = tan⁻¹(0/20) = 0°x01234Gx 0820120Gy 00000G0820120E (T=16)00100same in every row (y = 0…4)edge map E5 edge pixelsat x = 2
swipe to see the whole diagram

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.

→ LO5 deep part

6 · Hough: vote, find the peak, write the line (T6) Topic 6 · slides 10, 13, 18–25, 27

Each edge pixel votes; the peak gives the line0123401234edge pixels (2, 0)…(2, 4)d = x cosθ + y sinθ for each pixel (x = 2)θ \ yy=0y=1y=2y=3y=40°2222245°1.412.122.833.544.2490°01234135°−1.41−0.7100.711.4120 votes over 16 (d, θ) cellspeak A(2, 0°) = 5other 15 cells = 15 ≥ T = 3 → a linex cos0° + y sin0° = 2→ x = 2
swipe to see the whole diagram

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.

→ LO6 deep part

Likely exam questions

  1. Distinguish computer vision, image processing and computer graphics. LO1 ›
  2. Explain sampling and quantization; define quantization error. LO2 ›
  3. Histogram-equalise a given 8-level histogram (worked table). LO2 ›
  4. Contrast stretching: apply the formula; why do outliers break it? LO2 ›
  5. Define the arithmetic operations and give applications (motion detection, masking, averaging). LO3 ›
  6. Why does translation need homogeneous coordinates? LO3 ›
  7. Forward vs inverse mapping; nearest-neighbour vs bilinear (scale a 2 × 2 by 2). LO3 ›
  8. Describe the four noise types, their models and the filter for each. LO4 ›
  9. Mean vs Gaussian vs median: which for salt & pepper, and why? LO4 ›
  10. Convolution vs cross-correlation; boundary handling options. LO4 ›
  11. Compute G, θ and the edge orientation from Ix, Iy. LO5 ›
  12. Prewitt vs Sobel; Laplacian zero crossings; LoG. LO5 ›
  13. The five steps of Canny and why each is needed. LO5 ›
  14. Why polar form? Give (d, θ) for a line such as y = x + 1 or x = 3. LO6 ›
  15. Run a Hough accumulator on a few edge pixels and recover the line. LO6 ›

Cross-topic exam questions · 7

X1An image has salt-and-pepper noise and you need Sobel edges. Which filter do you run first, and why not a mean or Gaussian filter?
Run a median filter first. Salt and pepper is isolated extreme values from transmission or storage errors (Topic 4 · slides 14–15), and an edge detector reacts to any abrupt local change (Topic 5 · slides 3, 8), so each impulse becomes a false edge (Topic 4 · slide 20). The mean is pulled by outliers and blurs edges because it averages across the boundary (Topic 4 · slide 26); the Gaussian does not reliably remove isolated extreme pixels (Topic 4 · slide 30). The median sorts and keeps the middle value, is particularly effective against salt and pepper and preserves edges better (Topic 4 · slides 31, 33). Then Sobel and the threshold T (Topic 5 · slides 17–18). In the worked example above: the mean at the salt pixel gives 2.33 instead of 1, the median gives 1, and without filtering the true edge is lost and two false edge pixels appear. LO4 › · LO5 ›
X2Why does the Hough transform need an edge map first, and what does it add that the edge detector cannot give?
Step 1 of the Hough summary is “obtain edge pixels” (Topic 6 · slide 24): the voters are the 1s of a binary edge image (Topic 6 · slides 19–20), produced by thresholding the gradient, E = 1 where G ≥ T (Topic 5 · slide 18). An edge detector only gives local facts: where intensity changes and which pixels are likely boundaries (Topic 6 · slide 3). It does not say whether edge pixels belong to the same line, or whether a line is there despite gaps, noise or occlusion (Topic 6 · slide 5). Hough adds that global grouping: every edge pixel votes in A(d, θ) and the peak is the line (Topic 6 · slides 18, 25). Two different thresholds appear: T on gradient magnitude (Topic 5 · slide 18) and T on votes (Topic 6 · slide 27). added Thick Sobel edges (Topic 5 · slide 30) put several parallel columns into the vote and spread the peak; thin Canny edges (Topic 5 · slide 33) give a sharper one. LO5 › · LO6 ›
X3How do sampling and quantization choices at capture affect edge detection later in the pipeline?
Sampling sets how many pixels describe the scene (Topic 2 · slides 11–12): more samples, finer detail. Derivatives are approximated by differences between neighbouring samples (Topic 5 · slide 15), so coarse sampling squeezes an edge into one or two pixels, and sampling too low for fine detail gives aliasing such as jagged edges (Topic 3 · slide 32). Quantization sets the size of the intensity steps (Topic 2 · slides 17–18; Topic 1 · slides 15–16 show what few levels do). Worked on the pipeline row 0.12, 0.15, 0.47, 0.86, 0.90: with 8 levels it becomes 1 1 3 6 6 and Sobel Gx = 0 8 20 12 0, one clear peak at x = 2. With 2 levels (1 bit) it becomes 0 0 0 1 1 and Gx = 0 0 4 4 0: the in-between pixel is gone, two columns tie, and with T = 16 nothing is marked at all. added T is measured in grey-level units, so it can only be chosen once the bit depth is fixed. LO2 › · LO3 › · LO5 ›
X4Images come from a high-ISO, low-light camera. Name the noise model, the filter and the edge detector you would chain, and justify each link.
High-ISO and dark images carry sensor noise, modelled as additive Gaussian η ~ N(μ, σ²) (Topic 4 · slides 6, 8); low light also brings shot noise, K ~ Poisson(λ) (Topic 4 · slides 10–11). For both, start with a Gaussian (or mean) filter (Topic 4 · slides 33–34). Do not use the plain Laplacian: it is noise-sensitive (Topic 5 · slide 28). Use LoG = ∇²(Gσ ∗ I), which smooths first (Topic 5 · slide 29), or Canny, whose step 1 is the same Gaussian smoothing (Topic 5 · slides 31–32) with the kernel from Topic 4 · slide 29; non-maximum suppression thins the edges and double threshold + hysteresis keep weak edges only when connected to strong ones (Topic 5 · slides 33–35). added If the scene is still, averaging N frames (Topic 3 · slide 12) lowers the noise before any of this. LO3 › · LO4 › · LO5 ›
X5An image is rotated (a geometric transform) before edge detection and Hough. How do the interpolation choice and the rotation itself show up in the edges and in the accumulator?
Rotation (Topic 3 · slide 20) sends pixels to non-integer positions, so the output is built by inverse mapping plus interpolation (Topic 3 · slides 25, 27–28). Nearest neighbour keeps the original intensities but gives jagged edges and aliasing (Topic 3 · slide 29): a straight boundary becomes a staircase, so the edge pixels scatter around the true line. Bilinear weights four neighbours (Topic 3 · slide 30): a smoother edge, but it averages across the boundary like a mean filter (Topic 4 · slide 26), so the gradient peak is lower and may drop under T (Topic 5 · slide 18). In Hough, scattered or broken edges split votes over nearby cells (Topic 6 · slide 26). added The rotation itself moves the peak: rotating by φ about the origin turns the line’s perpendicular by φ, so a line at (d, θ) shows up at (d, θ + φ). LO3 › · LO5 › · LO6 ›
X6Should you apply contrast stretching or histogram equalisation before thresholding a gradient image? What happens to the threshold T?
Contrast stretching maps [c, d] to [a, b] with one scale factor (b − a)/(d − c) (Topic 2 · slide 28), so every difference between pixels, and so every derivative (Topic 5 · slides 15, 17), grows by the same factor. Worked on the pipeline row 1 1 3 6 6 stretched from [1, 6] to [0, 7] (factor 1.4): 0 0 2.8 7 7, stored as 0 0 3 7 7, and Sobel Gx = 0 12 28 16 0. With the old T = 16 the edge becomes two pixels wide (x = 2 and 3). So a fixed T must be re-chosen after any enhancement; percentile, histogram-analysis or Otsu thresholds (Topic 5 · slide 22) adjust to the new range on their own. Equalisation (Topic 2 · slides 31–33) is non-linear: it spreads the most frequent intensities, so differences change by different amounts in different places. added It can make small, noisy differences in flat regions larger, giving more false edges; enhancement is mainly for viewing. LO2 › · LO5 ›
X7A library’s “convolution” is used to run Sobel. Does it matter whether it really convolves or cross-correlates? What changes in G, θ, the edge map and the Hough result?
Cross-correlation uses the kernel as it is (Topic 4 · slide 35); convolution flips it horizontally and vertically first (Topic 4 · slide 36); the two agree only for symmetric kernels (Topic 4 · slide 37). The mean and Gaussian kernels are symmetric (Topic 4 · slides 26, 29), so smoothing is unaffected. The Sobel masks are not: flipping [−1 0 1; −2 0 2; −1 0 1] gives its negative, so Gx → −Gx and Gy → −Gy. G = √(Gx² + Gy²) is unchanged (Topic 5 · slide 13), so the edge map E (Topic 5 · slide 18) and the Hough votes, which use only edge-pixel coordinates (Topic 6 · slide 24), are unchanged too. Only the direction flips by 180° (bright → dark instead of dark → bright). In the pipeline: at (2, 2) Gx becomes −20, G is still 20. added tan⁻¹(Gy/Gx) alone cannot see the flip, since 0/20 and 0/−20 are both 0; you need the signs. LO4 › · LO5 › · LO6 ›

Final mixed check · 12 MCQs All MCQs in Practise

Practise every MCS4304 question