IP 12 · Probe a pixel: flat, edge or corner?
AdvancedIP 12 · Feature ExtractionImage lab
Description
Slide a small window over a real photograph and watch the window’s gradient vectors, its structure-tensor ellipse and the Harris response decide whether the spot is flat, an edge or a corner.
Try this: Place the probe on the three marked points with the sliders (A: x 200, y 20; B: x 80, y 52; C: x 30, y 80) and compare the dots: a tiny huddle at the origin, a cloud in two directions and a thin line. Then try the left tripod leg (x 122, y 232) and the right leg (x 183, y 220): the line turns, yet λ2/λ1 stays below 0.0025 for both, because both are edges. Finally raise the window from 9 to 25 pixels: the share of the image labelled corner grows from 1.4% to 8.9%. Why does a bigger window find more corners?
Explanation
Answer the prediction first, or open the explanation when you are ready.
Show the explanation
B is the corner: where the hair meets the dark coat against the sky, the gradients point in two directions. With the default 9-pixel window its tensor has λ1 = 1759 and λ2 = 360, both large. At C, a straight shoulder edge, all gradients point the same way: λ1 = 2206 but λ2 = 1.85, so only one direction changes. In the sky at A both eigenvalues are tiny (λ1 = 0.13). Eigenvalues are in squared gray levels per pixel.
Lab · IP 12 · Probe a pixel: flat, edge or corner?
Loading image…
Try this: Place the probe on the three marked points with the sliders (A: x 200, y 20; B: x 80, y 52; C: x 30, y 80) and compare the dots: a tiny huddle at the origin, a cloud in two directions and a thin line. Then try the left tripod leg (x 122, y 232) and the right leg (x 183, y 220): the line turns, yet λ2/λ1 stays below 0.0025 for both, because both are edges. Finally raise the window from 9 to 25 pixels: the share of the image labelled corner grows from 1.4% to 8.9%. Why does a bigger window find more corners?
Real photograph: skimage.data.camera at 256 × 256 (see the credit below). Gradients are Gaussian derivatives with σ = 1 pixel, as in the IP 12 code. The window is W × W pixels with Gaussian weights of σ = W/6, so W = 9 gives the chapter’s integration scale σ = 1.5 (the chapter code truncates the Gaussian at 4σ instead of at the box). M is the weighted sum of the outer products of the gradient vectors, R = det M − 0.05 · tr(M)². Gradients are in gray levels per pixel (0 to 255) and eigenvalues in their squares. The flat, edge and corner labels use a cutoff chosen for this lab, not part of Harris and Stephens: an eigenvalue counts as large when it is at least 5% of the largest λ1 anywhere in the image at that window size. The Harris detector proper keeps local maxima of R above a threshold. The heat map shows R divided by its image maximum, compressed by a square root: red positive, blue negative, white near zero.
Method and image sources
- Chris Harris and Mike Stephens, A Combined Corner and Edge Detector, Proceedings of the Alvey Vision Conference, 1988
- SciPy documentation, scipy.ndimage.gaussian_filter (Gaussian derivatives with reflected borders, as in the IP 12 code)
- scikit-image test images (skimage.data): camera is CC0 by Lav Varshney; coins is from the Brooklyn Museum collection, no known copyright restrictions; astronaut is a NASA photograph in the public domain