CS676 Homework 1: Camera Transformations and Camera Calibration

CS676 Computer Vision and Image Processing Jul 2012

Homework 1: Clustering and Image Averaging

This assignment has two parts: A is for image averaging over time and B: colour clustering using K-means. There is also an optional preliminary Exercise: Part 0, on k-means.

All parts are to be done in MATLAB. Results files should be uploaded on your webpage using the filename given below. Please ensure you follow the file naming conventions given below very precisely - otherwise we may not be able to see your submission.

You should download the PETS 2000 dataset from [http://www.cse.iitk.ac.in/users/cs676/PETS2000] (291mb).

Submission Deadline: Sunday 18th August midnight (11:59pm).


Part 0 (Optional Exercise): K-means clustering

This exercise is intended to give you an idea of how to create and modify images, and also to implement k-means (it is a fairly simple implementation). It will not be graded, it is to give you a start of the Image processing in MATLAB.


aImage Structure


In an image of size 400x400, you need to generate N random points (x,y) in four circles of radius 100 centered at (Cx,Cy):

C2=(100,100); C1=(300 ,100); C3=(300,100); C4=(300,300).
N1 = N2 = 100; N3=50; N4=10.

a) Display the image with the generated random points in black (do not draw the circles). Use roundoff on the randomly generated points; leave the background pixels white.

b) Use k-Means clustering with k=4 on your randomly generated data points. On your submission HTML page, display a color image, with the data points colored as follows: K = 1 : Red, K = 2 : Yellow, K = 3 : Blue, K = 4 : Black where K is cluster number.

You should play around now by changing K to 3, 5 etc. And also, try values of R close to 150 (this will make the points quite close to each other and may violate some clusters).

Optionally, this exercise may be submitted in the directory "Part0/" (see below). It will not be formally evaluated, but posting it is useful for comparing with others and obtaining feedback.

Part A: Image smoothing

Instead of a full background subtraction, we will smooth the image over time which gives an impression of the fixed background with some blurring where motion occurs.

Output images to be displayed on your submission index.html page.

Consider the PETS 2000 image dataset.
It (x,y,k) : kth Color component of (x,y)th pixel of the image at time t
where k = 1 : Red component , k = 2 : Green component , k = 3 : Blue component

Compute:

µ1(x,y,k) = I1 (x,y,k)        [I1: First Image]

µt (x,y,k) = (1-α) µt-1(x,y,k) + α It(x,y,k) ;     [It: tth Frame of the dataset]

Report Image    Bt(x,y,k) = ROUND(µt (x,y,k)

Change α and observe the changes, take α = 0, 0.01 , 0.1 , 1.0. Submit the Images Bt(x,y,k) for t = 150 , 850, 1250 for above mentioned α’s. Report these 12 images in your index.html file under Part A.

In the discussion state what steps need to be taken on this exercise to make it a true background subtraction algorithm. Assume that a single gaussian is used to model each pixel's colour variation.

Extra credit: Implement the steps for background subtraction, and report your results, for a single-gaussian model of each pixel colour, for the images shown.

 

Part B: Colour Level Reduction by K-means


Consider a single image: PETS2000 image test0130.jpg.

Resize the image to half size (shown). Write your own implementation of K-Means clustering and run it on the pixel color vectors of the image , i.e. you will have WxH 3 Dimensional points {r,g,b} to cluster using K Means algorithm.

For this assignment, use euclidean distance for colour vectors in the RGB space, but remember that there are other metrics possible (e.g. in human perception, violet is closer to red than to green).

Re-visit all the pixels of the image and replace their pixel values by the cluster centre (ravg , gavg , bavg ) of the cluster in which that pixel goes. Try with increasing K = 5,10,20,40 and observe the output. What do you infer from this (increasing K).

Please try this on any image you like (animations etc) and observe the results, however test0130.jpg is to be used for submission.

 


Submission Instructions

We will look for all submissions in your home.iitk.ac.in/~youruserid/cs676/hw1/partX/ area. Note that CODE files are to be uploaded A DAY after the main submission.

To create thsi webpage, you must log ont to the CC machines, log on to your web area, and create the subdir "cs676", and the subdir "hw1" in that. In this directory, you must put a file called index.html so that typing home.iitk.ac.in/~youruserid/cs676/hw1/ in the browser will load this index.html file.

We will be making a webpage with everyone's submission webpages; if you load your files at some other location the TAs may not be able to find these files.

For part A and part B, we recommend you make subfolders partA, partB under your cs676/hw1/ area. In all case, the submissions should be linked from the "hw1/index.html" file.

partA : (Folder: ~userid/cs676/hw1/partA/): Save the 12 output images Bt(x,y,k) (for four values of α and three frames (t=150,850,1250)) as hw1_α_t.jpg, replace α,t by their values.

Keep the main code in file "partA.m" (you can write functions in separate files and call them from this code). "partA.m" when run should display the output image (for some α,t )as a MATLAB figure. There should be 2 variables inside partA.m naming ‘alpha’,’t’ which can be used to set their different values.

Please include a brief discussion of your observations in the "index.html" file.

partB : (Folder: partB/): This folder should contain "test0130.jpg". Put the 5 output images in file partB_k.jpg (with k = 5,10,20,40) . Include your discussion of the results in the "index.html" file. Put the code in file "partB.m" (you can write functions for K-Means etc in separate files and call them from this code). "partB.m" when run should display the output image (for some k )as a MATLAB figure. There should be a variable "k" inside partB.m which can be used to set different values of k.

Submission Deadline: Your webpages must be up by 18th August 11:59 PM. All the .m files are to be linked from the index.html pages, but the actual code should be uploaded only on 19th August midnight (a day after the main submission).