Assignment 3
Assignment 3
Fourier Descriptors (FDs) can be used to describe the contour of an object (here, a character). The
description of the contour should be not only invariant to translation, scale, rotation and
parametrization (starting point) but also insensitive to small distortions of the contour. You can make
FDs invariant to position, scale, rotation and starting point by normalizing them in the following way:
| F (k ) |
N (k ) = for k= −n/2 −1, .., −2, −1, 2, 3, ..., n/2,
| F (1) |
where F(k) are the Fourier descriptors of the complex contour f=x+i*y (x and y are the n points of
the closed contour of the object). Note that the values k=0,1 are left out (why?). You can make the
N(k) insensitive to small distortions (=high frequencies) by using only the lower values of k (in this
assignment, k=[−4 −3 −2 −1 2 3 4]). The N(k) can be used as a feature vector to describe the contour
of an object. By calculating a "contour difference measure" between a feature vector N(k) and
reference feature vectors R(k) a classification can be done. To do this all the contours must be
resampled to the same length of N points (in this assignment, N=128) before calculating the FDs. A
"contour difference measure" between feature vectors can be calculated as the Euclidean distance:
2
diff_measure = ∑ N (k ) − R(k ) .
k
Load the binary images char_e and char_w (load char_e;) and display them (subplot, imshow).
% compute the feature vector (scale, rotation, and starting point invariant FDs)
Re=normFD(Fe,[−4 −3 −2 −1 2 3 4]); % only the lower values of k
Do the same for the character W. Compute the feature vector Rw, and display the resampled
contour.
Page 1 of 3
2. Matching with a scaled object
Change the scale for the character E and calculate the feature vector Se. Use the following code to
scale the image:
Compute the feature vector Se for the scaled character E. Display the resampled contour.
Calculate the value of the "contour difference measure" between the scaled character E and the
references for characters E and W.
Write down the values values of diff_e and diff_w and the feature vectors Se, Re, and Rw.
What is your decision regarding the character described by the feature vector Se? Is the character
an "E" or a "W"?
Compute the feature vector SRe for the scaled and rotated character E. Display the resampled
contour.
Find the value of the contour difference measure between the rotated and scaled character E and
the reference characters "E" and "W".
Write down your results for the difference and the feature vectors Sre, Re and Rw. What is your
decision regarding the character described by vector SRe? Is the character an "E" or a "W"?
Finally, translate the scaled and rotated character E. You can perform the translation by adding a Dx
and a Dy, respectively to each of the contour−points srxe and srye of the scaled and rotated E
(before resampling).
Page 2 of 3
srtxe=srxe +32; % translate 32 pixels in the x−direction
srtye=srye +15; % translate 15 pixels in the y−direction
Calculate the feature vector SRTe for the scaled, rotated, and translated character E. Display the
resampled contour.
Compute the contour difference measure between the rotated, scaled and translated "E" and the
reference images for characters "E" and "W".
Write down your results and the feature vectors SRTe, Re, and Rw.
What is your decision regarding the character described by the feature vector SRTe? Is it closer to a
"E" or to a "W"?
Page 3 of 3