bundles / scipy 1.17.1 / scipy / fft / _realtransforms / idct
_Function
scipy.fft._realtransforms:idct
Signature
def idct ( x , type = 2 , n = None , axis = -1 , norm = None , overwrite_x = False , workers = None , orthogonalize = None ) Summary
Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.
Parameters
x: array_likeThe input array.
type: {1, 2, 3, 4}, optionalType of the DCT (see Notes). Default type is 2.
n: int, optionalLength of the transform. If
n < x.shape[axis],xis truncated. Ifn > x.shape[axis],xis zero-padded. The default results inn = x.shape[axis].axis: int, optionalAxis along which the idct is computed; the default is over the last axis (i.e.,
axis=-1).norm: {"backward", "ortho", "forward"}, optionalNormalization mode (see Notes). Default is "backward".
overwrite_x: bool, optionalIf True, the contents of
xcan be destroyed; the default is False.workers: int, optionalMaximum number of workers to use for parallel computation. If negative, the value wraps around from
os.cpu_count(). See fft for more details.orthogonalize: bool, optionalWhether to use the orthogonalized IDCT variant (see Notes). Defaults to
Truewhennorm="ortho"andFalseotherwise.
Returns
idct: ndarray of realThe transformed input array.
Notes
For a single dimension array x, idct(x, norm='ortho') is equal to MATLAB idct(x).
For norm="ortho" both the dct and idct 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 (see dct 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.
Array API Standard Support
idct has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ✅ ⛔ JAX ✅ ⛔ Dask ⚠️ computes graph n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
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 idct(np.array([ 30., -8., 6., -2.]), 1)✗
See also
- dct
Forward DCT
Aliases
-
scipy.fft.idct