Describing my background: I have around 33 items labeled. For example, 3 pictures of the contour of a basil plant, 4 pictures of the contour of earphones, 7 of a mug, etcetera.

I'm trying to calculate N Fourier descriptors of a random picture in order to compare them with the other items, making the average of the distances between classes and saying: "This is a mug!" or "this is a basil plant!".

In my experience, I take a random picture of a MUG:

enter image description here

it looks to my MUGS that I've classified (because it gives me a distance close to 0):

enter image description here

but if I take a picture of the MUG without the handle:

enter image description here

the closest averages of the norm of distances to this MUG are of BASIL plants or EARPHONES (instead MUG, which is boundary closer):

enter image description here enter image description here

indeed I have been realising that for every random picture I use to get a low value for earphones and basil. It seems that I have to normalize somewhere... but... what should I do ??

Do anybody could give me a clue?

Thank you very much in advance. Regards.

UPDATED In response to @tbirdal , I have to say that that's what I do:

vector<double> vector;
if (dft_z.size() < 2)
    return vector; // handling errors
dft_z.at(0) = complex<double>(0,0); // First DC to 0 (invariance on translation)
double si1 = abs(dft_z.at(1)); // Module of the a(1)
for(int i = 0; i < dft_z.size(); i++) {
    dft_z.at(i) = complex<double>(dft_z.at(i).real() / si1, dft_z.at(i).imag() / si1); // dividing by the module
    vector.push_back(abs(dft_z.at(i))); // and putting into my vector the absolute value (to eliminate any phase)


I've seen that making the absolute value of every FD to remove its phase makes confusion on my shapes. In addiction, I realised that only simple forms and contours are well matched. For example basil was too complicated, but the mug is not.

Thanks to @tbirdal who gives me an idea.

  • $\begingroup$ Honestly, the descriptors you are using are rather historic. In reality the Fourier basis is an inefficient basis to describe objects for numerous reasons, my favourite is that the Fourier transform occurs over the whole image domain, while features tend to be localized to some small area. The interplay of these features provides a much sparser description of your scene. $\endgroup$
    – Mikhail
    Jun 12 '15 at 23:06
  • $\begingroup$ How come you thank and never up vote? : ) $\endgroup$ Sep 10 '15 at 20:26
  • $\begingroup$ sorry @TolgaBirdal, it didn't work. But I'll vote you up because it's a good answer (theorically valid) $\endgroup$ Sep 11 '15 at 7:25

The normalization of the Fourier descriptors is performed as follows:

1) Set the DC component of the descriptors to $a(0)=0$.

2) Divide all the Fourier descriptors with the magnitude of the second one. i.e. :


$a(k)=\frac{a(k)}{\lVert a(1) \rVert}$

3) Now, only the position of the starting point remains to be normalized. This is done by subtracting the phase of the second Fourier descriptor $\phi_1$ frin the phase of all Fourier descriptors and weighting by $k$; that is:

$a(k)=a(k)e^{-j \phi_1 k}$

Note that I did not describe rotational invariance here. In simple terms it is achieved by taking the magnitude of each Fourier coefficient.

Also, you have to chain code your contours and represent them in complex space to perform the Fourier transformation (the ordering matters if you don't perform step (2) ).

Fourier descriptors are not necessarily robust. They are good if you have some control of environment (such as lighting and appearance etc. ), but I don't expect them to work on cases such as a missing handle.

  • $\begingroup$ The third point is the only one which I didn't do. $\endgroup$ Jan 12 '15 at 16:41
  • $\begingroup$ Sorry, I'm going to try to do it as soon as possible and I'll reply to you (and mark as correct if proceeds). Thanks! $\endgroup$ Jan 12 '15 at 16:42
  • $\begingroup$ Updated the answer. $\endgroup$ Jan 12 '15 at 16:44
  • $\begingroup$ Updated question @tbirdal ... I was doing that. I really know that if I don't have the handle, it will be different. But all objets that I try to match are close to the basil, which has more strange contour $\endgroup$ Jan 13 '15 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.