

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


ECE547 Image Processing Sept 25, 2008
Lecturer: Prof. Thomas Huang Due: Oct 9, 2008
In this machine problem you are asked to write a MATLAB program which will the fractal com- pression scheme discussed in class. The program will contain two main functions: an encoder and decoder described below.
You are asked to write a MATLAB program to perform the following tasks for each of the given test images.
The first matlab function must have the name encode with the following definition:
function [row, column, a, b] = encode(inputimage, blocksize)
The inputimage parameter contains (grayscale) image to be compressed. You may assume that the input image is 128 Ă 128. The blocksize parameter is the size of the range block. The domain blocks are assumed to be twice as large in each dimension. For example, if blocksize=4, then you are to use 4 Ă 4 range blocks and 8 Ă 8 domain blocks. You may assume that blocksize divides evenly into the size of the image. Each of the outputs of this function should be n Ă n matrices, where n = (^) blocksize^128. For example if blocksize=4, the output should be four 32 Ă 32 matricies. Entry (i, j) should describe the encoding of the range block whose upper left corner is ((i â 1)blocksize + 1, (j â 1)blocksize + 1). Recall that the domain blocks are twice the size of the range blocks on each side (8 Ă 8 for blocksize=4), and that they can be drawn from anywhere as long as they are completely inside the image (there are 121 Ă 121 choices for blocksize=4). Since the domain blocks are twice as big as the range blocks, you must downsample the domain blocks before comparing them. To do this, take the average of the 4 corresponding pixels. You may find MATLAB indexing operators useful here. For each candidate block, consider drawing a from { 0 , 0. 2 , 0. 4 , 0. 6 , 0. 8 , 1. 0 }. Then choose b by
b = mean(orig_block(:) - a.*new_block(:));
The row and column parameters should return the upper left corner of the best matching domain block. Return values a and b should be the multiplicative and additive factors, respectively. Keep in mind that the brute-force search can take a while. Thus, be prepared to write clever MATLAB code or devote a lot of computer time to encoding. It may be wise to debug on a smaller image first.
The first matlab function must have the name decode with the following definition:
function [decodedImage] = decode(row,column,a,b,blocksize,ITR)
This function takes the output of the encode, uses some random image as the seed, performs the (LIFS) mapping ITR number of times. The output should be a 128 Ă 128 grayscale image.
The main program reads the image, feeds it to the encoder. Takes the output of the decoder, and displays the decoded image. It should also compute the rms error with respect to the original image. Apply your functions to http://courses.ece.uiuc.edu/ece547/mp/lena128.png^1 with blocksize=4 and blocksize=8.
Besides the code and the original and decoded images and the results for SNR, (and the optional part if you did that), try to analyze the effect of the size of blocks and explain what you are observing.
MathWorks Inc. provides an excellent documentation on how to use MATLAB. You may learn more about MATLAB from their website at: http://www.mathworks.com/access/helpdesk/help/techdoc/matlab.shtml
(^1) This famous picture in image processing was actually scanned from a copy of Playboy! See http://www.lenna.org for details.