# Question about harmonic calculations and other functionals for image analysis

I am implementing a method known as trace transform for image analysis. The algorithm extracts a lot of features of an image (in my case features pertained to texture) using a set of transforms on the values of the pixels. Here is a paper describing the algorithm: (PDF link).

The algorithm finally constructs a "triple feature" which is a number that characterizes the image and was calculated by applying a first set of transforms on the pixel values extracted by all the tracing lines going through the image at all angles. On the paper you can see this description starting on page 2, Figure 1 shows an abstraction of such a tracing line which is defined by its angle (phi) and the distance (d) of the line from the center of the image. So we can describe each tracing line by the pair (phi,d).

Now on the next page on the paper (page 3) we have Table 1 which is the set of functionals that is applied to the pixel values extracted by the tracing lines. Each of these functionals applied to all the tracing lines generates another representation of the image. Then another set of functionals (those that appear on Table 2 on page 4) are applied to the new representation of the image along the columns which is basically along parameter d generating, this way, another new representation of the image.

Finally another set of functionals is applied to this last representation which is an array of values over parameter phi which was the angle parameter (that means we have 360 values describing the image, one for each angle of the tracing lines). You can see these functionals in the paper on Table 3 page 4.

Now some of this last set of functionals that have to be applied to the last representation of the image over parameter phi need to calculate the harmonics of this set of 360 values. First I need to calculate the first harmonic and then the amplitude and phase of the first through fourth harmonic but I don't know how to do this.

You can read the first couple of pages of the paper since it's probably better explained there. And figure 1 makes it clear what I mean by tracing lines and the representation of each line by the (phi,d) pair.

Other functionals I have trouble with since I don't know if I'm understanding them correctly are:

$$\text{c so that:}\sum_{i=1}^cx_i=\sum_c^Nx_i.$$

where $x_i$ is one of the values and $N$ is the total number of values.

So my doubt is with what the result should be. The source (the paper listed above) has nothing else to contextualize this functional that's all it says so I'm interpreting that the result is $c$ rather than the sum of $x_i$ until $c$ right?

So let's say I have this set of numbers {2 2 3 1} where each number is one value $x_i$

So the above functional will tell me $c=2$ but the result of the sum is 4. So which should I take as the result in this case given the above functional?

The other functionals I'm having trouble with are related to the calculation of harmonics based on the dataset extracted from the image:

$$\text{i so that } x_i=\min_{i=1 \ldots N}x_i\text{ without the first Harmonic}$$ $$\text{i so that } x_i=\max_{i=1 \ldots N} x_i\text{ without the first Harmonic}$$ $$\text{Amplitud of the first Harmonic}$$ $$\text{Phase of the first Harmonic}$$

all the way to

$$\text{Amplitud of the fourth Harmonic}$$ $$\text{Phase of the fourth Harmonic}$$

I really don't know how to calculate a Harmonic or the amplitude or phase of it for the values. If someone more knowledgeable than me on image analysis can look into the paper linked above and provide me some tips I'll be greatly appreciated.

Perhaps looking at this paper 1 would be appropriate for a literature survey.

The paper describes in detail the rules of constructing functionals for a Trace transform. The functionals described in your paper are merely examples of the functions which follow the rules presented in paper 1.

I managed to calculate the amplitude and phase of the harmonics for the values representing the image.

I don't know if it's correct but I did it by following what's on this link:

http://clivac.eri.ucsb.edu/harmonic_analysis.htm

Which is based on what is written in the book Statistical Methods in the Atmospheric Sciences by Daniel S. Wilks

So if I take my 360 values that represent an image as a time series of a periodic function then I can calculate the amplitude and phase of the harmonics this way:

$$A_k=2/n\sum_{t=1}^ny_t \cos(2\pi kt/n)$$

$$B_k=2/n\sum_{t=1}^ny_t\sin(2\pi kt/n)$$

Where $k$ is the number of the harmonic for example the first harmonic is $k=1$ while the second is $k=2$. $n$ is the total number of values of the time series, in my case 360. $y_t$ is the value of the periodic function at time $t$ of the time series.

Now to calculate the amplitude of the harmonic I do

$$C_k=(A_k^2+B_k^2)^{1/2}$$

$C_k$ is the amplitude of the harmonic k

Then the phase of the harmonic is:

$$\tan^{-1}(B_k/A_k) \text{ if } A_k>0$$

$$\tan^{-1}(B_k/A_k)+\pi \text{ if } A_k<0$$

$$\pi/2 \text{ if } A_k=0$$

So I now have the amplitude and phase of the harmonics but I still haven't figured out what to do in this functionals

$$\text{i so that } x_i=\min_{i=1 \ldots N}x_i\text{ without the first Harmonic}$$ $$\text{i so that } x_i=\max_{i=1 \ldots N} x_i\text{ without the first Harmonic}$$

According to the link I can get the first harmonic using this equation

$$\bar{y}+A_k\cos(2\pi kt/n)+B_k\sin(2\pi kt/n)$$

Where $\bar{y}$ is the mean of the values, $k=1$ (because it's the first harmonic) and $t$, in this case should be the time $t$ of the highest value of the periodic series if I'm not mistaken. But I still don't know how to pick up the index of the maximum value of the minimum value of the series without the first harmonic. I'm not sure what it means.