This code performs the 2D Discrete Cosine Transform on images. It can save to disk the spectrum of a image in png or binary format, and it can perform the inverse DCT to reconstruct the image from the spectrum (or a modified version of it). It can also generate the basis images for a certain width and height, by performig the inverse DCT on spectums with only one non-zero element.
Here are some images generated from various spectra:
Alternatively one can also use the Matlab script