Anda di halaman 1dari 3

Addis Ababa University

Department of Computer Science


Postgraduate Program
Digital Image Processing (COSC 6012)
Assignment 3: Fourier Descriptors (FDs) May 2019

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

1. Computing reference feature vectors

Load the binary images char_e and char_w (load char_e;) and display them (subplot, imshow).

Compute the feature vector Re for character E as follows:


(check the help for: perim_sort, resample, normFD)

[xe ye]=perim_sort(char_e); % extract contour points


xer=resample(xe,128,length(xe),2); % resample the contour to 128 points
yer=resample(ye,128,length(ye),2);
subplot(2,2,1); plot(yer,−xer); % plot the resampled contour

fe=xer+i*yer; % resampled complex contour


Fe=fft(fe,128); % Fourier descriptors

% 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:

s_e=imresize(char_e,1.6); % do char_e 1.6 times bigger


imshow(s_e); %display it

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.

You can use the following code:

diff_e=sum((Se−Re).*(Se−Re)); % difference between scaled character and reference for E


diff_w=sum((Se−Rw).*(Se−Rw)); % difference between scaled character and reference for 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"?

3. Matching with a scaled and rotated object

Next, create a rotated version of the scaled character E:

sr_e=imrotate(s_e,90); % rotate 90 degrees


imshow(sr_e); % display it

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"?

4. Invariance with respect to translation

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

Anda mungkin juga menyukai