Exam card
- Edge = a significant local intensity change, usually on a region boundary. Edge pixels change abruptly; an edge = connected edge pixels. Causes: object/surface boundaries (geometric), and specularity, shadows, inter-reflections (non-geometric).
- Gradient ∇I = [Ix, Iy] · G = √(Ix²+Iy²) · θ = tan⁻¹(Iy/Ix). The edge runs ⟂ to the gradient. Ix = Iy = 50 gives G ≈ 70.7, θ = 45°, edge at 135°.
- Differences: forward · backward · central. Derivative in one direction + smoothing in the other: Prewitt [−1 0 1]×[1 1 1]ᵀ · Sobel ×[1 2 1]ᵀ. Threshold T → binary edge map (manual, histogram, percentile, Otsu, adaptive).
- Laplacian ∇²I = Ixx+Iyy, 4-nbr [0 1 0; 1 −4 1; 0 1 0]. Edge at a zero crossing: L₁L₂ < 0 and |L₁−L₂| ≥ T. Noise-sensitive, no orientation.
- LoG (Marr–Hildreth) = ∇²(Gσ ∗ I): smooth → Laplacian → zero crossings → threshold.
- Canny: Gaussian → Sobel gradient (M, θ) → non-maximum suppression → double threshold (TL, TH) → hysteresis (keep weak only if connected to strong).
Key diagram
Key terms
What this topic covers
- What is an edge, and what causes one?
- The gradient
- From derivatives to filters: Prewitt and Sobel
- Second derivative: the Laplacian
- Laplacian of Gaussian (LoG, the Marr–Hildreth operator)
- Canny edge detector
Deep summary
Everything here follows the Topic 5 slides; each part shows its slide numbers. Parts marked added are study aids we wrote, not lecture content.
1 · An edge is a jump in a row of pixels Topic 5 · slides 3–9
Slide 3: edges are significant local changes of intensity, usually on the boundary between two regions. Slides 4–5 draw one image row as a graph: flat stretches are regions, sudden jumps are edges.
Slide 8 separates three words: an edge pixel is where the intensity changes abruptly; an edge is a set of connected edge pixels; an edge detector finds edge pixels. The goal (slide 6) is a line drawing of the scene, from which corners, lines and curves are taken for recognition and segmentation.
In the toy row, the step from 20 to 180 gives a difference of 160; the small wobble 20 → 22 gives only 2. Slide 7 shows the same idea on a photo: several detectors, several line drawings.
2 · Derivatives of the three slide-12 pictures Topic 5 · slides 10–12, 15
Slides 10–11: treat the image as a function I(x, y): ℝ² → ℝ. Its rate of change is the first derivative, taken in both directions: Ix = ∂I/∂x and Iy = ∂I/∂y.
Slide 12 asks for the derivatives of three pictures. Uniform black: nothing changes, so both are 0. Ramp: each step right adds 50, so Ix = 50 everywhere (constant, no single edge) and Iy = 0. White box: zero inside and outside, +255 entering the box and −255 leaving it; along the top and bottom sides Iy does the same.
added The rows of numbers and the forward difference I(x+1) − I(x) (slide 15) are ours; the slide shows only the three pictures.
3 · Gradient magnitude and direction: slide 14 worked Topic 5 · slides 13–14
Slide 13 stacks the two derivatives into the gradient ∇I = [Ix, Iy], with magnitude G = √(Ix² + Iy²) and direction θ = tan⁻¹(Iy/Ix).
Slide 14 worked: Ix = Iy = 50. ① G = √(2500 + 2500) = √5000 ≈ 70.7. ② The direction of maximum increase is θ = tan⁻¹(50/50) = tan⁻¹(1) = 45°. ③ The edge runs perpendicular to that: 45° + 90° = 135° (the same line as −45°).
The gradient points from dark to bright, across the edge; the edge line runs along the boundary.
4 · From differences to Prewitt and Sobel, then a threshold Topic 5 · slides 15–22
Slide 15: an image has only whole-pixel samples, so the derivative is approximated by a forward, backward or central difference. On the row 10 20 40 70 at x (value 40) they give 30, 20 and 25.
Slide 16: differences amplify noise, so take the derivative in one direction and smooth in the perpendicular direction. Slide 17: Prewitt = [−1 0 1] across × [1 1 1]ᵀ down; Sobel = the same × weighted [1 2 1]ᵀ. On the patch, Prewitt sums the three row differences 40 + 40 + 80 = 160; Sobel doubles the middle one: 200.
Slide 18: threshold the magnitude into a binary map, E[i, j] = 1 if G[i, j] ≥ T, else 0. Slide 22 lists ways to choose T: manual, histogram analysis, percentile, Otsu, adaptive. added T = 150 and the patch are our example; slides 19–21 show the two operators on a photo.
5 · Laplacian: zero crossings, the threshold, and LoG Topic 5 · slides 23–29
Slide 23: the second derivative measures how the rate of change changes, ∇²I = ∂²I/∂x² + ∂²I/∂y². Slide 24’s approximation Ixx = I[i, j+1] − 2I[i, j] + I[i, j−1] (and Iyy the same way down) gives the 4-neighbour mask.
On a clean step the response goes 0, 80, −80, 0: the edge sits at the zero crossing between 80 and −80. Slide 25 marks it only if L₁L₂ < 0 and |L₁ − L₂| ≥ T: here −6400 < 0 and 160 ≥ 100. A noise bump of 4 also flips sign (4, −8, 4) but its jump of 12 fails the threshold.
Slide 28: the Laplacian is noise-sensitive and a scalar, so it gives no edge orientation. Slide 29’s LoG = ∇²(Gσ ∗ I) (Marr–Hildreth) smooths first, then: Laplacian → significant zero crossings → threshold. added Smoothing with [1 2 1]/4 (the 1-D row of Topic 4’s Gaussian) turns the bump into 10 11 12 11 10, and the crossings vanish.
6 · Canny steps 1–2 on a small image: smooth, then gradient Topic 5 · slides 30–32 · Topic 4 · slide 29
Slide 30: Sobel gives thick, noise-prone edges and the Laplacian spurious zero crossings; Canny aims for clear, thin, connected edges. Slide 31 lists five steps; here are steps 1–2 on a small image: a vertical edge that fades from 10|90 at the top to 10|60 at the bottom, plus one noise pixel (70).
Step 1 (slide 32): Is = Gσ ∗ I with the 3 × 3 Gaussian from Topic 4 slide 29, H = 1/16 [1 2 1; 2 4 2; 1 2 1]. The noise pixel drops from 70 to 25.
Step 2: Gx = Sx ∗ Is, Gy = Sy ∗ Is with the Sobel masks, then M and θ. The box shows every number for the highlighted pixel. The edge is now a 3-pixel-wide ridge in M (124, 211, 150 in row 2).
added Border pixels copy their nearest neighbour, and masks are laid on the image without flipping; the slides don’t specify either. Values are rounded for display.
7 · Canny steps 3–5: thin, classify, connect Topic 5 · slides 33–36
Step 3 · non-maximum suppression (slide 33): for each pixel, find the gradient direction and compare M with the two neighbours approximately along it; keep it only if it is the local maximum. Row 2 has θ ≈ −9.5°, so compare left and right: 124 < 211 > 150. Only 211 survives; the ridge becomes one pixel wide.
Step 4 · double threshold (slide 34): M ≥ TH = 180 is strong (238, 230, 211, 185); TL = 30 ≤ M < TH is weak (164, and the noise leftovers 40, 45, 40); M < TL is rejected (23, 27, 19 …).
Step 5 · hysteresis (slide 35): strong pixels are accepted; a weak pixel is accepted only if connected to a strong one. 164 touches 185, so the faint bottom of the edge survives; the noise leftovers touch nothing strong and go. Slide 36 shows the result on a photo. added TL, TH and “connected” = the 8 surrounding pixels are our choices.
8 · Exam traps Topic 5 · slides 13–14, 17, 25, 28, 31–35 added
- Edge orientation is not θ: θ is the gradient (maximum increase); the edge is perpendicular, θ + 90° (slides 13–14).
- Prewitt vs Sobel differ only in the smoothing vector, [1 1 1]ᵀ vs [1 2 1]ᵀ; the derivative part [−1 0 1] is the same (slide 17).
- A sign change alone is not an edge: a zero crossing needs L₁L₂ < 0 and |L₁ − L₂| ≥ T (slide 25).
- The Laplacian gives no orientation: it is a scalar (slide 28). Gradient methods give θ.
- Canny order: smooth → gradient → non-max suppression → double threshold → hysteresis (slide 31). Thinning comes before thresholding.
- Weak ≠ rejected: a weak pixel survives if it is connected to a strong one (slide 35).
9 · Quick check Topic 5 · slides 13, 25, 34–35 added
Q1. A pixel has Ix = 0 and Iy = 80. Give G, θ and the edge orientation.
Q2. Neighbouring Laplacian responses are 30 and −10, with T = 50. Is there an edge?
Q3. Canny with TL = 50, TH = 150: a pixel with M = 100 sits next to a pixel with M = 200. What happens to it?
Exam questions · 15 Practise these 15
Q1What is an edge? List the causes of edges in an image.
Q2An edge pixel has Ix = 50 and Iy = 50. Find G, the direction of maximum increase, and the local edge orientation.
Q3Explain the Prewitt and Sobel operators and how a binary edge map is produced.
Q4How does the Laplacian detect edges? What are its drawbacks, and how does LoG address them?
Q5Describe the five steps of the Canny edge detector and why it is needed.
Q6Calculate · An edge pixel has Ix = 30 and Iy = 40. Find the gradient magnitude G, the direction of maximum increase θ, and the local edge orientation.
Q7Classify · Classify the cause of each edge as geometric (object or surface boundary) or non-geometric (specularity, shadow, inter-reflection): (a) a mug against the wall behind it (b) where a table top meets its side (c) a bright shine on a car bonnet (d) a tree’s shadow on a road (e) a red wall casting reddish light onto a white floor.
Q8Calculate · Apply the Sobel masks to the 3 × 3 patch [20 20 20; 20 20 20; 80 80 80]. Find Gx, Gy, G and say which way the edge runs.
Q9Compare · Compute Gx for the patch [10 10 70; 10 10 70; 10 10 10] with Prewitt and with Sobel, and explain where the difference comes from.
Q10Apply · Gradient magnitudes along a row are 12, 45, 160, 210, 90, 20. Write the binary edge map for T = 100 and for T = 50, and say what lowering T does.
Q11Calculate · Apply the 4-neighbour Laplacian to the centre of [10 20 10; 30 50 30; 10 20 10]. Its neighbour’s response is L₂ = 60. With T = 100, is there an edge between them?
Q12Explain · Explain why Prewitt and Sobel smooth in the direction perpendicular to the derivative. Use three rows whose right − left differences are 40, 70 (noise +30) and 40.
Q13Match · Match each situation to the threshold-selection method from the slides: (a) the lighting and noise vary across the image (b) the magnitude histogram has two clear groups (c) you want to keep the strongest 10 % of responses (d) a quick one-off image you can inspect (e) you study the magnitude distribution to find a value separating weak from strong.
Q14Apply · After Canny step 2, five pixels across an edge (along the gradient direction) have M = 60, 150, 220, 180, 70. Apply non-maximum suppression. What is left, and why is this step needed?
Q15Outline · Outline Canny steps 4 and 5 on this chain of neighbouring pixels after NMS: M = 170, 120, 90, 0, 80, 60, with TL = 50 and TH = 150.
Quick MCQs · 14 MCQs in Practise
Not the exam format: quick checks that you understood the topic. Choose 1 or all that apply, then Check.