Learn R Programming

imagerExtra (version 1.3.2)

DCT: Two Dimensional Discrete Cosine Transformation and Inverse Cosine Transformation

Description

DCT2D computes two dimensional discrete cosine transformation. IDCT2D computes two dimensional inverse discrete cosine transformation.

Usage

DCT2D(imormat, returnmat = FALSE)

IDCT2D(imormat, returnmat = FALSE)

Arguments

imormat

a grayscale image of class cimg or a numeric matrix

returnmat

if returnmat is TRUE, returns numeric matrix. if FALSE, returns a grayscale image of class cimg.

Value

a grayscale image of class cimg or a numeric matrix

References

Makhoul, J. (1980). A fast cosine transform in one and two dimensions. IEEE Transactions on Acoustics, Speech, and Signal Processing. 28 (1): 27-34.

Examples

Run this code
# NOT RUN {
g <- grayscale(boats)
layout(matrix(1:2, 1, 2))
plot(g, main = "Original")
gg <- DCT2D(g) %>% IDCT2D() %>% plot(main = "Transformed")
mean((g - gg)^2)
# }

Run the code above in your browser using DataLab