Today we're going to play with spreadsheets to illustrate some of the compression techniques of JPEG and MPEG. I'm going to be assuming you have some experience with spreadsheets. If not, you might prefer to do the CSCI 107 labs on spreadsheets.

There are many good on-line references to the Discrete Cosine
Transform, and, if you want *good* information on the DCT, you
should Google for one of them.

In JPEG and MPEG, the DCT is performed on a 8-by-8 block of whole numbers, between 0 and 255, that represent the color and intensity values of individual dots within an image. The DCT takes this collection of 64 numbers and transforms it into another collection of 64 numbers. At first that doesn't seem like much of an accomplishment, but it turns out that most of the numbers within that second set of 64 will be close to 0 and can be ignored. So, in practice the DCT transforms a set of 64 numbers into a set of 10 (or so) numbers. That's worthwhile.

So how is this magic accomplished? Well, we're not going to worry about all the mathematics, which as pretty intimidating. Instead, we're going to look at some illustrations of parts of the process.

There are 64 (8 by 8) DCT basis functions. The functions themselves
are denoted by a pair of subscripts, such as `DCT`_{3,5}.
So, this is how we take about the 64 basis functions:
`DCT`_{0,0}, `DCT`_{0,1}, ..., `DCT`_{0,7}, `DCT`_{1,0}, ..., `DCT`_{7,7}.
Your task is to display all this information in a spreadsheet which
should look similar to a page from the
spreadsheet I generated to display the DCT basis functions.

In my spreadsheet, I can enter numbers into the cells immediate
to the right of those labeled `i` and `j`.
This should then display the DCT basis function
`DCT`_{i, j} within
a table.

So what are the numbers in that table. Give the
`i` and `j` that select the table and
the `x` and `y` that point to a cell within
the table, the value of the cell is given by the following formula:

- cos(
`i`* π * (`x`+ 0.5) / 8) * cos(`j`* π * (`y`+ 0.5) / 8)

Go ahead and start up Excel and construct the outline of the table, that is, everything except for the values. When it goes time to add the values, you'll need to type a formula to Excel. What you really want to go is to type a formula into a single cell and then copy that formula into the other cells. Here's some important points to keep in mind:

- The Excel function for cosine is called
`COS`. - π is
`PI()`. - Use absolute references when appropriate.
- Use Help in Excel if you don't understand any of the above.

You can look at the Data Compression chapter of Steven Smith's book The Scientist and Engineer's Guide to Digital Signal Processing for more information about the DCT, including some very pretty pictures.

Change the fonts and colors used in the cells of your spreadsheet to get a much nicer display of the DCT basis function.

Now use Excel's Chart Wizard to make a much nicer diagram than I did.

Remember, the DCT transformation takes 64 input number and produces 64 output numbers, most of which are zeros. These up-to-64 output numbers can be multiplied by the DCT basis functions to generate a good approximation of the 64 input numbers. There will be more on this next week.