How to implement Fourier Descriptor of an image?

I want to implement Fourier Descriptor of an object. I have read link. However, I have some questions about normalizing Fourier Descriptor.

First, if I want to normalize the position of the starting point, according to the above link, This is done by subtracting the phase of the second Fourier descriptor $\phi_1$ from the phase of all Fourier descriptors and weighting by $k$; that is:

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

Is the weight $k$ equal to the $k$ in $a(k)$ ?

Second, how could I do in order to achieve rotational invariance when I implement Fourier descriptor ? Thank you very much for your reply.

Yes, these k are the same.

In the basic sense, the rotational invariance is obtained by only taking the magnitude of the descriptors. However, in practice this might lead to information loss and decreases discrimination power. For this reason it is typically prefered to augment the phase information with additional terms. There are many ways to do this but for a simple approach follow:

Invariant Fourier Descriptors Representation of Medieval Byzantine Neume Notation

• So if I want to normalize the FD I need to take the following step? 1) Set $a(0)=0$. 2) Divide all the Fourier descriptors with the magnitude of the second one. $a(1)=r_1e^{j\phi_1}$ $a(k)=\frac{a(k)}{\lVert a(1) \rVert}$ 3) Subtracting the phase of the second Fourier descriptor $\phi_1$ from the phase of all Fourier descriptors and weighting by $k$. $a(k)=a(k)e^{-j \phi_1 k}$ (4)implement rotational invariant: $a(k)=a(k)e^{-j \phi_1}$