3
$\begingroup$

I've been working much with numpy.fft lately where just like the documentation says:

When the input a is a time-domain signal and A = fft(a), np.abs(A) is its amplitude spectrum and np.abs(A)**2 is its power spectrum. The phase spectrum is obtained by np.angle(A).

Then I took a look at DCT, but I could not figure out how to derive the phase from the results, because only real values are contained, so the np.angle() will be $0$. From the FFT results I can take out interesting elements, calculate amplitude, phase and plot them as cosines:

[A*np.cos(2*np.pi*f*t + ph) for t in range(N)]

where A is the amplitude, f is the frequency, ph is the phase-shift and t is the variable, i.e. time. So my question is: can the same be derived from DCT results and how?

$\endgroup$
3
  • $\begingroup$ Delta = p1 ~p2 - (p<--i -1) In same place $\endgroup$
    – hassani
    May 7, 2017 at 18:32
  • $\begingroup$ @hassani What exactly are trying to suggest here? Please explain what you wrote. $\endgroup$
    – mac13k
    May 8, 2017 at 20:47
  • $\begingroup$ @hassani Sounds cryptic $\endgroup$ May 8, 2017 at 21:23

2 Answers 2

4
$\begingroup$

A DCT is equivalent to a DFT of real data that is doubled and mirrored, thus rendering it symmetric. The DFT of any symmetric real signal has a phase of zero (its all cosines, no antisymmetric sine components).

$\endgroup$
2
  • $\begingroup$ Does this mean that DCT assumes that all cosines start at (0, Ak) where Ak is the component's amplitude? $\endgroup$
    – mac13k
    May 7, 2017 at 18:38
  • $\begingroup$ Only cosine that starts at 0 with a phase of 0 (or Pi) is symmetric around 0. $\endgroup$
    – hotpaw2
    Sep 6, 2017 at 20:50
4
$\begingroup$

Not really, as the transform is real. However, one could interpret the sign as a poor man's phase, being "quantized" or restricted to values $0$ or $\pi$. In other words, $1 = 1.e^{0.\imath}$ and $-1 = 1.e^{\pi.\imath}$.

[EDIT] There are some instances where people use the sign of DCT or (real) wavelet coefficients, for subpixel image registration or matching, as alluded to in DCT Sign Only Correlation and Its Application to Image Registration:

In the DCT case, all DCT coefficients are real values, as a result, the phase information corresponds to the sign of DCT coefficients.

$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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