Project 3: Fourier Harmonics

Manasi Datar


1. Overview

In this project we implement an invariant contour representation using Fourier Harmonics. Fourier harmonics allow a contour description that is invariant to translation, rotation and scale. Such a representation can be use to construct an co-ordinate frame for object recognition and provide a means to quantify how "different" one contour is, from another. The following sections describe the process of computing Fourier coefficients from a chain-code representation of a contour, followed by the method to reconstruct the contour from the coefficients. Finally, we describe a metric to differentiate different contours and end with conclusions and implementation details.

2. Fourier Harmonics and Invariance

The Fourier harmonics method describes a collection of coefficients which can be used to represent any closed contour using a group of superimposed ellipses. These coefficients can be computed ad infinitum along the positive and negative axes, and their use will result in a reconstruction that has 0-error. However, closed contours can be reconstructed faithfully using very few coefficients in practice.

The coefficients are complex numbers associated with every parameterized position on the closed contour. An intuitive interpretation would be to think of the coefficients as vectors in a real-imaginary co-ordinate frame, which describe a position on the contour as a sum of rotating vectors. The frequency of rotation corresponds to the degree of the coefficient - higher order coefficients rotate at increasingly faster frequencies.

Given the fact that the contours are composed of piece-wise linear segments, the solution from Kuhl & Giardina can be used to obtain a closed form solution using the slope of each segment in the contour and its length. Given the discrete sampling of the contour on a pixel grid, such a solution is valid and can be used to compute Fourier coefficients efficiently. The math was discussed vigourously in class, and I conciously omit the details here.

Reconstruction is comparatively trivial and often not required. However, it may be used to verify the sanity of our implementation. In practice, it is the coefficients that are used in applications involving such harmonics. Again, the math was described in great detail in class, and I conciously omit it from this report.
One thing to note during the reconstruction process is the interval of sampling while computing the contour. A sparse sampling may lead to broken contours, and hence I chose an interval of 0.01 for all reconstructions in this project. It actually may even have been an overkill !

We also make the coefficients invariant to translation, rotation and scaling in order to use them for comparison of the various contour pairs. As discussed in class, translation invariance is the easiest to obtain while rotational invariance requires a fair bit of computation. In this implementation, I have tried to ensure that the rotation invariance computation does not flip images accidently ! Given the elliptic components, scale invariance can be achieved by normalizing the semi-major axis.


4. Results

The following table displays the results of contour reconstruction using different number of coefficients. The input chain codes were same as those described in the project instructions.

Fourier Harmonics: Reconstruction

n=1n=10n=100n=1000

As discussed earlier, it is evident that the first few coefficients are sufficient to obtain a faithful reconstruction of the contour. An order of 10s of coefficients are sufficient to capture all the features in the original contour upto pixel scale. Antialiasing artifacts may arise on a different grid-size, but these can be eliminated by post-processing.

Fourier harmonics: Inavariant reconstructions

1st Order Contour
Invariant Contours

The above table displays reconstruction results after making the coefficients invariant to translation, rotation and scale. It is interesting to observe that the semi-major axis of the 1st order ellipse is the same in all cases, and also the starting point (I have tried to depict it as a yellow dot) !

Pairwise sum of square differences (SSD) is a measure of comparison for coefficients of different shapes. As shown in the table below, SSD is a fair measure of differentiation between various shapes. Intuitively, this represents the distance between the two pairs of coefficients represented as points in some higher-dimensional space. Even though I report the SSD values for pairs of contours described by 1000 coefficients, fewer coefficients will most likely result in a discrimination almost similar to this one.

SSD for n = 1000
*VaseHouseCatDuck
Vase*146.4114.5186.8
House146.4*205.3174.5
Cat114.5205.3*229.3
Duck186.8174.5229.3*

5. Conclusion

Fourier harmonics are a simple method to represent closed contours. In practice, only a few coefficients are required to obtain a faithful reconstruction and the accuracy is appreciable. Complicated shapes can be represented using as many coefficients as required, however this remains a heuristic.

However, invariance is obtained by an arbitrary process and can be a serious drawback.


7. Implementation Notes

Continuing my exploration of the VISPack library, I implemeted the above methods using C++ and VISPack image processing operations. The code can be compiled using CMake on multiple compilers.