Next: About this document ...
ELEC 5430/6430 Project #7 Spring 2009
Assigned: 4/22/09
Due: 4/29/09
Image Compression
This exercise is intended to familiarize you with some basic
concepts related to image compression.
Exercises
- Write a simple m-file
function
that computes an error image for the following DPCM prediction:
The error image is defined as
Include a listing of the m-file in your write-up.
- Read in cameraman.tif. Compute the error image.
Display a normalized version of the error image with imagesc().
Describe the image characteristics that cause the most error in the
prediction.
- Compute the histogram of the values in e(m,n) with
hist.
(Hint #1: You'll need to turn e(m,n) into a
vector before finding the histogram. Hint #2: Use hist(x,[-255:255])
to compute the histogram.) Plot the histogram, and include it in your
report.
- Calculate the entropy to get the best lossless compression (in bpp) to be
expected from this predictor. If p is a probability, use log2(p + eps) in
the formula instead of log2(p) to prevent the result from being -Infty for
p=0.
- This exercise deals with JPEG transform coding.
- (a)
Use imwrite(image,filename,'jpg','Quality',quality) to create
lossy coded images.
Determine the quality setting at which you can detect a difference
between the coded image and the original. (The quality setting has a
range [0,100], with 100 being the highest quality.) Describe the
difference.
- (b) Determine the quality setting at which the image begins
to look unnatural. What aspects of the image look unnatural?
- (c) Code the image at a quality factor of 20. Describe the
problems with the image. Explain why the problems appear as they do.
- (d) Draw a rough plot of the number of bits versus quality
factor. (You'll need to look at the image file sizes for each quality
factor.) Is it a straight line? Why or why not?
The following exercises are for ELEC 5430 only. NOTE: This portion will count as a supplemental assignment as described in the syllabus.
- Write an m-file function that
- splits an image into 8x8 blocks, applies a 2-D DCT to each block, and returns the result in an image.
Use the blkproc function.
- divides the entire image by 8 to normalize the DCT.
- given the standard JPEG quantization table and scale defined as follows:
| 16 |
11 |
10 |
16 |
24 |
40 |
51 |
61 |
| 12 |
12 |
14 |
19 |
26 |
58 |
60 |
55 |
| 14 |
13 |
16 |
24 |
40 |
57 |
69 |
56 |
| 14 |
17 |
22 |
29 |
51 |
87 |
80 |
62 |
| 18 |
22 |
37 |
56 |
68 |
109 |
103 |
77 |
| 24 |
35 |
55 |
64 |
81 |
104 |
113 |
92 |
| 49 |
64 |
78 |
87 |
103 |
121 |
120 |
101 |
| 72 |
92 |
95 |
98 |
112 |
100 |
103 |
99 |
if quality < 50
scale = 50 / quality;
else
scale = 2 - quality * 2 / 100;
end
multiplies each element by scale and
rounds each result to the nearest integer, and then sets the minimum value to
one (1). That is,
NewQuantTable = max(ones(size(QuantTable)), round(scale * QuantTable));
- divides each block by the resulting quantization table and rounds
to the nearest integer.
- multiplies each block by the same table and takes the 8x8 IDCT.
- Scales the result by 1/8.
Congratulations! You've just implemented the basics of a JPEG coder/decoder!
- Run your function on the cameraman image with a quality factor of 50.
Compare to the result of saving and loading the image with the MATLAB JPEG
format. What is the MSE of each result?
- What is the MSE if you use a quality factor of 100?
Write a short report describing your findings following
my format instructions.
The report should contain a concise description of your results.
Be sure to answer all questions.
Please include in your report all the final image results you generated.
Only email the specified image(s).
For further help:
Next: About this document ...
Stan Reeves
2009-04-22