Spring 2005 CSCI 173 lab 11

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.

DCT basis function

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 DCT3,5. So, this is how we take about the 64 basis functions: DCT0,0, DCT0,1, ..., DCT0,7, DCT1,0, ..., DCT7,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 DCTi, 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:

The task

Getting started

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:

Getting more information

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.

Improving the spreadsheet

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

Plotting along

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

Upcoming events

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.