cutcutcodec.core.analysis.video.complexity.dct.compute_dct

cutcutcodec.core.analysis.video.complexity.dct.compute_dct(tensor: Tensor, dim: int) Tensor[source]

Compute the DCT-II on the given axis.

The output vector \(\hat x_k\) is defined as \(\hat x_k = \sum\limits_{l=0}^{n-1} x_l \cos\left(\frac{\pi}{n}\left(l+\frac{1}{2}\right)k\right)\).

It is calculated by a matrix product, computed by dct_matrix().

Parameters

inputtorch.Tensor

A n-dimensional tensor of real.

dimint

The axis along which the DCT is computed. The other axes are treated as batch dimensions.

Returns

outputtorch.Tensor

The dimension of the input tensor. The input and output have the same size.

Examples

>>> import torch
>>> from cutcutcodec.core.analysis.video.complexity.dct import compute_dct
>>> src = torch.randn((128, 16, 16))
>>> 2d_dct = compute_dct(compute_dct(src, -1), -2)  # compute the 2d dct
>>>