We will implement a command line tool
pngcorrelate that you can use to find pairwise correlations between pixel rows in PNG images. It outputs the result as another PNG image, similar to what you see in the examples. The program accepts images with colors, but automatically converts them to grayscale before analyzing correlations.
The program can be used as follows:
./pngcorrelate INPUT OUTPUT1 OUTPUT2
where INPUT is the input file, OUTPUT1 will be a grayscale version of the input file, and OUTPUT2 will show the pairwise correlations.
For example, if you have a PNG file called example.png in the current directory, you can find the pairwise correlations as follows:
./pngcorrelate example.png result1.png result2.png
You can find an almost-working implementation in your personal Git repository, in the subdirectories
cp*. The only part that is missing is the implementation of the subroutine
correlate() in file
cp*/cp.cc. This is the function that does the actual calculations. See
cp*/cp.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.