This animation shows the structure of the discrete wavelet transform
of a 8x8x8 three-dimensional array.
First, an empty 8x8x8 array is computed within
WaveThresh3
by first setting the size within each
of the dimensions (this has to be a dyadic number)
nd <- 8Then create an 8x8x8 array containing just zeros (an "empty" array)
a <- array(rep(0, nd^3), dim = rep(nd, 3))And then use the
WaveThresh3
function
wd3D to perform the 3D
discrete wavelet transform:
awd3D <- wd3D(a)Now, the picture in the rotating 3D cube actually shows two different effects. The first, and simplest, is where each resolution level is assigned a colour (red, green and blue) and the second is where the different "blocks" (for the horizontal, vertical and diagonal detail, except in 3D these names don't quite have the same meaning and so we use the identifiers GGG (i.e. the 3D extension of the GG=diagonal detail), GGH, GHG, GHH, HGG, HGH, HHG for each of the resolution levels (these are the subcubes that make up the cube resolution levels of coefficients in different colours.
A "block" of coefficients can be inserted into an wd3D object using the putD.wd3D function (remember in the 1D transform a vector of coefficients can be inserted into a wd class object, in the 2D transform a sub-image can be inserted into a imwd object, here a sub-array or block is inserted!
To produce the animation the array component of the
awd3D
is subjected to a particular (pretty) 3D rotation
and a 2D image is produced for each rotation step using a 3D->2D
projection. The multiple images, one for each rotation step,
are converted into PostScript using S-Plus postscript
function with the ps.options
set up to reflect the
colours I wanted to link in with the integers I inserted into
the awd3D
array using
putD.wd3D.
The animated GIF itself was produced from GIF files using Peter Hartley's InterGif software.. The GIF files were produced using the public domain ImageMagick package to convert PostScript files produced from within S+ into GIF.