Quiz: rectangle features
Before this unit: Box filters & local statistics (previous unit); Day 1: Images, filters and frequencies.
See also: Localised basis functions and the Haar transform (day 7); Day 3: Bit depth and noise; Day 12: Thresholding; Day 33: Random forests; Day 7: Wavelets.
Short questions to test your understanding. Try each on paper first, then open the answer.
Q1. A two-rectangle feature (left − right) is placed on a flat region of grey level 120. What is its response? And on a region that is 120 on the left and 80 on the right, with rectangles of 10 \times 10 pixels?
Flat: 100 \cdot 120 - 100 \cdot 120 = 0. Edge: 100 \cdot 120 - 100 \cdot 80 = 4000 (a mean difference of 40 grey levels).
Q2. Two rectangle sums cost 4 lookups each. Why does the two-rectangle feature need only 6?
The two rectangles share a side, so two of their corners are the same table entries. Their coefficients are added (giving \pm 2) and each shared entry is read once: 8 - 2 = 6.
Q3. Which template would you use to find (a) a thin bright vertical line, (b) a horizontal edge, (c) a round dark spot of about 10 pixels?
- The three-rectangle line template across, with the centre rectangle about as wide as the line (positive response). (b) The two-rectangle edge template top − bottom. (c) Centre − surround with a centre box of about 10 pixels: a strongly negative response (the centre is darker than its surroundings).
Q4. Why is the feature response divided by the standard deviation of the detection window?
To remove the effect of contrast (lighting, camera gain): with twice the contrast every difference doubles, and so does the SD. Dividing makes the response the same. A brightness offset needs no correction, because the weights of every template sum to zero.
Q5. A 24 \times 24 window holds about 160 000 rectangle features but only 576 pixels. Is the feature set a basis? Does that matter for detection?
No: the features are far more numerous than the pixels, so they are linearly dependent (overcomplete), and the image cannot be uniquely rebuilt from them in a stable way. For detection that does not matter: the aim is to discriminate faces from background, not to reconstruct. The redundancy offers many candidate features; learning picks the useful few.
Q6. How do the 2D Haar wavelets differ from Haar-like features?
Haar wavelets use only dyadic sizes (powers of two) at fixed grid positions and form an orthonormal basis (the transform is invertible, useful for compression). Haar-like features take every size and position: an overcomplete set, with no inverse, for detection.
Q7. In a box feature stack, why does the box SD at 16 px cost the same as at 1 px?
Both come from four lookups in the table of I and four in the table of I^2, whatever the window size. Computed directly, the 16 px box (33 \times 33, 1089 pixels) would read 121 times as many pixels per window as the 1 px box (3 \times 3, 9 pixels).
Q8. (math) An edge feature of two w \times h rectangles (left − right) lies on the ramp I(x, y) = 3x + 40. What is its response divided by the area of one rectangle?
The response is -a w^2 h = -3w^2h; divided by wh: -3w, the slope times the distance w between the centres of the two rectangles.