The goal of this practical session is to extract information from a set of images. Suppose we are in front of a beautifull place (e.g. the Taj Mahal in India).
As the place is very nice, there is plenty of people moving around and we cannot take a photo without having somebody in front of the building.
The idea consist in taking many images from exactly the same place. A given pixel in the image will have different values: either the value corresponding to the building (most of the time) or the value corresponding to a person that lies between the camera and the building.
Assuming, most of the time, the pixel value corresponds to the building, we can get this value by computing the median of the different values taken by this pixel.
The goal of this practical session is to write a script that does this job.
We will assume here that all the images can fit in memory.
Write a function that takes as input a directory and a suffix and return the list of files in the directory that ends up with the given suffix
os.listdir
to list the set of files in a directorystr.endswith
to filter this setWe are assuming here that all the images fits in memory. We
our problem now is to load all the images as a unique numpy array. Fortunatelly, this exact question has been asked (and answered) on stackoverflow: https://stackoverflow.com/questions/17394882/add-dimensions-to-a-numpy-array
Modify you code to have an "out of core" algorithm (ie do not load all the image in memory):
compute_median(img_list, line_start, line_end)