Fourier descriptors: trying to classify objects

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: it looks to my MUGS that I've classified (because it gives me a distance close to 0): but if I take a picture of the MUG without the handle: the closest averages of the norm of distances to this MUG are of BASIL plants or EARPHONES (instead MUG, which is boundary closer):  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)
}

HOW I'M GOING TO CONTINUE

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.

• 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. Jun 12 '15 at 23:06
• How come you thank and never up vote? : ) Sep 10 '15 at 20:26
• sorry @TolgaBirdal, it didn't work. But I'll vote you up because it's a good answer (theorically valid) 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(1)=r_1e^{j\phi_1}$

$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.

• The third point is the only one which I didn't do. Jan 12 '15 at 16:41
• 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! Jan 12 '15 at 16:42
• Updated the answer. Jan 12 '15 at 16:44
• 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 Jan 13 '15 at 10:13