# F06 Splines Aliasing And Principal Components

In this assignment you are to reconstruct an object using splines with different control point sampling distances and to compare and explain the results. You are also to generate principal components from the spline control points of a number of cases and to explain what you see in the first two principal directions.

Download this Matlab code. The script drawFace.m will produce a face profile (a 1D curve in 2D) that has been equally sampled along a parameter theta in the range 0 to 2pi. There are 512 samples equally spaced with theta = (0:511)*2*pi/512. For each of the following five means of reconstructing this profile, you are to compute and display 512 samples equally spaced at theta = ((0:511)+0.5)*2*pi/512, i.e., exactly between the input sample parameter values.

The five ways of reconstructing the profile will involve evaluating a B-spline fit to the data, where the data serve as the control points. In the first way, use every original sample as a control point. In the second way of reconstruction, use only the data corresponding to even multiples of 2*pi/512, i.e., using every other sample as a control point (but still displaying at the original sampling rate, with offset). In the third way of reconstruction, do the same, but use every fourth sample as a control point. In the fourth way of reconstruction, do the same, but use every eighth sample as a control point. In the fifth way of reconstruction, do the same, but use every sixteenth sample as a control point (so there will be only 32 control points).

Compute the Fourier transforms of the five reconstructed objects (with 512 values). Plot the amplitude of each FFT, and for each compute the sampling you would choose on the basis of epsilon = 0.01 (1% relative error due to folding; “relative” means value at chosen frequency divided by value at zero frequency. Mark your chosen sampling frequency on your plots, and compare the spatial sampling interval to the control point sampling interval used for the respective inputs.

Now for fun with the PCA!

Using the control points from the 1/16 sampling (32 control points), manually modify the control points to lengthen or shorten the nose and beard, in different combinations of amounts, to produce 12 faces. Display these twelve faces using your spline reconstruction. Using computePC12.m, do principal component analysis on the sets of spline control points. Display (after spline reconstruction at 512-point sampling) the mean face and the mean +- 2 std deviations in the first principal direction, the mean +- 2 std deviations in the second principal direction, and the mean +- sqrt(2) std deviations in the first principal direction +- sqrt(2) std deviations in the second principal direction. This will produce 9 faces. Comment on how the principal directions are related to how your input faces differed.

Your writeup should include:

- The original object and the five reconstructions, each displayed as a set of 512 points, with adjacent points optionally connected by line segments. On each reconstruction plot also plot, in a different color or style, the sample points used in that sample spacing, and in yet a different color or style, the sample points that would be used (round the generated sample indices to an integer) if the spacing given by meeting aliasing criteria were used.
- The magnitude plot of the Fourier transform of each object, with your chosen sampling frequency marked on it.
- Discussions of the relative quality of the reconstructions, the effect of sampling, and relative values of the sampling and the sampling recommended by aliasing considerations.
- The twelve training faces for the PCA, the nine sample faces from the principal components analysis, and a discussion of how the principal directions are related to the training faces.