CS 558a - Advanced Computer Networking
Project 1

Due: See class webpage.

# 1. Experiment with DCT transform

This project help re-enforce the DCT transform method used in JPEG encoding. In this project, you are to write 5 functions that perform the forward and reverse DCT transform on an 8x8 input matrix:

• Forward_DCT_Trans(int MatrixIn[8][8], float MatrixOut[8][8]):
• The 8x8 input matrix "MatrixIn" is transformed using the forward DCT transform method discussed in class.
• The output is stored in the 8x8 float matrix MatrixOut.
• Note: make sure you use double to perform the transform computations. Only after you completely calculated a matrix coefficient, should you convert it to a float and assign it to MatrixOut.

• Forward_Quantize(int MatrixIn[8][8], int Q[8][8], float MatrixOut[8][8]):
• The 8x8 input matrix "MatrixIn" is divided by using the Quantization matrix Q
• The output is stored in the 8x8 float matrix MatrixOut.

• Reverse_Quantize(int MatrixIn[8][8], int Q[8][8], int MatrixOut[8][8]):
• The 8x8 input matrix "MatrixIn" is multiplied using the Quantization matrix Q
• The output is stored in the 8x8 float matrix MatrixOut.

• Reverse_DCT_Trans1(float MatrixIn[8][8], int MatrixOut[8][8])
• The 8x8 float input matrix "MatrixIn" is transformed using the reverse DCT transform method discussed in class.
• The reverse DCT transform was not discussed in class (because it is similar to the forward method) and it is described in Wallace paper: click here
• The output is stored in the 8x8 int matrix MatrixOut.
• Note: make sure you use double to perform the transform computations. Only after you completely calculated a matrix coefficient, should you convert it to int and assign it to MatrixOut.

• Reverse_DCT_Trans2(int MatrixIn[8][8], int MatrixOut[8][8])
• The 8x8 int input matrix "MatrixIn" is transformed using the revrese DCT transform method discussed in class.
• The reverse DCT transform was not discussed in class (because it is similar to the forward method) and it is described in Wallace paper: click here
• The output is stored in the 8x8 int matrix MatrixOut.
• Note: make sure you use double to perform the transform computations. Only after you completely calculated a matrix coefficient, should you convert it to int and assign it to MatrixOut.

# 2. Driver program

Write a driver program that reads in an 8x8 pixel matrix from stdin and do the following:

1. Prints out the 8x8 pixel matrix to stdout

2. Use the Forward_DCT_Trans() function to perform the Forward DCT transform and prints out the 8x8 DCT (float) matrix. Use the format "%6.1f " to print each float in the matrix to make the output line up nicely.

3. Perform the Reverse_DCT_Trans1() function to perform the Reverse DCT transform on the matrix that you have just obtained in step (1). Print the result out to stdout and compare that to the original pixel matrix. (Should be almost equal).

4. Use Forward_Quantize() on the result from (1) and print out the results.

5. Use Reverse_Quantize() and then Reverse_DCT_Trans2() on the result from (4) and print out the results.

Each printing must be preceeded by a title (tell you what the program is printing.

# 3. Sample Inputs

Try your program on the following inputs:

1. The input pixel matrix from Wallace's paper (slowly varying):
```   139  144  149  153  155  155  155  155
144  151  153  156  159  156  156  156
150  155  160  163  158  156  156  156
159  161  162  160  160  159  159  159
159  160  161  162  162  155  155  155
161  161  161  161  160  157  157  157
162  162  161  163  162  157  157  157
162  162  161  161  163  158  158  158
```

2. A rapidly varying input:
```   10   40   90   150  200  170  100  20
20   60   100  161  221  181  129  40
40   70   111  177  211  190  130  60
70   90   90   150  199  170  170  80
80   80   90   160  180  160  150  99
60   60   80   140  160  150  140  80
50   50   80   120  130  140  130  100
40   60   90   100  120  130  120  90
```

3. Abrupt changes (1):
```   80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
```

4. Abrupt changes (2):
```   80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
80   80   80   80   200  200  200  200
200  200  200  200   200  200  200  200
200  200  200  200   200  200  200  200
200  200  200  200   200  200  200  200
200  200  200  200   200  200  200  200
```

# 4. Turn In

I want a Makefile that I can use to compile your programs. The object of the makefile must be main (so I can automate the grading - I will run main on my inputs).

Turn the following in using the following turnin codes:

• The makefile as `pj1':
```   /home/cs584000/turnin  Makefile  pj1
```

• The driver program file containing the main() function as `pj1-1':
```   /home/cs584000/turnin  main.c  pj1-1
```

• The file containing the other functions as `pj1-2':
```   /home/cs584000/turnin  otherfunc.c  pj1-2
```