Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Add the following method to Steganography.java: * Sets the highest two bits of each pixel's colors * to the lowest two bits of

image text in transcribedimage text in transcribed

4. Add the following method to Steganography.java: * Sets the highest two bits of each pixel's colors * to the lowest two bits of each pixel's color o s public static Picture revealPicture(Picture hidden i) { Picture copy = new Picture(hidden) e ; Pixel[][] pixels = copy.getPixels 2D(); Pixel[][] source = hidden.getPixels2D(); for (int r = 0; r < pixels.length; r++) { for (int c = 0; c < pixels[0].length; c++ t ) { Color col= source[r][c].getColor(); /* To be Implemented */ } } return copy; } In the area specified "To be implemented", implement the process to isolate the rightmost two bits of the color values of col and move them to the leftmost position in copy. 5. Add the following to the main method: Picture copy3 = revealPicture (copy2); copy3.explore(); These lines take the previously hidden color and then reveal it. These techniques will be explored more in Activity 2. In the code below, notice that the method set Low has a Pixel p and a Color c as parameters. This color is the new information that will be stored in the now cleared bits. To store this information, a pixel is modified by adding the leftmost two bits of the color values of c (isolated by dividing by the value identified above) to the color values of Pixel p. After Call to setLow Red Green Blue Original Pixel Values Decimal Binary 139 66 16 Parameter Color c Value Decimal Binary 1000 1011 218 0100 0010 112 0001 0000 214 Decimal 139 65 11010110 19 1101 1010 0111 0000 Binary 1000 1011 0100 0001 0001 0011 So, in the code below, the rightmost two bits in the original pixel's colors are being set to the leftmost bits of another color c by adding those bits from c to the color values of the pixel (after the pixel's rightmost two bits have been cleared). 1. In Steganography.java add the following method: * Set the lower 2 bits in a pixel to the highest 2 bitsin c */ public static void setLow (Pixel p, Color c) { /* To be implemented */ |} In the area specified "To be implemented," implement the process described above to replace the lowest two bits of each color value with the highest two bits of color value of the parameter c. 2. Add a static method testSet Low that accepts a Picture and a color as parameters and returns a new Picture object with the lowest two bits of each pixel set to the highest two bits of the provided color. 3. Change main in Steganography.java to contain the following lines: Picture beach2 = new Picture ("./labs/steganography/beach.jpg"); beach2.explore(); Picture copy2 = testSet Low(beach2, Color.PINK); copy2.explore(); Note that again, the two pictures appear to be identical, yet looking at individual pixels, you'll see that the color values differ between 0 and 3.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Programming With Java A Problem Solving Approach

Authors: John Dean

3rd International Edition

1260575241, 9781260575248

More Books

Students also viewed these Programming questions

Question

What does the equals method defined in the String class compare?

Answered: 1 week ago

Question

What are two ways to cause a window to be a certain size?

Answered: 1 week ago