SignalProcessing
DCT
compute forward discrete cosine transform
InverseDCT
compute inverse discrete cosine transform
Calling Sequence
Parameters
Options
Description
Thread Safety
Examples
Compatibility
DCT(A)
InverseDCT(A)
A
-
Array of real numeric values; the signal
container : Array, predefined Array for holding results
inplace : truefalse, specifies that output should overwrite input
The DCT(A) command computes the discrete cosine transform (DCT) of the Array A and returns the result in an Array with datatype float[8].
The InverseDCT(A) command computes the inverse discrete cosine transform of the Array A and returns the result in an Array with datatype float[8].
Before the code performing the computation runs, A is converted to datatype float[8] 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 with initial index 1 is defined by the formula
Bk=Ck⁢∑i=1N⁡Ai⁢cos⁡2⁢i−1⁢π⁢k−12⁢N
where Ck is given by
Ck=1Nk=12Notherwise
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[8] 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[8].
The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands are thread-safe as of Maple 17.
For more information on thread safety, see index/threadsafe.
with⁡SignalProcessing:
with⁡plots:
N ≔ 10:
A ≔ GenerateTone⁡N,1,0.1,0+GenerateTone⁡N,3,0.4,0.2:
B ≔ DCT⁡A
−5.617333549722722⁢10-161.84081507493746972.12662702088009861.07340522632521−5.998696806194468⁢10-161.8674493435445694−1.233922005235723⁢10-154.53201776089782453.29911475027503−2.454780728041238
display⁡listplot⁡A,'title'=Signal,listplot⁡B,'title'=Cosine Transform
C ≔ InverseDCT⁡B
3.940199733523725−1.91997926507489261.784425963812390.03271740521865585−2.83736383747987861.9401997335237255−3.53801325382478641.16639197506249430.6507513939685514−1.2193298487299862
map⁡fnormal,A−C
0.−0.0.0.0.0.−0.−0.0.0.
A ≔ GenerateJaehne⁡10,3
0.00.469303395120692631.76335575687741942.96306502178541331.7633557568774196−2.1213203435596424−1.763355756877422.963065021785413−1.76335575687741830.46930339512069374
C ≔ Array⁡1..10,'datatype'='float'8:
DCT⁡A,'container'=C
1.50000000000000041.534351019701625−0.3036659479510252−2.5278309009474733−2.06039897562768332.24801372960733751.2781204298267193−2.67811620958831182.163239928271285−1.0329588850112363
C
InverseDCT⁡C,'inplace'
−1.3877787807814457⁢10-160.469303395120692751.76335575687741962.9630650217854131.7633557568774196−2.1213203435596424−1.763355756877422.9630650217854124−1.76335575687741830.46930339512069374
0.−0.−0.0.0.0.0.0.0.0.
The SignalProcessing[DCT] and SignalProcessing[InverseDCT] commands were introduced in Maple 17.
For more information on Maple 17 changes, see Updates in Maple 17.
See Also
SignalProcessing[DFT]
SignalProcessing[DWT]
SignalProcessing[FFT]
Download Help Document