IP Exercises 2024 Ex5
IP Exercises 2024 Ex5
5.1 In general
Image compression is an operation which aims to minimise the amount of bits
needed to represent an image digitally. The advantages of a more compact
image representation are obvious: more efficient transmission and storage.
Images can be compressed by exploiting the correlation between neighbouring
pixels and by using some properties of the human visual system. Image
compression can be divided into two domains: compression with quality loss
(lossy) and without any loss of quality (lossless).
In a first step the image is transformed to another representation with the help
of an image transformation.
Quantisation
for each block
DCT quantized
= coefficients
Image is divided in
frequency decomposition
blocks of 8x8 pixels
Run-length coding
+
Huffman encoding
5.4.1 Exercise 20
Load the greyscale image lenagray.tif and convert it to double format. Look at
the image. Split it up in blocks of 8 by 8 pixels and execute the DCT on each
block (function: DCT2). Block based operations in Matlab are best executed
with blkproc. Check what the effect is when you set a part of the high frequency
coefficients to zero. Do this in four steps where each time you set more
coefficients to zero. Start by setting only the highest frequency coefficients to
zero and end up with keeping only the DC components. Use masking for this
operation (multiplication with a matrix with only ones on the positions of the
coefficients you want to keep and zeros on the other positions). Each time
execute the IDCT (function IDCT2) and compare the image with the original.
Write a program to compute the PSNR and execute it for every case. What can
you conclude about the influence of setting the high frequent components to
zero? What kind of distortions occurs if you retain only a few coefficients?
We can also see that the detail subbands of natural images don’t contain a lot of
information. By removing the coefficients out of the highfrequent subbands or
quantifying them more coarsely, efficient lossy compression can be achieved.
Lossless compression becomes possible by exploiting the inter- or intra-
subband correlation between the coefficients by using a form of entropy
coding.
5.5.1 Exercise 21
Load the image lenagray.tif and convert it to double format. Execute a wavelet
decomposition with 3 levels. Use the function wavedec2 with filtertype bior4.4.
Derive all the subbands from C and S (see help wavedec2) with the use of the
functions appcoef2 and detcoef2. Display the subbands with myshow.m (take
64 as second parameters for the LL subband and 128 for all other subbands).
Can you detect the different orientations of the details? The orientations
depend on the sequence in which the filtering is performed. Explain. See what
happens when you put all the coefficients from the HH1 subband to zero (in
the C matrix) and execute the wavelet reconstruction (command waverec2).
Compare the result with the original. Is there a lot of difference? Repeat the
previous steps and successively put all coefficients from
1) HH1 LH1 HL1
2) HH1 LH1 HL1 HH2
3) HH1 LH1 HL1 HH2 HL2 LH2
4) HH1 LH1 HL1 HH2 HL2 LH2 HH3
5) HH1 LH1 HL1 HH2 HL2 LH2 HH3 LH3 HL3
to zero and check the results. What are the kind of errors you see in the last
cases between the original and the reconstructed image (2)? Calculate the
PSNR for each case and compare.