SignalProcessing - Maple Programming Help

Home : Support : Online Help : Science and Engineering : Signal Processing : Transforms : SignalProcessing/DCT

SignalProcessing

 DCT
 compute forward discrete cosine transform
 InverseDCT
 compute inverse discrete cosine transform

 Calling Sequence DCT(A) InverseDCT(A)

Parameters

 A - Array of real numeric values; the signal

Options

 • container : Array, predefined Array for holding results
 • inplace   : truefalse, specifies that output should overwrite input

Description

 • The DCT(A) command computes the discrete cosine transform (DCT) of the Array A and returns the result in an Array with datatype float.
 • The InverseDCT(A) command computes the inverse discrete cosine transform of the Array A and returns the result in an Array with datatype float.
 • Before the code performing the computation runs, A is converted to datatype float if it does not have that datatype already. For this reason, it is most efficient if A has this datatype beforehand.
 • The discrete cosine transform B of a sample of $N$ elements is defined by the formula

${B}_{k}=C\left(k\right)\left({\sum }_{i=0}^{N-1}{A}_{i}\mathrm{cos}\left(\frac{\left(2i+1\right)\mathrm{\pi }k}{2N}\right)\right)$

 where $C$ is given by

$C\left(k\right)=\left\{\begin{array}{cc}\frac{1}{\sqrt{N}}& k=0\\ \frac{\sqrt{2}}{\sqrt{N}}& 0

 .
 • Samples may be of arbitrary length, but when the length is a power of $2$, a faster algorithm is used,
 • If the container=C option is provided, then the results are put into C and C is returned. With this option, no additional memory is allocated to store the result. The container must be an Array having datatype float and size equal to those of A.
 • If the inplace or inplace=true option is provided, then A is overwritten with the results. In this case, the container option is ignored. Furthermore, A must have datatype float.

 • The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands are thread-safe as of Maple 17.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$
 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $N≔10:$
 > $A≔\mathrm{GenerateTone}\left(N,1,0.1,0\right)+\mathrm{GenerateTone}\left(N,3,0.4,0.2\right):$
 > $B≔\mathrm{DCT}\left(A\right)$
 $\left[\begin{array}{cccccccccc}-8.426000324584082{}{10}^{-16}& 1.8408150749374697& 2.1266270208801& 1.0734052263252105& -7.944109290391274{}{10}^{-16}& 1.8674493435445683& -1.787424590338037{}{10}^{-15}& 4.532017760897827& 3.2991147502750304& -2.454780728041237\end{array}\right]$ (1)
 > $\mathrm{display}\left(⟨⟨⟨\mathrm{listplot}\left(A,'\mathrm{title}'="Signal"\right)⟩,⟨\mathrm{listplot}\left(B,'\mathrm{title}'="Cosine Transform"\right)⟩⟩⟩\right)$  > $C≔\mathrm{InverseDCT}\left(B\right)$
 $\left[\begin{array}{cccccccccc}3.940199733523726& -1.9199792650748937& 1.7844259638123918& 0.03271740521865407& -2.8373638374798804& 1.9401997335237262& -3.5380132538247873& 1.1663919750624934& 0.650751393968553& -1.219329848729986\end{array}\right]$ (2)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\begin{array}{cccccccccc}-0.& 0.& -0.& 0.& 0.& -0.& 0.& -0.& 0.& 0.\end{array}\right]$ (3)
 > $A≔\mathrm{GenerateJaehne}\left(10,3\right)$
 $\left[\begin{array}{cccccccccc}0.0& 0.46930339512069263& 1.7633557568774194& 2.9630650217854133& 1.7633557568774196& -2.1213203435596424& -1.76335575687742& 2.963065021785413& -1.7633557568774183& 0.46930339512069374\end{array}\right]$ (4)
 > $C≔\mathrm{Array}\left(1..10,'\mathrm{datatype}'={'\mathrm{float}'}_{8}\right):$
 > $\mathrm{DCT}\left(A,'\mathrm{container}'=C\right)$
 $\left[\begin{array}{cccccccccc}1.5000000000000004& 1.5343510197016252& -0.30366594795102525& -2.5278309009474733& -2.0603989756276837& 2.248013729607338& 1.2781204298267197& -2.678116209588312& 2.1632399282712855& -1.0329588850112361\end{array}\right]$ (5)
 > $C$
 $\left[\begin{array}{cccccccccc}1.5000000000000004& 1.5343510197016252& -0.30366594795102525& -2.5278309009474733& -2.0603989756276837& 2.248013729607338& 1.2781204298267197& -2.678116209588312& 2.1632399282712855& -1.0329588850112361\end{array}\right]$ (6)
 > $\mathrm{InverseDCT}\left(C,'\mathrm{inplace}'\right)$
 $\left[\begin{array}{cccccccccc}5.551115123125783{}{10}^{-17}& 0.46930339512069263& 1.7633557568774196& 2.9630650217854138& 1.7633557568774203& -2.1213203435596437& -1.7633557568774203& 2.9630650217854133& -1.7633557568774192& 0.4693033951206936\end{array}\right]$ (7)
 > $C$
 $\left[\begin{array}{cccccccccc}5.551115123125783{}{10}^{-17}& 0.46930339512069263& 1.7633557568774196& 2.9630650217854138& 1.7633557568774203& -2.1213203435596437& -1.7633557568774203& 2.9630650217854133& -1.7633557568774192& 0.4693033951206936\end{array}\right]$ (8)
 > $\mathrm{map}\left(\mathrm{fnormal},A-C\right)$
 $\left[\begin{array}{cccccccccc}-0.& 0.& -0.& -0.& -0.& 0.& 0.& -0.& 0.& 0.\end{array}\right]$ (9)
 > 

Compatibility

 • The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands were introduced in Maple 17.