Full search page →

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?

Predict first

Three places are marked on the photograph: A, B and C. Which one is a corner, a point where shifting the window in any direction changes what it sees?

Hints

The chapter section that uses this lab:

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?

Predict first

Three places are marked on the photograph: A, B and C. Which one is a corner, a point where shifting the window in any direction changes what it sees?

Loading image…

Photograph with the probe window (yellow) and marks A, B, C. Click or drag to move the probe
The window magnified, with a gradient arrow in each pixel (orange)
Harris response R over the whole image (red: corner, blue: edge, white: flat)
One dot per window pixel: its gradient (Ix, Iy). The orange ellipse is the structure tensor
The two eigenvalues of this window (dot) among all windows of the image (grey)

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

Open in the Playground →