Linear Feedback Shift Register (part B)
In Part B, we finish the linear feedback shift register assignment described at http://www.cs.princeton.edu/courses/archive/fall13/cos126/assignments/lfsr.html.
For this portion of the assignment, you will:
- Write a C++ program to read four arguments from the command line: source image filename, output image filename, and LFSR seed and tap position.
- Use SFML to load the source image from disk and display it in its own window.
- Use your debugged LFSR class to encode (or decode) the image.
- Display the encoded/decoded image in its own window.
- Save the new image to disk.
Please see starter code
pixels.cpp for using SFML to load, manipulate, display, and save an image.
The code reads in a file and then uses individual pixel access to photographically negate an upper 200 px square, like this:
Your main code should be in a file named
PhotoMagic.cpp and should accept command line arguments as follows (e.g.):
% PhotoMagic input-file.png output-file.png 01101000010100010000 16
which should take the input file and encrypt it using the method described in the Princeton assignment, with LFSR seed
01101000010100010000 and tap position
Your program should display the source file and encrypted file, and write out the encrypted file to
output-file.png. Note: you may save either a PNG or BMP output file, but not a JPG. (Why not?)
Then, if you re-run your program on the encrypted file, and give it the same LFSR seed and tap, it should produce the original input file! (Make sure you understand why.)
Note: it's probably easier to make one SFML window and display both the pre-processed and post-processed images in it (rather than two SFML windows).
Make sure to create a Makefile or include short, direct instructions for how to build your project.
Submit your code files
LFSR.hpp plus a Makefile or make instructions:
submit fredm 204-ps4bfiles
If you're looking for a bigger challenge, consider the two suggestions in the Princeton assignment:
- Converting from an alphanumeric password to the LFSR initial seed and tap (2 extra points)
- Figuring out a missing seed/tap by trying all possibilities and analyzing the decoded image for reasonableness (e.g. not randomly-distributed colors). Note: if you try this, it will probably matter to have good performance in your core LFSR implementation. (3 extra points)
|core implementation||4||full & correct implementation=4 pts; nearly complete=3pts; part way=2 pts; started=1 pt|
|Makefile||2||Makefile or explicit build/link instructions included|