Quiz: Legendre moments and reconstruction
Before this unit: Normalisation and moment invariants (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. Inner product on [-1, 1]: \langle g, h\rangle = \int_{-1}^1 g h\,dx; Legendre polynomials P_0 = 1, P_1 = x, P_2 = \tfrac12(3x^2 - 1).
Q1. Why are x and x^2 orthogonal on [-1, 1], but 1 and x^2 not?
Even times odd is odd.
x \cdot x^2 = x^3 is odd, so its integral over the symmetric interval is 0. 1 \cdot x^2 = x^2 is positive everywhere (except at 0): \int_{-1}^1 x^2\,dx = 2/3 \ne 0.
Q2. The cosine of the angle between x^8 and x^{10} on [-1, 1] is 0.994. What does that mean for the moments m_8 and m_{10} of a 1D signal, and for getting the signal back from them?
Two nearly parallel vectors measure almost the same component.
They are almost the same measurement: m_{10} adds very little information to m_8. To separate the contributions of x^8 and x^{10} to the signal, one has to take a small difference of two large, nearly equal numbers: rounding errors in the moments are amplified enormously (an ill-conditioned system).
Q3. The Gram matrix of the monomials up to degree 10 on [-1, 1] has condition number about 10^7. Roughly how many of the 16 significant digits of a double survive in the coefficients of the reconstruction?
About \log_{10}\kappa digits are lost.
About 7 digits are lost, so about 9 remain. At degree 20 (\kappa \approx 3 \times 10^{14}) only 1–2 remain: the reconstruction becomes noise.
Q4. Gram–Schmidt on 1, x, x^2: what do you subtract from x^2, and what is the result after scaling to the value 1 at x = 1?
x^2 is already orthogonal to x. Its component along 1 is its average over the interval.
Subtract the projection onto 1: \frac{\langle x^2, 1\rangle}{\langle 1, 1\rangle} = \frac{2/3}{2} = \frac13. Then x^2 - \frac13, scaled by \frac32: P_2 = \frac12(3x^2 - 1).
Q5. You have reconstructed an image from its Legendre moments up to N = 10, and now add order 11. Which coefficients must be recomputed? And with monomials?
Orthogonal projection: each coefficient is \langle I, b_k\rangle / \langle b_k, b_k\rangle.
Legendre: none; only the 12 new coefficients of order 11 are added. Each coefficient depends only on its own basis function. Monomials: all coefficients change, because the new monomials are not orthogonal to the old ones and the whole Gram system has to be solved again.
Q6. Legendre moments up to order N and geometric moments up to order N: which contains more information about the image?
Is P_p a combination of monomials of degree at most p, and conversely?
Neither: each set is a fixed invertible (triangular) linear transformation of the other. They differ in how well they are conditioned, not in information.
Q7. A 64 \times 64 image is rebuilt from its moments up to order 40 with Legendre polynomials sampled at the pixel centres. The error first falls with N, then rises again. Why, and what are two remedies?
Are the sampled polynomials orthogonal on the grid?
The integral is replaced by a sum over pixel centres, and the sampled P_n are only approximately orthogonal on the grid; the error grows with the order, so the “projection” is no longer a projection. Remedies: integrate each P_n over the pixel (exact for an image constant on each pixel), or use discrete orthogonal polynomials (Tchebichef), which are exactly orthogonal on the grid.
Q8. How many Legendre moments are there up to order 20, and what fraction of the pixels of a 128 \times 128 image is that?
(N+1)(N+2)/2.
21 \cdot 22/2 = 231; 231/16384 = 1.4\,\%.
Q9. (math) Show that \int_{-1}^1 P_2(x)^2\,dx = 2/5.
P_2^2 = \tfrac14(9x^4 - 6x^2 + 1).
\tfrac14\left(9 \cdot \tfrac25 - 6 \cdot \tfrac23 + 2\right) = \tfrac14\left(\tfrac{18}{5} - 4 + 2\right) = \tfrac14 \cdot \tfrac85 = \tfrac25, in agreement with \frac{2}{2n+1} for n = 2.