4. Add the following method to Steganography.java: * Sets the highest two bits of each pixel's...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Posted Date:
Students also viewed these programming questions
-
This code will store messages consisting of uppercase letters and spaces in a picture. To achieve this, the 26 letters will be represented by numbers (1-26 where A = 1, etc.), a space will be...
-
1. A man digs 3 cubic feet per minute. Express the digging rate in cubic meters per hour. = ( 0 . 3 0 5 f t A ) 0 . 3 4 B ) 2 . 3 4 C ) 3 6 . 2 D ) 1 6 7 . 4 E ) 6 4 0 0 2. The x -...
-
Pinkerton Stores is authorized to issue 13,000 shares of common stock. During a two-month period, Pinkerton completed these stock-issuance transactions: Mar 23 Issued 3,000 shares of $6.00 par common...
-
1. Late-arriving bills pertaining to the 20-5 year were Supplies Miscellaneous Expense Truck Expense Total $ 56.20 26.85 563.85 $646.90 2. Office supplies on hand at October 31 are valued at $360. 3....
-
Locate sample affidavits used in a civil litigation for both California court and federal court. What do they have in common? Are there any striking differences?
-
On the last day of the fiscal year, Stanley Carpenter comes to you for a favor. He asks that you enter a check for $2,000 to CD Company for Miscellaneous Expense. You notice the invoice looks a...
-
Your firm anticipates receiving a $10 million payment in 3 months, and wants to invest that money for 3 months at ICELIBOR rates for 3 months (or 91 days) once they receive it. You contact your bank...
-
We have learned how companies come up with their interim financial reports. Please pick a publicly traded company of your choice, look up its more recent quarterly report on its website, and comment...
-
A new Hyundai Triburon has a book value of $22,000, and after 2 years a book value of $14,000. What is the cars value in 4 years? Apply the formula N = N 0 e -rt , where N represents the value of the...
-
Company is leasing production equipment where the estimated useful life of the equipment is 1 1 years, and the lease term is 8 years. As per the current market, the fair value of the equipment is $ 1...
-
What's the difference between internal interfaces versus external? Which is more important, internal interface or external interfaces?
-
1.What are external costs? When external costs are present, will market allocation result in too much or too little output of the good relative to the ideal efficiency level? Explain. 2.What is a...
-
Outline what you think would happen to a country's economy (either our own, another, or even some hypothetical country) if the scarce and non-renewable resource oil was suddenly all used up...
-
1. A Ford F-150 currently costs USD 45,000 in the US, and MXN 640,000 in Mexico. The current exchange rate is MXN 20 per USD. a. Given these prices, what is the PPP exchange rate between USD and MXN?...
-
Gates Rubber Company sells cases of hydraulic hoses for $125. Direct materials and direct labour (together) per case are $75. There is an additional selling commission of $12.50 per case. Fixed...
-
During the month, services performed for customers on account amounted to $7,500 and collections from customers in payment of their accounts totaled $6,000. At the end of the month, the Accounts...
-
What does the equals method defined in the String class compare?
-
What are two ways to cause a window to be a certain size?
-
Write a sufficient stopping condition for the recursive calculation of a factorial.
-
Derive the equation of motion and natural frequency for mass \(m\) shown in Figure 2.57. Assume the pulleys are massless, the cable is inextensible, and let the spring constant be \(k\). eeeee k...
-
Derive the equation of motion and natural frequency for mass \(m\) shown in Figure 2.58. Assume the pulleys are massless, and let the spring constants be \(k_{1}\) and \(k_{2}\). Let \(x_{1}\) and...
-
Show that the period of free vibration of a load weighing \(W\) suspended from two parallel springs, as shown in Figure 2.59, is given by \(T\), \[ T=2 \pi \sqrt{\frac{W}{g\left(k_{1}+k_{2} ight)}}...
Study smarter with the SolutionInn App