Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Provided Files M_M.bmp, CookieMonster.bmp In this assignment, we will try to hide a message image within a context image. Then we will also mplement a

image text in transcribed

Provided Files M_M.bmp, CookieMonster.bmp In this assignment, we will try to hide a message image within a context image. Then we will also mplement a function to recover that message image from a combined image. FudanImgLib.py provides image loading/saving and some other supports, do not change anything in steganography. py contains starter code for this PA. Complete functions with \#TODO comments by following the instructions below. Please create steganopgrahy.py by pasting the following code from FudanImgLib import * def get_least_significant2(num) : \#\#TODO def get_most_significant2(num): \#\#TODO def embed_digits2(context_val, message_val): def hide_secret_message_2bits (context_img, message_img): def recover_secret_message_2bits(img_with_message) : \#TODO Here are the details about each function. def get_least_significant2(num) This method takes in an integer and returns the two least significant bits (rightmost two) as an integer. - You can assume num will always be an integer between 0 and 255 inclusive. - For example, get_least_significant2(255) should return 3 (since the rightmost two bits of 11111111 is 11 ) and get_least_significant2(253) should return 1 (since the rightmost two bits of 11111101 is 01). def get_most_significant2(num) This method takes in an integer and returns the two most significant bits (leftmost two) in decimal form. - You can assume num will always be an integer between 0 and 255 inclusive. - For example, get_most_significant2(200) should return 3 (since the leftmost two bits of 11001000 is 11) and get_most_significant2(150) should return 2 (since the leftmost two bits of 10010110 is 10 ). def embed_digits2 (context_val, message_val) This method takes in two integers and returns the result of replacing the two least significant digits (rightmost two) in context_val with the value of message_val. - You can assume that context_val will always be an integer between 0 and 255 inclusive (i.e. an 8-bit integer) and message_val will always be an integer between 0 and 3 inclusive (i.e. a 2 bit integer). - Hint: One way to approach this problem is first to "clear" the two least significant digits of context_val (i.e., set them to 0 ) and then use addition to add in message_val . There are many ways you can clear these two digits, but a quick way is just to shift right and then shift left again. E.g.: 00111111 shift right 2 yields 0000 1111. If you shift 00001111 left 2 you will get 00111100. def hide_secret_message_2bits(context_img, message_img) This method takes in two 2D array of tuples (similar to the image format in PA6) and returns a new image with image message_img hidden in image context_img 's least significant 2 bits. - You need to hide the most significant 2 bits of message_img 's RGB values in the least significant 2 bits of the corresponding RGB values of context_img - You can assume that message_img will always be the same size as context_img - This method should make a copy of the image stored in context_img and modify and return that copy. It should not modify the input context_img image. - Hint: make use of the functions that you already implemented above. def recover_secret_message_2bits(img_with_message) Given an image(which is a 2D array of tuples), this method should return a 2D array of tuples that is the hidden message image in img_with_message . - You can assume that the message is hidden in the least significant 2 bits of the img_with_message image. - Your method won't know the dimension of the hidden image so all you need to do is to go through the entire img_with_message image. The returned image should have the same size as img_with_message . - This method should not modify the input img_with_message image. - Again, functions that you already implemented may help you. Hide and recover After implementing all the above functions, use them to hide the CookieMonster image into the M_M image. In terminal, load M_M. bmp (the context image) and CookieMonster. bmp (the message image) as 2D arrays of tuples. Then call hide_secret_message_2bits to get the resulting image that encrypted the message image in the last two bits of the context image. Save the resulting image to a file called recovered image with message. Finally, save the recovered image to a file called recMessage. bmp . - When finished, two additional files, M_MWithMessage. bmp and recMessage. bmp, should be created in your workspace. - For your reference, the created images should look like below: M_MWithMessage.bmp

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

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

Students also viewed these Databases questions

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago