idct: Inverse Discrete Cosine Transform

View source: R/idct.R

idctR Documentation

Inverse Discrete Cosine Transform

Description

Compute the inverse unitary discrete cosine transform of a signal.

Usage

idct(x, n = NROW(x))

Arguments

x

input discrete cosine transform, specified as a numeric vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal.

n

transform length, specified as a positive integer scalar. Default: NROW(x).

Details

The discrete cosine transform (DCT) is closely related to the discrete Fourier transform. You can often reconstruct a sequence very accurately from only a few DCT coefficients. This property is useful for applications requiring data reduction.

Value

Inverse discrete cosine transform, returned as a vector or matrix.

Author(s)

Paul Kienzle, pkienzle@users.sf.net.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

See Also

dct

Examples

x <- seq_len(100) + 50 * cos(seq_len(100) * 2 * pi / 40)
X <- dct(x)

# Find which cosine coefficients are significant (approx.)
# zero the rest
nsig <- which(abs(X) < 1)
N <- length(X) - length(nsig) + 1
X[nsig] <- 0

# Reconstruct the signal and compare it to the original signal.
xx <- idct(X)
plot(x, type = "l")
lines(xx, col = "red")
legend("bottomright", legend = c("Original", paste("Reconstructed, N =", N)),
       lty = 1, col = 1:2)


gsignal documentation built on Sept. 12, 2024, 6:27 a.m.