Digital Image Processing
(Spring 2013)


    You may have seen such scene in TV or movie: a car is runing on the highway, detected and marked with a red rectange either by human or some system.

    In fact, we belive that the knowledge you have learned so far in our DIP course would allow you to explore the solution to this problem, of course within some simple settings. There are lots of methods to obtain moving objects from a sequence of images, especially when the background is static. Ideally, as shown below, for an input image (left), we want an algorithm to ouput the an image (right) containing all the moving objects (foreground) as well as remove all the background:

    Obviously, this cannot be done using only ONE image, so the input are a sequence of images, obtained by a surveillance camera with fixed position (notice that in this case the background is also almost fixed). The input images would like:

    We provide a trival solution: substract image k+1 from image k, this procudes an image like

    This is not an ideal solution, since some backgrounds are still in the image and the foregrounds (cars) are not as good as they are in the original input image. Can you improve this solution? Or can you think up some other better solutions? 

          1. Complete the function bg_remove.m to take a sequence of images as input and output a sequence of processed images (through cell structure in matlab). 
          (All the materials can be found in Download section)


       1. Code.
           2. Sample input image.

    Sepecification of submission
           1. Submission directory:
           2. The format: A zip file, which has the structure as: (--x means a directory named as x)
                        --code:  bg_remove.m
                        --doc:  a pdf/doc file which describes the idea, method and implementation in your experiment. 
                Here we provide a sample submission file. (Your submitted file should be organised as the same structure as this file)
           3. Use your student number as the name of the submitted file, such as If you have multiple submissions, add an extra '_' with a number, such as We will use the the version with the largest number as your final submission.

    You can write a matlab script (for example, test_ass2.m) to test your code. This script need not to be submitted, and is like
       File:  test_ass2.m
         % create input array of images
input_array = cell(50,1);

% read all the images
for i=0:49
    input_array{i+1} = imread(['xxx/images/' num2str(i) '.jpg']);

output_array = bg_remove(input_array);

% select several frame to compare, for example, 1,11,21,31,41
for i=1:5
for i=1:5