20191021 CITS1001 Project 2 2019sem2: Steganography
CITS1001 Project 2 2019sem2:
Steganography
Semester 2 2019
Version 1.2 20191018
Please check the LMS for CITS1001 to ensure that you have the latest version. Version history
1. Use System.out.println statements to report unchecked exceptions eg for missing files etc. 20191008
2. Library class typo corrected, the Color class is java.awt.Color as in the lecture notes, colour info hand out etc. 20191014
3. Another typo corrected for setBlackWhite. Then scale the pixel values of secretZ by multiplying each colour value by 255 because looking at black images is not much fun. 20191018
Any questions for clarification should be posted to help1001.
Project Rules
Submission deadline: 5pm Friday 25 October 2019 Value: 15 of CITS1001
Project work to be done individually.
Project published: Sunday 6 October 2019
The project task is to write three Java classes, StegoImage, StegoCoder, StegoViewer, containing your solution to the steganography problem described below.
You must submit your project in cssubmit before the submission deadline. There are mandatory university penalties for late submission click the links for details.
You are expected to have read and understood the University Guidelines on Academic Conduct. In accordance with this policy, you may discuss with other students the general principles required to understand this project, but the work you submit must be the result of your own effort.
Project Overview
The Wikipedia entry for steganography states:
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 110
20191021 CITS1001 Project 2 2019sem2: Steganography
Steganography is the practice of concealing a file, message, image, or video within another file, message, image, or video. The word steganography combines the Greek words steganos, meaning covered or concealed, and graphe meaning writing. … The first recorded use of the term was in 1499. … Whereas cryptography is the practice of protecting the contents of a message alone, steganography is concerned both with concealing the fact that a secret message is being sent and its contents.
In the second Java project this semester you will implement a very basic steganographic system. First you will provide the ability to hide a secret image within the pixels of a cover image and to reveal such secret images. Second you will implement a demonstration class using SimpleCanvas to display images and their transformations.
To complete the project, first read and understand the problem specification in the next section. Then study the specification of project classes to understand how your implementation is to be structured. This second CITS1001 project allows more flexibility than the first for you to design your own solution.
Problem Description
This section explains how steganographic encryption and decryption is performed on images. Make sure you understand the principles of the process before you attempt to implement a solution in Java.
Steganography terminology The shared image which will be used to carry your secret message is called the cover image. The term secret is used for the greyscale image that you want to hide. You could use coloured secret messages, but they will be reduced to a black and white image and so you are likely to lose information. The encrypted image for transmission is called the message image. The message images contains the secret message but to the eye it should look the same as the cover image.
Encrypting a message has three steps. First we take a cover image and clear the low order bit of each RGB pixel. That is, we make the lowest bit zero. Each pixel has a red, green and blue value in the range 0 to 255. So clearing the low order bit is equivalent to quantizing the cover image so that it uses only 128 distinct values per pixel. This change is largely imperceptible to the eye. Call this quantized image coverQ. Second we reduce the range of pixel values used in the secret image from 0 to 255 to just 0 or 1 for each colour. This can be done by dividing each colour in the pixel by 128. Call this reduced image secretZ. Finally, add the reduced 0,1 secret image to the quantized cover image to create a coded message for sending. That is, message coverQ secretZ
Decrypting a coded message reverses the encryption process. Get the low order bits from an encrypted message by applying modulo 2 operation to each colour pixel. Let this extracted 0,1 image be secretZ. Then scale the pixel values of secretZ by multiplying
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 210
20191021 CITS1001 Project 2 2019sem2: Steganography
each colour value by 255 because looking at black images is not much fun. This should yield a twotone version of the secret image. Call this scalerecovered image secretS.
Adding Images For our purposes, adding two images together is as simple as adding the corresponding colour values together for each pixel. Given two images of the same dimensions, we will create a new image where each pixel in the new image is exactly the sum of the pixels in the original images. If your images are prepared correctly, then adding operations will always give legal 0..255 pixel colour values.
Scaling Images The colour pixel operations for generating coverQ, secretZ and secretS can each be defined using integer division and multiplications on each pixel colour. Recall that integer division in Java always produces another integer. As a result, consider what happens if we first divide a number by 10 and then immediately multiply the result by 10. The final result will always be the same as the original value with the rightmost digit replaced by a 0. For example, 354 divided by 10 is 35 and 35 times 10 is 350. Division by 2 in binary behaves the same way as division by 10 does in decimal. If we divide a binary number by 2 and then multiply by two, the result will be the same as simply replacing the last binary digit of the initial value with 0. In other words, we can clear the low order bit of a pixel by first dividing by 2 and then multiplying by 2. Quantizing cover to coverQ is done this way. Scaling secret to secretZ is done by integer division of each pixel by 128 and multiplying by 1. And scaling secretZ to secretS is done by dividing by 1 and multiplying by 255. On the other hand, extracting the low order bit from an encrypted message uses modulo 2 operator to return the low order bit which is the remainder after dividing by 2.
Image Manipulation The Java libraries BufferedImage and Color will be used for manipulating images. The BufferedImage method int getRGBint x, int y returns the value of the pixel at position x,y as an integer in the default RGB colour model TYPEINTARGB and default sRGB colourspace. Then use Color c new Color img.getRGBx,y; to convert the integer pixel value into a Color object. The colour parts of the pixel can then be accessed by c.getRed, c.getGreen, c.getBlue which return the 0..255 integer value of each colour in the pixel. You will be manipulating these three colour pixels to encrypt and decrypt steganographic images.
To get started, you will need to read images from a file. Use the ImageIO library class for these tasks as described in the CITS1001 week 9 lab class for a way to do this.
Specification of Project Classes
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 310
20191021 CITS1001 Project 2 2019sem2: Steganography
The steganography project uses a modelviewcontroller design similar to the Game of Life example studied in class.
The StegoViewer class manages a display for showing four images: a cover, secret, encrypted message and decrypted secret. The display can created using methods of the SimpleCanvas class provided. You should only require the constructor, drawImage and drawString methods from SimpleCanvas. Do not make any changes to the SimpleCanvas class because the provided class will be used to test your project.
The StegoImage class manages all the image manipulations required for steganography. Its methods transform the image by clearing bits, thresholding, and adding and subtracting images. Its constructor reads an image from a file.
The StegoCoder class is a utility class containing just two methods: one for encrypting and one for decrypting. Each method takes StegoImage objects as input and returns a StegoImage object.
StegoDemo provides methods for running the application. It contains methods that run examples for creating, encoding and decoding stego messages. Call these methods to test your project code. You are welcome to extend the project by adding your own methods to this class.
You will make use of several Java library classes in this project. The following library classes are recommended. You should not require any others. java.awt.image.BufferedImage
java.awt.Color
java.io.File java.io.IOException javax.imageio.ImageIO
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 410
20191021 CITS1001 Project 2 2019sem2: Steganography
Details of the methods required in each class are as follows. The first group of methods for each class phase 1 should be straightforward to implement, so it is recommended you complete and test those methods first. The second group of methods for each class phase 2 marked require more thought. Follow the specifications for error handling using System.out.println statements to report unchecked exceptions eg for missing files etc. Post any questions for clarification of the specifications to help1001, including the method name in the subject line.
StegoViewer class
Begin this project by implementing the user interface. Call your toplevel class StegoViewer. Use the SimpleCanvas class to create a viewer for 4 images each with height and width of 300. Your output should look something like this:
1. Use the following class variables to provide default values for the display.
public static int IMGWIDTH 300; public static int IMGHEIGHT 300; public static int CAPTIONMARGIN 50; public static int NUMIMAGES 4;
2. StegoViewer Is the constructor for creating a stego display using the default values. Your canvas should have NUMIMAGES each of the same size of IMGWIDTH by IMGHEIGHT. CAPTIONMARGIN pixels are allowed below each image for writing captions.
3. void displayImageBufferedImage image, int window This method displays its parameter image in one of the 4 windows of the canvas. Use window 0 for the cover image, 1 for the secret, 2 for the encrypted message and 3 for the decrypted secret. For example, displayImagecoverimage, 0; should display the cover image in the leftmost window and displayImagefoundsecret, 3; should display the decrypted secret image in the rightmost window.
StegoImage class
The StegoImage class implements methods for creating a single image and transforming that image by manipulating the RGB values of each of its pixels. Read the Problem Description section carefully before implementing this class.
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 510
20191021 CITS1001 Project 2 2019sem2: Steganography
1. Three fields called image, width, height with types BufferedImage, int, int respectively.
2. A constructor StegoImageString filename to create a StegoImage by reading an image from a file. The constructor should also set the width and height fields from the read image.
3. Three getter methods: getImage, getWidth, getHeight to return the field values of the class.
4. void scaleImageint div, int mult Modify this image by changing every pixel by scaling its red, green, blue components as described in the Problem Description section. Each pixel is modified by dividing by div then multiplying by mult.
5. void clearLowBit Modify this image by setting the lowest bit of each pixel colour to 0.
6. void setZeroOne Modify this image by thresholding its pixels to 0 or 1 in each pixel colour.
7. void setBlackWhite Modify this image by upscaling each 0,1 pixel to a greyscale for viewing.
8. void setToLowBit Modify this image by setting each pixel to just its low bit value 0 or 1.
9. void mergeImageStegoImage newimage Modify this image to become this newimage by adding each of their RGB pixels.
StegoCoder class
The StegoCoder class is a utility class that provides methods for the encryption and decryption of images.
1. This class has no field variables and the constructor body should be empty. It is a utility class like Math.
2. StegoImage encryptStegoImage cover, StegoImage secret Return a new message by hiding a secret in the cover image.
3. StegoImage decryptStegoImage message Return a decryption of the received message by extracting and then upscaling its low bits.
Creativity
If you have time and wish to extend your knowledge of Java, then you are encouraged to extend this project to take it further towards a complete application. It is up to you to identify, select and complete additional functionality. If you complete this section you must submit a short report about 1 page in a file called Extension.pdf. The report should include a description of the functionality you have implemented and how it was tested. Ensure that you submit a file called Extension.pdf or this part of the project will not be identified for marking.
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 610
20191021 CITS1001 Project 2 2019sem2: Steganography
For the extension you may add completely new Java classes or add new Java methods to the project classes. But remember not to change the signatures of the specified project methods. Some possible extensions could be:
Extend the stego viewer to have a richer user interface
Extend the encryption functionality, for example for to enable encryption of text in images.
Strengthen the encryption algorithm to make it more secure. In our simple version anyone who knows secrets are hidden in the low order bits can discover secrets.
Support different sizes of images by providing a method to crop or pad an image to a given width and height.
Save a stego image by writing it to an image file.
Scaffolding
Scaffolding files are provided to help you develop and test your project. Download these files from LMS and put them in your BlueJ project directory. The scaffolding code comprises:
1. SimpleCanvas.java code to create a canvas on the screen and display an image, text.
2. StegoDemo.java a demonstration class for running your application. These methods will be used for checking your submitted code.
3. The ProjectImages directory provides some example images to use for the cover or secret and some encrypted messages for you to decrypt. Place this image directory into your BlueJ project directory so that the StegoDemo class can access the images. All of the provided images are the default size of 300×300 pixels. You are welcome to work with your own images but you may need to resize them.
JUnit test classes will be provided by week 11.
See the week 9 lab, tutorial code and lecture notes for examples of how to use images and colours in Java.
Project Management Tips
Planning
Students should plan to spend around 18 hours working on this project during the 3 weeks to the deadline. The time might be broken down as follows.
Understanding the project description and clarifying any questions 3 hours Reviewing code examples from the labs and text book 3 hours
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 710
20191021 CITS1001 Project 2 2019sem2: Steganography
Implement and test the StegoImage class 4 hours
Implement and test the StegoCoder class 3 hours
Implement and test the StegoDemo class 3 hours
Cleaning up and formatting your code and submitting the project 2 hours
Before starting this project, students are expected to have studied the lectures, recommended reading from the text book, and completed the assigned labs for weeks 1 to 9 of CITS1001.
It is recommended that you tackle the project in the order given above; that you compile frequently; and that you test and run the code after completing each method, to ensure your code behaves as you think it ought, and does not fail any tests. You can gain good marks even if you do not complete all the methods, so long as the code you have written compiles and runs correctly. But if you submit a large body of code that does not compile or that crashes then few marks can be awarded.
Help
Timetabled lab sessions will run as usual during the project weeks and facilitators will be available to help you at any of the 5 lab sessions per week see the CITS1001 timetable for lab time details. Remember this project is to be done individually: you may discuss with the facilitators and other students the general principles required to understand this project, but the Java code you submit must be the result of your own effort. Suspected academic misconduct will be referred to the Academic Conduct Advisor for formal review.
Post any questions or requests for clarification to help1001 but do not post any project code on help1001.
Submission
Submit your completed java source files in the CITS10012Project2 area of https:secure.csse.uwa.edu.auruncssubmit.
Do submit StegoImage.java, StegoCoder.java and StegoViewer.java source files.
Do not submit class files or a zip of your BlueJ directory. Ensure you have completed the author and version date tags in each of your submitted files. If you have completed an extension for the project submit Extension.pdf and a zip of any additional files needed to run your extension. You can submit as often as you wish to backup your work. The final submitted version of your code will be the one used for marking. The file names, class names, method names and signatures in your submitted code must match the specifications exactly because marking process is partly automated. If your code can not be compiled with the StegoDemo and JUnit test cases provided, then your submission may be awarded 0 for correctness and completeness.
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 810
20191021 CITS1001 Project 2 2019sem2: Steganography
Assessment
Your submission will be assessed on
completeness: how many of the methods you have written according to the specifications;
correctness: whether your methods implement the specifications exactly; clarity: whether your code is clear to read and wellconstructed.
additional creativity: any extensions you make to the specified project.
Completeness 2 guidelines
0 The submission does not contain all three project .java files or the submitted files do not compile.
1 The submitted .java files compile correctly with no other classes present. 2 Class names and public method signatures are exactly as specified in this document. They run correctly with the provided ExampleDemo.java class.
Correctness 8 guidelines
The submitted project classes are correct according to the specifications in this document. Correctness will be evaluated using JUnit tests and by running examples similar to the demonstrator. Any questions or requests for clarification on the specifications should be posted to help1001. Use the method name in the subject line.
4 StegoImage 2 StegoCoder 2 StegoViewer
Clarity and Design guidelines 8
1 author and version fields in the class Javadoc header are completed with your name, student number and date in all studentwritten classes. All public methods you implement have Javadoc comments that explain what the method does and their parameters and return values if any. Follow the style of example classes provided in the labs and text book. If the logic used in a method is particularly complex, a brief comment is included explaining the strategy. But code should not be commented unnecessarily.
1 Appropriate names are used for all variables, following Java case conventions. No redundant code e.g. empty else clauses in conditionals.
1 Code is neatly and consistently laid out and indented, with lines no longer than 80 characters. Use the BlueJ autolayout feature found under the edit menu to assist with this.
3 Classes are clearly organised with appropriate reuse of code and use of helper methods. The same code is not duplicated in multiple methods.
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 910
20191021 CITS1001 Project 2 2019sem2: Steganography
2 Error handling is organised consistently with appropriate use of exceptions.
Marks for clarity and design will be proportioned according to the completeness of the code.
Creativity 2
0 No Extension.pdf is submitted
1 Extension.pdf and new code is submitted. The extension functionality is clearly described and makes reasonable but small improvements to the basic project functionality.
2 Extension.pdf and new code is submitted. The extension functionality is clearly described and makes major improvements to the basic project functionality.
Good luck!
Rachel CardellOliver, CITS1001 Unit Coordinator
Department of Computer Science and Software Engineering
https:lms.uwa.edu.aubbcswebdavpid1515649dtcontentrid225810621coursesCITS1001SEM22019project22019sem228529.html 1010