Programming Parallel Computers 2020

Exercise MF: median filter

Implementation

We will implement a command line tool pngmf that you can use to do median filtering in PNG files.

Usage

The program can be used as follows:

./pngmf WINDOW INPUT OUTPUT1 OUTPUT2

where WINDOW is the parameter k that determines the size of the sliding window, INPUT is the input file, OUTPUT1 will be the result of median filtering, and OUTPUT2 will be a file that shows the differences between INPUT and OUTPUT1.

For example, if you have a PNG file called example.png in the current directory, you can do median filtering with parameter k = 10 as follows:

./pngmf 10 example.png result1.png result2.png

Template

You can find an almost-working implementation in your personal Git repository, in the subdirectories mf*. The only part that is missing is the implementation of the subroutine mf() in file mf*/mf.cc. This is the function that actually does median filtering. See mf*/mf.h for the description of the interface.

Once you have implemented the function correctly, you should be able to run make -j to compile your code, ./grading test to check that it works correctly (at least for some test cases) and ./grading benchmark to see how well it performs.