%% Advanced Image Synthesis, Exercises Week 3

dim = 25;

% compute basis function coefficients
coeffs_legendre = projLegendre( dim-1, @signal);
coeffs_characteristic = projCharacteristic( dim, @signal);

% reconstruct signals
[f_legendre, x] = reconstLegendre( coeffs_legendre);
[f_characteristic, x] = reconstCharacteristic( coeffs_characteristic);

% plot result
f_signal = signal( x);
plot( x, f_signal, '-r', ...
      x, f_legendre, '-b', ...
      x, f_characteristic, '-.b');
legend( 'Original', 'Legendre', 'Characteristic');