Programming Parallel Computers 2020

Exercise IS: image segmentation


We will implement a command line tool pngsegment that you can use to do image segmentation in PNG files.


The program can be used as follows:

./pngsegment INPUT OUTPUT1 OUTPUT2

where INPUT is the input file and OUTPUT1 and OUTPUT2 will show the segmentation: OUTPUT1 will draw the approximation of the image as a monochromatic rectangle and a monochromatic background, while OUTPUT2 will show the location of the rectangle overlaid with the original figure.

For example, if you have a PNG file called example.png in the current directory, you can do image segmentation as follows:

./pngsegment example.png result1.png result2.png


You can find an almost-working implementation in your personal Git repository, in the subdirectories is*. The only part that is missing is the implementation of the subroutine segment() in file is*/ This is the function that actually does segmentation. See is*/is.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.