Five topics from decks 08 and 09, each with a picture and the exact lines to write in the exam.
Everything she has asked from decks 08 and 09 is on this page. Skip the rest of the decks (point detection, split & merge, Hough).
How each section works: the orange box lists the exam questions it answers. Then: the idea in one line, the lines to write (with a grey "means" line under each), and every numeric worked in full.
Your own words are fine. She marks the idea, not the exact sentence. Make sure the bold keywords appear in your answer.
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
Segmentation algorithms use one of two basic properties of intensity values:
There are only two ways to split a picture into objects. Say that first.
1. Discontinuity: partition the image where intensity changes sharply, i.e. at edges.
Look for places where brightness suddenly jumps (dark to bright). Those jumps are the borders of objects.
Methods: point, line and edge detection (gradient, LoG, Canny), watershed.
The tools that find those jumps: Sobel gradient, Canny and so on.
2. Similarity: partition the image into regions that are similar according to a predefined criterion.
Instead of borders, put pixels that look alike into the same group (e.g. all bright pixels = object).
Methods: thresholding, region growing, region splitting and merging.
The tools that make groups: one cut-off value (threshold), or spreading from a seed (region growing).
Memory hook: discontinuity finds borders, similarity finds groups.
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| f(x) | 5 | 5 | 4 | 3 | 2 | 1 | 0 | 0 |
| 1st = f(x+1) − f(x) | 0 | -1 | -1 | -1 | -1 | -1 | 0 | |
| 2nd = f(x+1) + f(x−1) − 2f(x) | -1 | 0 | 0 | 0 | 0 | 1 |
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
∂f/∂x = f(x+1) − f(x)
1st derivative = next pixel minus this pixel: how much the brightness changes in one step.
∂²f/∂x² = f(x+1) + f(x−1) − 2f(x)
2nd derivative = how much that change itself changes: right + left − 2 × middle.
Example ramp 5 5 4 3 2 1 0 0: 1st = 0 -1 -1 -1 -1 -1 0; 2nd = -1 0 0 0 0 1.
Brightness slides down 5 to 0 one step at a time (a ramp). Work out both rows with the formulas above; this example earns marks.
(1) The 1st derivative is non-zero along the entire ramp, giving a thick edge.
It is −1 at every step of the slope, so the whole slope lights up: the edge looks wide.
(2) The 2nd derivative is non-zero only at the start and end of the ramp, with opposite signs (a double edge), and zero along the ramp.
It only reacts where the slope begins (−1) and ends (+1): two thin lines, one negative and one positive.
(3) It crosses zero at the edge centre, where the 1st derivative is maximum. Its sign tells dark→light or light→dark.
Between the −1 and the +1 it passes through 0: that crossing point is the middle of the edge. Which sign comes first tells which way the brightness goes.
The 2nd derivative responds strongly to isolated points and is very sensitive to noise, so the image is smoothed first.
A single noisy dot gives a huge 2nd-derivative value, so we blur the image a bit before using it.
What are the two principal approaches to image segmentation? Why is a Laplacian filter typically combined with a Gaussian smoothing filter (LoG operator) before performing edge detection in noisy environments? [4 + 2 = 6]
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
(a) Two principal approaches, based on two basic properties of intensity values:
Same answer as section 1. Write both approaches with their methods; that's the 4 marks.
1. Discontinuity: partition the image where intensity changes abruptly, e.g. at edges. Methods: point, line and edge detection (gradient, Laplacian / LoG, Canny).
Find where brightness suddenly jumps; those jumps are the borders.
2. Similarity: partition the image into regions that are similar according to a predefined criterion. Methods: thresholding, region growing, region splitting and merging.
Group pixels that look alike.
(b) Why Gaussian before Laplacian: the Laplacian ∇²f is a second derivative, which is extremely sensitive to noise: every noisy pixel gives a strong response and false zero crossings (false edges).
The Laplacian reacts hugely to any single odd pixel, so noise shows up as fake edges.
Smoothing with a Gaussian G(x,y) = e−(x²+y²)/2σ² first suppresses the noise, so the zero crossings of the Laplacian mark only real edges: g(x,y) = ∇²[G(x,y) ★ f(x,y)].
Blur first to kill the noise, then take the Laplacian. Now the zero crossings are real edges.
Both are linear, so they combine into one mask, the LoG ("Mexican hat"): ∇²[G ★ f] = [∇²G] ★ f. This is cheaper, and the zero crossings give well-localised edges. σ controls the scale: larger σ = more smoothing, only coarse edges.
You can pre-combine blur + Laplacian into a single mask and slide it once. Bigger σ = more blur = only the big edges remain.
| 0 | 0 | -1 | 0 | 0 |
| 0 | -1 | -2 | -1 | 0 |
| -1 | -2 | 16 | -2 | -1 |
| 0 | -1 | -2 | -1 | 0 |
| 0 | 0 | -1 | 0 | 0 |
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
Three criteria:
Canny promises three things. Write all three.
(1) Good detection: mark all real edges, few missed, few false.
Find every real edge, and don't invent fake ones from noise.
(2) Good localisation: detected edge as close as possible to the true edge.
The line you draw sits exactly on the real border, not shifted to the side.
(3) Single response: only one response per edge.
One edge = one thin line, not three parallel lines.
Five steps:
Then list the 5 steps in order.
1. Smoothing: fs = G ★ f, with Gaussian G(x,y) = e−(x²+y²)/2σ², to remove noise.
Blur the picture a little so tiny noise dots don't look like edges. ★ = slide the Gaussian mask over the image; σ = how strong the blur is.
2. Gradient with Sobel masks: M = √(gx² + gy²), α = tan⁻¹(gy/gx).
gx = how fast brightness changes left to right, gy = top to bottom (the two Sobel masks). M = edge strength (big M = strong edge). α = the direction in which brightness increases.
3. Non-maximum suppression: round α to 0°, 45°, 90° or 135°; keep a pixel only if its M is not smaller than both neighbours along that direction, else set it to 0.
After step 2 an edge is several pixels thick, like a hill. Walk across the hill (direction α) and keep only the top; set the slopes to 0. Now every edge is 1 pixel thin.
4. Double threshold TH : TL = 2:1 or 3:1. M ≥ TH → strong; TL ≤ M < TH → weak; M < TL → discarded.
Two cut-off values. Above the high one = sure edge. Below the low one = sure NOT an edge. In between = "maybe". The high one is 2 to 3 times the low one.
5. Hysteresis: keep a weak pixel only if it is 8-connected to a strong pixel.
A "maybe" pixel survives only if it touches a "sure" pixel (in any of the 8 directions). Real edges are long lines, so a maybe next to a sure is part of it; a lonely maybe is just noise.
Why two thresholds: one high T loses real edges (false negatives); one low T keeps noise (false positives). Hysteresis keeps the weak pixels that continue a real edge, giving thin, continuous edges.
Only a high cut-off: faint parts of real edges disappear and leave gaps. Only a low cut-off: noise becomes edges. Two cut-offs + the touch rule keep faint parts that connect to strong ones and throw away lonely noise.
| 200 | 0 | 57 |
| 0 | 45 | 101 |
| 50 | 0 | 0 |
| 200 | 0 | 57 |
| 0 | 45 | 101 |
| 0 | 0 | 0 |
| c0 | c1 | c2 | |
|---|---|---|---|
| r0 | 200 ↓ | 40 ↓ | 57 ↙ |
| r1 | 10 → | 20 ↑ | 101 ← |
| r2 | 50 ↑ | 41 ↑ | 74 ← |
Given: magnitude M and gradient arrow at each pixel (F23 Q3(a)). TH = 100, TL = 45.
For each pixel, check the two neighbours in the arrow direction (forward and backward). Neighbours outside the 3×3 are ignored.
| pixel | M | arrow | neighbours along the arrow | result |
|---|---|---|---|---|
| (0,0) | 200 | ↓ | (1,0) = 10 (other side is outside) | kept |
| (0,1) | 40 | ↓ | (1,1) = 20 (other side is outside) | kept |
| (0,2) | 57 | ↙ | (1,1) = 20 (other side is outside) | kept |
| (1,0) | 10 | → | (1,1) = 20 (other side is outside) | smaller → 0 |
| (1,1) | 20 | ↑ | (0,1) = 40, (2,1) = 41 | smaller → 0 |
| (1,2) | 101 | ← | (1,1) = 20 (other side is outside) | kept |
| (2,0) | 50 | ↑ | (1,0) = 10 (other side is outside) | kept |
| (2,1) | 41 | ↑ | (1,1) = 20 (other side is outside) | kept |
| (2,2) | 74 | ← | (2,1) = 41 (other side is outside) | kept |
| 200 | 40 | 57 |
| 0 | 0 | 101 |
| 50 | 41 | 74 |
≥ 100 → strong. 45 to 99 → weak. Below 45 → 0 (so 40 and 41 are gone).
| 200 | 0 | 0 |
| 0 | 0 | 101 |
| 0 | 0 | 0 |
| 0 | 0 | 57 |
| 0 | 0 | 0 |
| 50 | 0 | 74 |
| weak pixel | value | strong 8-neighbours | decision |
|---|---|---|---|
| (0,2) | 57 | 101 at (1,2) | kept |
| (2,0) | 50 | none | dropped |
| (2,2) | 74 | 101 at (1,2) | kept |
| 200 | 0 | 57 |
| 0 | 0 | 101 |
| 0 | 0 | 74 |
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
(ii) 74 at (2,2) is weak but kept because it touches the strong 101. If it was really noise, it is a false positive. 50 at (2,0) is weak with no strong neighbour, so it is dropped. If it was a real edge, it is a false negative.
Name one pixel that might be a fake edge that got in, and one that might be a real edge that got thrown out.
(iii) With TH = 245 no pixel is strong, so hysteresis keeps nothing: the output is empty, every real edge is lost (false negatives). TL = 10 would let almost every pixel in as weak (false positives). The ratio 245:10 breaks the usual 2:1 to 3:1 rule.
Too high a top cut-off: nothing is "sure", so nothing survives. Too low a bottom cut-off: everything becomes a "maybe".
SP25: 50 ≤ 80 < 100, so the pixel is a weak edge. It becomes an edge only if it is 8-connected to a strong pixel; otherwise it is discarded.
80 is between the two cut-offs, so it is a "maybe".
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
False positive: a pixel marked as an edge that is not a real edge (e.g. noise). Caused by a threshold that is too low.
Fake edge drawn.
False negative: a real edge pixel that is missed. Caused by a threshold that is too high.
Real edge lost.
How Canny reduces them: Gaussian smoothing removes noise before the gradient (fewer false positives). NMS keeps only the local maxima, so thick edges become thin (fewer false positives).
Blur kills noise; NMS deletes the extra pixels around each edge.
Double threshold + hysteresis keeps a weak pixel only when it is connected to a strong edge: faint parts of real edges are kept (fewer false negatives) and isolated weak noise is dropped (fewer false positives).
The touch rule rescues faint real edges and throws away lonely noise.
| -1 | 0 | 1 |
| -2 | 0 | 2 |
| -1 | 0 | 1 |
| -1 | -2 | -1 |
| 0 | 0 | 0 |
| 1 | 2 | 1 |
| 3 | 7 | 6 |
| 2 | 5 | 8 |
| 3 | 4 | 7 |
Label the 3×3 window z1 … z9 row by row: z1 = 3, z2 = 7, z3 = 6, z4 = 2, z5 = 5, z6 = 8, z7 = 3, z8 = 4, z9 = 7.
Gx = (z3 + 2z6 + z9) − (z1 + 2z4 + z7) = (6 + 16 + 7) − (3 + 4 + 3) = 29 − 10 = 19
Gy = (z7 + 2z8 + z9) − (z1 + 2z2 + z3) = (3 + 8 + 7) − (3 + 14 + 6) = 18 − 23 = −5
|∇f| ≈ |Gx| + |Gy| = 19 + 5 = 24 (exact √(19² + 5²) = 19.65)
Gradient angle α = tan⁻¹(Gy/Gx) = tan⁻¹(−5/19) = -14.74°. The edge runs at right angles to the gradient: edge direction = α − 90° = -104.74°.
Window around (0,0), outside = 0: z1, z2, z3, z4, z7 = 0; z5 = 3, z6 = 7, z8 = 2, z9 = 5.
Gx = (0 + 2×7 + 5) − (0 + 0 + 0) = 19; Gy = (0 + 2×2 + 5) − (0 + 0 + 0) = 9; |∇f| = 19 + 9 = 28.
| 19 | 12 | -19 |
| 21 | 19 | -21 |
| 13 | 14 | -13 |
| 9 | 20 | 21 |
| -3 | -5 | -1 |
| -9 | -20 | -21 |
| 28 | 32 | 40 |
| 24 | 24 | 22 |
| 22 | 34 | 34 |
Patch [10 10 10; 10 50 10; 10 10 10]: Gx = (10 + 20 + 10) − (10 + 20 + 10) = 0 (Gy = 0 too). The left and right columns are equal and Sobel's centre weight is 0, so the dot is not seen. A Laplacian would give 4×50 − 4×10 = 160.
| -1 | -1 | -1 |
| 2 | 2 | 2 |
| -1 | -1 | -1 |
| -1 | -1 | 2 |
| -1 | 2 | -1 |
| 2 | -1 | -1 |
| -1 | 2 | -1 |
| -1 | 2 | -1 |
| -1 | 2 | -1 |
| 2 | -1 | -1 |
| -1 | 2 | -1 |
| -1 | -1 | 2 |
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
Draw the four masks above and label each.
The 2s show the line's direction.
The coefficients sum to 0, so a constant area gives 0; a line in the mask's direction gives the largest response.
Flat area: no answer. Line along the 2s: big answer.
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
(i) Draw the boxes above in a row with arrows, and write each box's formula under it.
The schematic is the 5 steps as boxes; the formulas earn the marks.
(ii) Hysteresis: gNH(x,y) = gN(x,y) ≥ TH; gNL(x,y) = gN(x,y) ≥ TL; then gNL = gNL − gNH.
Make a "strong" image and a "weak" image. Remove the strong pixels from the weak image so each pixel is in only one.
(a) Locate the next unvisited edge pixel p in gNH. (b) Mark as valid all weak pixels in gNL connected to p (8-connectivity). (c) Repeat until all pixels of gNH are visited. (d) Set to 0 all unmarked pixels of gNL.
Start at each strong pixel and follow touching weak pixels; every weak pixel you can reach stays, the rest are deleted.
Output = gNH + the marked pixels of gNL.
Final edges = strong ones + rescued weak ones.
Or NMS: round α to 0°, 45°, 90° or 135°; if M(x,y) is less than at least one of its two neighbours along that direction, gN(x,y) = 0, otherwise gN(x,y) = M(x,y).
Keep only the top of each edge "hill".
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
g(x,y) = 1 if f(x,y) > T (object point); 0 if f(x,y) ≤ T (background point).
Every pixel brighter than T becomes white (object); everything else becomes black (background).
Global: one T for the whole image, T = T[f(x,y)].
One cut-off number for the entire picture.
Local / regional: T = T[p(x,y), f(x,y)], p = a neighbourhood property such as its mean.
Each small area picks its own cut-off from its own pixels (e.g. its average brightness).
Adaptive (dynamic): T = T[x, y, p(x,y), f(x,y)].
The cut-off also changes with the position in the picture, so it can follow a shadow.
Iterative global threshold: (1) initial T = mean intensity;
Start with a guess: the average brightness.
(2) split: G₁ = pixels > T, G₂ = pixels ≤ T; (3) means μ₁, μ₂;
Split the pixels into a bright group and a dark group, and average each group.
(4) new T = ½(μ₁ + μ₂); (5) repeat until the change in T < ΔT.
The new cut-off is halfway between the two averages. Repeat until it stops moving.
Mini example (values 10, 20, 30, 200, 210, 220): T₀ = 690 / 6 = 115. G₁ = {200, 210, 220}, μ₁ = 210; G₂ = {10, 20, 30}, μ₂ = 20. T₁ = ½(210 + 20) = 115, no change → stop, T = 115.
Slide 14: seed = 60 at the centre, rule |difference| ≤ 5. Highlighted = the grown region.
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| 10 | 10 | 10 | 69 | 70 | 10 | 10 |
| 59 | 10 | 60 | 64 | 59 | 56 | 60 |
| 10 | 59 | 10 | 60 | 70 | 10 | 62 |
| 10 | 60 | 59 | 65 | 67 | 10 | 65 |
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| 10 | 10 | 10 | 69 | 70 | 10 | 10 |
| 59 | 10 | 60 | 64 | 59 | 56 | 60 |
| 10 | 59 | 10 | 60 | 70 | 10 | 62 |
| 10 | 60 | 59 | 65 | 67 | 10 | 65 |
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| 10 | 10 | 10 | 10 | 10 | 10 | 10 |
8-connectivity also steps diagonally, so the 59, 60, 59, 59 on the left join. The 10s never join: |10 − 60| = 50 > 5.
(a) 4-connectivity (up, down, left, right). Each new pixel is compared with the pixel it grows from:
| grows from | neighbour | test |
|---|---|---|
| (3,3) = 60 | (2,3) = 64 | |64 − 60| = 4 ≤ 5 ✓ |
| (3,3) = 60 | (4,3) = 65 | |65 − 60| = 5 ≤ 5 ✓ |
| (2,3) = 64 | (1,3) = 69 | |69 − 64| = 5 ≤ 5 ✓ |
| (2,3) = 64 | (2,2) = 60 | |60 − 64| = 4 ≤ 5 ✓ |
| (2,3) = 64 | (2,4) = 59 | |59 − 64| = 5 ≤ 5 ✓ |
| (4,3) = 65 | (4,4) = 67 | |67 − 65| = 2 ≤ 5 ✓ |
| (1,3) = 69 | (1,4) = 70 | |70 − 69| = 1 ≤ 5 ✓ |
| (2,4) = 59 | (2,5) = 56 | |56 − 59| = 3 ≤ 5 ✓ |
| (4,4) = 67 | (3,4) = 70 | |70 − 67| = 3 ≤ 5 ✓ |
| (2,5) = 56 | (2,6) = 60 | |60 − 56| = 4 ≤ 5 ✓ |
| (2,6) = 60 | (3,6) = 62 | |62 − 60| = 2 ≤ 5 ✓ |
| (3,6) = 62 | (4,6) = 65 | |65 − 62| = 3 ≤ 5 ✓ |
Region = seed + these 12 = 13 pixels. Every other neighbour is a 10: |10 − 60| = 50 > 5, so it can't join.
(b) 8-connectivity also checks diagonals. Everything above joins again, plus these:
| grows from | neighbour | test |
|---|---|---|
| (3,3) = 60 | (4,2) = 59 | |59 − 60| = 1 ≤ 5 ✓ |
| (2,2) = 60 | (3,1) = 59 | |59 − 60| = 1 ≤ 5 ✓ |
| (4,2) = 59 | (4,1) = 60 | |60 − 59| = 1 ≤ 5 ✓ |
| (3,1) = 59 | (2,0) = 59 | |59 − 59| = 0 ≤ 5 ✓ |
Region = 17 pixels.
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
| 15 | 15 | 15 | 68 | 69 | 15 | 15 |
| 64 | 64 | 63 | 67 | 70 | 68 | 15 |
| 15 | 15 | 70 | 65 | 61 | 71 | 66 |
| 15 | 15 | 69 | 73 | 58 | 15 | 15 |
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
| grows from | neighbour | test |
|---|---|---|
| (3,3) = 65 | (2,3) = 67 | |67 − 65| = 2 ≤ 4 ✓ |
| (3,3) = 65 | (3,4) = 61 | |61 − 65| = 4 ≤ 4 ✓ |
| (3,3) = 65 | (2,2) = 63 | |63 − 65| = 2 ≤ 4 ✓ |
| (3,3) = 65 | (4,2) = 69 | |69 − 65| = 4 ≤ 4 ✓ |
| (2,3) = 67 | (1,3) = 68 | |68 − 67| = 1 ≤ 4 ✓ |
| (2,3) = 67 | (2,4) = 70 | |70 − 67| = 3 ≤ 4 ✓ |
| (2,3) = 67 | (1,4) = 69 | |69 − 67| = 2 ≤ 4 ✓ |
| (2,3) = 67 | (3,2) = 70 | |70 − 67| = 3 ≤ 4 ✓ |
| (3,4) = 61 | (4,4) = 58 | |58 − 61| = 3 ≤ 4 ✓ |
| (2,2) = 63 | (2,1) = 64 | |64 − 63| = 1 ≤ 4 ✓ |
| (4,2) = 69 | (4,3) = 73 | |73 − 69| = 4 ≤ 4 ✓ |
| (2,4) = 70 | (2,5) = 68 | |68 − 70| = 2 ≤ 4 ✓ |
| (2,4) = 70 | (3,5) = 71 | |71 − 70| = 1 ≤ 4 ✓ |
| (2,1) = 64 | (2,0) = 64 | |64 − 64| = 0 ≤ 4 ✓ |
| (2,5) = 68 | (3,6) = 66 | |66 − 68| = 2 ≤ 4 ✓ |
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
| 15 | 15 | 15 | 68 | 69 | 15 | 15 |
| 64 | 64 | 63 | 67 | 70 | 68 | 15 |
| 15 | 15 | 70 | 65 | 61 | 71 | 66 |
| 15 | 15 | 69 | 73 | 58 | 15 | 15 |
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
| 15 | 15 | 15 | 15 | 15 | 15 | 15 |
All 16 non-15 pixels join, each through a chain of steps of 4 or less (e.g. 65 → 61 → 58). The 15s never join: the closest gap is |58 − 15| = 43 > 4.
Normal line = write it on the paper. Grey "means" line under it = what it means (do not write that).
Region growing groups pixels into larger regions, starting from seed points and appending neighbouring pixels with similar properties (gray level, texture, colour).
Start from one pixel you know is inside the object, and keep adding neighbours that look like it.
(1) Choose the seed(s).
Pick the starting pixel (the question usually gives it).
(2) A 4- or 8-neighbour joins if it satisfies the predicate, e.g. |f(neighbour) − f(pixel it grows from)| ≤ T.
Check the neighbours (4 = up/down/left/right, 8 = also the diagonals). A neighbour joins if its value is within T of the pixel next to it.
(3) Repeat with the new members.
Every new member checks its own neighbours, so the region spreads like a stain.
(4) Stop when no more pixels satisfy the predicate.
When no neighbour is close enough any more, you are done.
Works better than edge-based methods on noisy images. Problems: good seeds are hard to choose, hard to automate, needs a good similarity rule.
One plus point and three problems: easy marks.
With numbers: table "grows from | neighbour | test", e.g. (3,3)=60 → (2,3)=64: |64 − 60| = 4 ≤ 5 ✓; then the final grid and the pixel count.
Show every joining pixel as one row of the table, then draw the final region. 8-connectivity always gives an equal or bigger region than 4.
| the story says | write |
|---|---|
| "partition pixels depending on intensity" | thresholding, g = 1 if f > T |
| "group similar pixels", "tumor region from a point" | region growing from a seed, |diff| ≤ T |
| "uneven illumination", "shadow", "faded document" | adaptive / local threshold |
| "noisy image, need clean thin edges" | Canny (smooth first, then hysteresis) |
| "find boundaries of an organ / crack" | Sobel gradient or Canny |
| "straight lines: road, lane, fracture" | Hough: votes for lines in (ρ, θ), ρ = x cos θ + y sin θ |