These are from previous years.
Please obtain and use the following software packages:
You may also find the interactive iPython shell useful. There are also several Python IDEs available; DrPython is easy to use and reasonably powerful.
You can use the computer science department's machines. If you want to use your own machine, the easiest way is to run Ubuntu or another desktop Linux version. You can either run Linux directly, use one of the Ubuntu-under-Linux versions (e.g., andlinux.org), or install under VirtualBox or VMWare. For Macintosh, your best bet is to start with the SciPy bundle, or maybe to install it via Fink.
Images are represented in Python as NumPy arrays (2D arrays). There is a lot of introductory information available on the net on Python, NumPy, and SciPy. Good places to start reading are www.scipy.org and www.python.org.
Image File Formats
Exercise 1.2 (Image File Formats)(10 Point10=1s)
A common image storage format is the PGM format; you can find the specification here:
http://netpbm.sourceforge.net/doc/pgm.htmlWrite Python functions for reading and writing the binary, 8 bit per pixel variant of the PGM format (you should raise an error for any other input). You can generate sample images with the command:
convert magick:rose rose.pgm
Exercise 1.4 (Image Compression)(10 Point10=1s)
Image compression relies on reducing redundancies. A simple trick for compressing images relies on computing differences between subsequent pixels followed by gzip compression.
First, write a Python script that takes any file as input and outputs a file that consists of differences between pixels; that is, if the original file contains the bytes , , , ..., , then the output file should contain , , , ..., . Verify that you can transform images, reverse the transform, and obtain a bit-identical output image.
Take graylevel input images and convert them to binary PGM images (you can take color images and convert them with convert image.jpg image.pgm). For 10 images, determine the following: (1) the size of the image in binary PGM format, (2) the size of the image when JPEG compressed with quality 99, (3) and the size of the image when you take the binary PGM image and compress it with gzip -9, and (4) the size of the image when you take the binary PGM image, apply pixel differencing, and then compress it with gzip -9.
Explain and discuss your results.
Exercise 1.6 (Path-Finding)(20 Point20=1s)
Assume you are given an image image. You are given the two points `source' and `target' in the image for which
Python has several libraries dealing with images. You may find the following code useful for reading images using the PIL library. The PIL library understands a lot of image formats but doesn't output numerical arrays (instead, it outputs an Image object). The code below performs the necessary conversions.
from __future__ import with_statement
Image and Video Processing (SS 2007)
Exercise Sheet 2
to be handed in: 19.06.2007
Exercise 2.2 (Connected Components)(20 Point20=1s)
In your favorite programming language, program a function that given a binary image computes all connected components of value 1. (Implement the algorithm discussed in the lecture.) Assume the binary image is given as a one-dimensional array and values for height and width. Output the result coded as an image. That is, the function should return an image of the same size as the input image in which each pixel is either 0 (when the corresponding pixel was 0 in the input) or has the label of the connected component the pixel belongs to.
Exercise 2.4 (Current Cameras)(5 Point5=1s)
Perform a web- or library-search to answer the following questions regarding cameras sensors: 1=10
Exercise 2.6 (Color Spaces)(10 Point10=1s)
Briefly discuss one application for each of the following color spaces: 1=10
Exercise 2.8 (Fourier Series)(10 Point10=1s)
Compute the Fourier series of the rectangle signal
Exercise 2.10 (Gaussian Smoothing)(10 Point10=1s)
An image is to be low-pass filtered. 1=10
Smoothing for Down-Sampling
Exercise 2.12 (Smoothing for Down-Sampling)(20 Point20=1s)
An image is to be down-scaled by an (integer) factor . To avoid aliasing, we want to use a Gaussian smoothing filter. 1=10
Fourier transform properties
Exercise 3.2 (Fourier transform properties)(10 Point10=1s)
In the lecture, we discussed various connections between an image and its Fourier transform. For example, consider
Exercise 3.4 (Image Operations)(10 Point10=1s)
Implement the image processing operations 1=10
Exercise 3.6 (Subsampling)(15 Point15=1s)
In the lecture, it has been mentioned that low-pass filters should be applied before subsampling from an image in order to avoid aliasing. 1=10
Rotation with 3 Shears - Theory
Exercise 3.8 (Rotation with 3 Shears - Theory)(5 Point5=1s)
In the lecture it was discussed that rotating an image can be done by performing shear operations instead of using a rotation matrix. Derive the shear parameters for a rotation by using the ansatz
Exercise 3.10 (Rotation)(15 Point15=1s)
Write a program that rotates a given image by an angle using the image center as the origin. 1=10
Now test the two methods: take two example images from the course homepage and rotate them first by and then by . Crop the transformed image to size that the original had and calculate the difference image between the original and the transformed version. What do you see?
Exercise 4.2 (Morphological Processing)(5 Point5=1s)
Prove that the following relation between morphological closing and opening holds:
Exercise 4.4 (Unsharp Masking)(10 Point10=1s)
In the lecture, we discussed the use of the Laplacian operator for the enhancement of image details. How is the discussed procedure related to the following method, called `unsharp masking'?
A negative was contact-copied on to a low contrast film or plate to create a positive. However, the positive copy was blurred. After processing, this blurred positive was replaced in contact with the back of the original negative. When light was passed through both negative and in-register positive, the positive partially cancelled some of the information in the negative. Because the positive was intentionally blurred, only the low frequency (blurred) information was cancelled. In addition, the mask effectively reduced the dynamic range of the original negative. Thus, if the resulting enlarged image is recorded on contrasty photographic paper, the partial cancellation emphasizes the high frequency (fine detail) information in the original, without loss of highlight or shadow detail. The resulting print appears sharper than one made without the unsharp mask.
Exercise 4.6 (Histogram Properties)(10 Point10=1s)
In the lecture, we discussed several statistical properties of the grayscale histogram of an image in the context of Otsu-thresholding. Show that the following equalities hold (cp. the notation used in the lecture): 1=10
Exercise 4.8 (Wavelets Practice)(15 Point15=1s)
Write a program that reads an image of even dimensions and performs one level of the Wavelet transform on it, using a the Haar basis and . Make sure that no over- or underflows occur and output the result as an image again.
Extend the program such that it performs all levels of the transform. If the size of the image is not a power of 2, fill the additional parts with 0.
Exercise 4.10 (Wavelets Theory)(10 Point10=1s)
What is the computational complexity of your routine for the full wavelet transform for images of size . Is this optimal?
Compare the complexity of the DWT with the one of the FFT. Do you think
that the difference will matter in practice?
Exercise 5.2 (Median Filter)(5 Point5=1s)
Show that the Median Filter for images is not linear.
Exercise 5.4 (Invariant Features)(15 Point15=1s)
Analyze the behaviour of the three localized features
Choose one features/transformation combination which is not invariant. Can you come up with a modification of the feature that makes it (more) invariant?
Exercise 5.6 (Signal Entropy)(10 Point10=1s)
Calculate the entropy for the following discrete probability distribution resp. signal sequences:
Exercise 5.8 (Huffman Codes)(5 Point5=1s)
Construct a Huffman Code for items (1), (2), and (3) of exercise 5.3.
Exercise 5.10 (Hough Transform)(20 Point20=1s)
In the lecture, the Hough Transform for line-finding was explained. Write a program that reads a binary image and uses the Hough Transform to find the best line to match the ''ON'' pixels. Use a resolution in parameter space, i.e. discretize the angle and distance into steps each.
Blob Detection at Wikipedia).