scipy.fft.idct#
- scipy.fft.idct(x, type=2, n=None, axis=-1, norm=None, overwrite_x=False, workers=None, orthogonalize=None)[source]#
Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.
- Parameters:
- xarray_like
The input array.
- type{1, 2, 3, 4}, optional
Type of the DCT (see Notes). Default type is 2.
- nint, optional
Length of the transform. If
n < x.shape[axis]
, x is truncated. Ifn > x.shape[axis]
, x is zero-padded. The default results inn = x.shape[axis]
.- axisint, optional
Axis along which the idct is computed; the default is over the last axis (i.e.,
axis=-1
).- norm{“backward”, “ortho”, “forward”}, optional
Normalization mode (see Notes). Default is “backward”.
- overwrite_xbool, optional
If True, the contents of x can be destroyed; the default is False.
- workersint, optional
Maximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count()
. Seefft
for more details.- orthogonalizebool, optional
Whether to use the orthogonalized IDCT variant (see Notes). Defaults to
True
whennorm="ortho"
andFalse
otherwise.New in version 1.8.0.
- Returns:
- idctndarray of real
The transformed input array.
See also
dct
Forward DCT
Notes
For a single dimension array x,
idct(x, norm='ortho')
is equal to MATLABidct(x)
.Warning
For
type in {1, 2, 3}
,norm="ortho"
breaks the direct correspondence with the inverse direct Fourier transform. To recover it you must specifyorthogonalize=False
.For
norm="ortho"
both thedct
andidct
are scaled by the same overall factor in both directions. By default, the transform is also orthogonalized which for types 1, 2 and 3 means the transform definition is modified to give orthogonality of the IDCT matrix (seedct
for the full definitions).‘The’ IDCT is the IDCT-II, which is the same as the normalized DCT-III.
The IDCT is equivalent to a normal DCT except for the normalization and type. DCT type 1 and 4 are their own inverse and DCTs 2 and 3 are each other’s inverses.
Examples
The Type 1 DCT is equivalent to the DFT for real, even-symmetrical inputs. The output is also real and even-symmetrical. Half of the IFFT input is used to generate half of the IFFT output:
>>> from scipy.fft import ifft, idct >>> import numpy as np >>> ifft(np.array([ 30., -8., 6., -2., 6., -8.])).real array([ 4., 3., 5., 10., 5., 3.]) >>> idct(np.array([ 30., -8., 6., -2.]), 1) array([ 4., 3., 5., 10.])