Quiz: normalisation and moment invariants
Before this unit: Moments as projections onto monomials (previous unit); Day 14: Labelling.
See also: Day 33: Random forests.
Short questions to test your understanding. Try each on paper first, then open the answer. \mu_{pq}: central moments; \eta_{pq} = \mu_{pq}/\mu_{00}^{1 + (p+q)/2}; complex moments c_{pq} = \sum (x + iy)^p (x - iy)^q I in central coordinates with y up; Hu’s \phi_1, \dots, \phi_7.
Q1. An object is moved 10 pixels to the right. Which change: m_{10}, m_{20}, \mu_{20}, \eta_{30}?
Which of them measure positions from the centroid?
m_{10} and m_{20} change (they measure from the image origin). \mu_{20} and \eta_{30} do not: central moments measure from the centroid, which moves with the object.
Q2. An object is enlarged by a factor 2. By what factor do \mu_{00}, \mu_{20} and \mu_{30} change? And \eta_{30}?
\mu'_{pq} = s^{p+q+2}\mu_{pq}.
\mu_{00}: 2^2 = 4; \mu_{20}: 2^4 = 16; \mu_{30}: 2^5 = 32. \eta_{30} = \mu_{30}/\mu_{00}^{5/2} changes by 32/4^{5/2} = 32/32 = 1: not at all.
Q3. Why is \phi_1 = \eta_{20} + \eta_{02} unchanged by a rotation, while \eta_{20} alone changes?
What is \eta_{20} + \eta_{02} in terms of the matrix S?
It is the trace of the second-moment matrix (divided by \mu_{00}^2), i.e. the sum of its eigenvalues. A rotation turns the eigenvectors but keeps the eigenvalues. \eta_{20} alone is the spread along the x-axis, which depends on how the object is turned.
Q4. Of all shapes, the disc has the smallest \phi_1, namely 1/(2\pi) \approx 0.159. A square has 1/6. Without computing: is \phi_1 of a long thin rod larger or smaller than both?
\phi_1 is the mean squared distance from the centroid, divided by the area.
Larger. For a fixed area, a rod has much of its mass far from the centroid, so its mean squared distance (relative to the area) is large. The disc packs the mass as close as possible: that is why it has the minimum.
Q5. The object is rotated by 30° counter-clockwise. By how many degrees does the arrow of c_{30} turn? Of c_{12}? Of c_{11}?
c_{pq} \to e^{i(p-q)\alpha} c_{pq}.
c_{30}: 3 \cdot 30° = 90°. c_{12}: (1 - 2) \cdot 30° = -30° (backwards). c_{11}: 0°, it never turns.
Q6. A shape has 3-fold rotational symmetry (it looks the same after a turn of 120°). Show that c_{20} = 0.
Rotating by 120° gives the same image, so the same c_{20}.
Rotation by 120° multiplies c_{20} by e^{2i \cdot 120°} = e^{i \cdot 240°} \ne 1. But the image, and so c_{20}, is unchanged. The only number with c = e^{i240°} c is c = 0. (So \phi_2 = 0, and the orientation from the second moments is undefined.)
Q7. You classify the letters b, d, p and q with Hu’s invariants \phi_1, \dots, \phi_6. Which letters can you not tell apart? What changes if you add \phi_7?
Which pairs are rotations of each other, which are mirror images?
b rotated by 180° is q; d rotated by 180° is p; b and d are mirror images. \phi_1 \dots \phi_6 are invariant under rotation and reflection, so all four look the same (up to font details). \phi_7 changes sign under reflection: it separates {b, q} from {d, p}, but not b from q.
Q8. Why are Hu’s invariants usually compared as -\operatorname{sign}(\phi)\log_{10}|\phi|?
Typical values: \phi_1 \approx 0.27, \phi_5 \approx -5 \times 10^{-7}.
They span many orders of magnitude (higher invariants are products of many small \eta’s). In a distance between feature vectors, \phi_1 would dominate and \phi_5 would not count at all. The log makes them comparable (0.58 and −6.27 here); the sign is kept because some invariants can be negative.
Q9. Pose normalisation rotates the major axis of the object onto the x-axis. Name two shapes for which this fails, and say why.
The major axis is the eigenvector of S with the larger eigenvalue.
A disc, a square, a regular hexagon, a plus sign, a 3-pointed star: all have \lambda_1 = \lambda_2, so every direction is a principal axis and the angle is undefined (and for nearly round objects, it is dominated by noise). A rectangle has a major axis but \mu_{30} = 0: the 180° ambiguity cannot be fixed by \mu_{30}.
Q10. (math) Show that c_{20} = \mu_{20} - \mu_{02} + 2i\mu_{11} and c_{11} = \mu_{20} + \mu_{02}.
Expand (x + iy)^2 and (x + iy)(x - iy).
(x + iy)^2 = x^2 - y^2 + 2ixy; summing with weights I in central coordinates: \mu_{20} - \mu_{02} + 2i\mu_{11}. (x + iy)(x - iy) = x^2 + y^2, giving \mu_{20} + \mu_{02}. With \eta instead of \mu: |c_{20}|^2 = (\eta_{20} - \eta_{02})^2 + 4\eta_{11}^2 = \phi_2 and c_{11} = \phi_1.