Assignment 5 – Steganography

Maximum Points = 50

 (Due before class on October 31, 2007) The purpose of this lab is to use loops and conditionals in Java to modify pictures in order to hide and find pictures. In this lab you will use:

“Steganography is the art and science of writing hidden messages in such a way that no one apart from the sender and intended recipient even realizes there is a hidden message.” [http://en.wikipedia.org/wiki/Steganography]. Your program is going to use steganography to hide one image inside another image by changing pixels.

Write a Java program that does 1) encoding - obtains two images (e.g. source and target) and embeds the source image inside the target image and 2) decoding - obtains an image that has another image embedded inside it along with the width and height of the hidden image. Your program should allow the user to select which option to use (encode or decode) and to select the density (number of pixels to skip between each target pixel before placing each source pixel).

Besides the main method, you will need at least two other methods:

1) public static void encode (Picture sourcePic, Picture targetPic, int density)

2) public static Picture decode (Picture sourcePic, int density, int width, int height)

NOTE 1: For part 1, make sure the target picture is “big” enough to hold the source picture with the chosen density.

NOTE 2: You will need to use the Scanner class (java.util.Scanner) to read the user’s choice for the option from System.in.  You need to import java.util.Scanner, and declare a variable of type Scanner (i.e. Scanner scan = new Scanner (System.in)) and associate it with System.in. scan.nextInt can be used to get the next integer while scan.next().charAt(0) can be used to get the next character.

Use FileChooser.pickAFile to select the files holding the two pictures as well as the picture with the embedded image.

NOTE 3: Include error handling in case the user does not select option 1 or 2.

NOTE 4: To help make grading easier for me, please write the target file in 1) to "C:/Documents and Settings/wayne/Desktop/images/coded.jpg".

Test your program with several examples. I will test with my own pictures.  I found that anything bigger than 800 x 600 might cause Java to run out of memory and that a small image of 40 x 30 allows for a density of about 400.

Submit the .java file containing your program.

Grades are determined using the following scale:

Grading Rubric  (Word document)