Laboratory of Computer and Information Science / Neural Networks Research Centre CIS Lab Helsinki University of Technology

T-61.5100 Digital Image Processing

Course assignment / Harjoitustyö

This course assignment is a mandatory part of the course T-61.5100 Digital image processing. The purpose of the assignment is to acquaint the student with some common digital image processing tasks and further the understanding of the theoretical part of the course (lectures and exercises). The assignment consists of three tasks, which are about image filtering, restoration, and compression.

The images to be used in the assignment are in TIFF-format and can be downloaded from the links in the text, or from the separate download page.


This course assignment is meant to be done using the Matlab program. You may of course do it on your own computer, but it is recommended that you use HUT's unix workstations, since then you can use the Image Processing Toolbox (IPT), which eases image processing operations. Matlab is started using the commands

use matlab

For those who are not familiar with the Matlab software, there is a web page which describes the basics of Matlab and some frequently needed functions. It also describes how to load an image, display the results on the screen, and print out the results. The commands you are likely to need are the following ones: imread, uint8, colormap('gray'), image, imagesc, axis('image'), conv2, fft2, fftshift, ifft2, float, imwrite, print -deps mypicture.eps.

An image can be read into Matlab with the following command:


Notice the double-function which converts the image into floating-point numbers. (See the Matlab instructions for more information.)



Exercise 1

The first exercise considers noise reduction. Image 1 (img1noisy.tif) contains impulsive noise (left side) and additive white gaussian noise (right side). Try to use a median filter and an arithmetic mean filter. In addition to these filters, try at least one other filter from Chapter 5.3 in the textbook. Calculate the mean-square error:

E= 1
(Io(x,y) - If(x,y))2

(where Io is the original (noise-free) image and If the noisy/filtered image), in both sides separately of the image both before and after filtering with the different filters. Compare and discuss both the numerical results and visual appearance. Finally, show 'the best possible' filtered image, where both the left and the right side are filtered with the filter that produces the minimum mean-square error. Show also the respective error image (i.e. the difference image between the original and the corrected image). Remember to scale the error image properly!

The original noise-free image is in the file img1original.tif.

Exercise 2

In image 2 (img2.tif) there is a disturbing pattern, which should be removed. The pattern is a sinusoidal component. Remove the disturbance by a) making a model for the pattern and using that model to remove the disturbance, and b) by looking in the frequency domain for the spike corresponding to the disturbing frequency and removing it from there. Calculate the mean-square error both before and after your operation using the original image img2original.tif. Compare the results of the operations a) and b) both numerically and visually.

Note: Do not use the original image in any part of the restoration process! (The disturbing frequency can be found in the FFT by considering the orientation and frequency of the disturbance.)

Exercise 3

The purpose of this problem is to show how image transforms may be useful for example in image compression. The general idea is that if the image is represented in a suitable form much of the information can be represented with a small number of components. Load image img1original.tif and perform the two-dimensional discrete cosine transform (dct2). Now a large part of the components are very close to zero and only a few are significantly non-zero (this you can see for example by calculating a histogram).

Now one could think of compressing the image by simply dropping out components which have small absolute values, and only storing the rest. (In reality, we would of course need to keep book of which components were dropped, and quantize the remaining ones. These problems are not however considered here.) Because the DCT transform is orthogonal, leaving any one component si out directly implies a squared error of si2 in the original data. In other words it is easily seen that it is best to drop the components of small absolute values.

Make a plot where on the x-axis you have the mean-square error made - in percent of the total energy (that is, the sum of component squares) of the original image - and on the y-axis the amount of components needed to be kept along in the representation. In other words, if the allowed error is, say, 2% of the total energy of the image, how many of the DCT components will have to be saved in the compressed representation? Show also the exact amounts of components, the achieved compression ratios (assuming that an average of 8 bits are needed for encoding each component), and the compressed images, when the mean-square error is 1%, 2% and 4% of the total energy.

The work report

A written report is to be made, containing your Matlab-code, all the resulting images, and a clear explanation of exactly what was done and what were the results. Remember to comment your code well! However, just returning commented Matlab-code is not acceptable as a report.

The course assignment is graded as passed or failed, and a short description of what needs to be improved will be given for those graded as failed. Each student is expected to return his/her individual project work, i.e. only one name per returned work! Cooperation on the level of ideas is fine, but code and text should definitely be done individually.

The written report should be returned electronically as an e-mail attachment PDF file to the assistant (mats.sjoberg dot The file should be named after your student number, e.g. 12345X.pdf. The report can also be returned as a printed papercopy. The paper should be put in the mailbox next to the notice board of the Laboratory of Computer and Information Science (T-building, 3rd floor). The report must have a separate cover page which contains the name, student number, e-mail address and department.

The course assignment must be finished and returned on Monday, January 14th at 4pm. The course is passed only after both the exam and the course assignment are done.

You are at: CIST-61.5100 → Exercise work

Page maintained by t615100 at, last updated Monday, 12-Nov-2007 15:43:15 EET