Write a program to hide an image inside of another image a) allocate memory for
ID: 3763560 • Letter: W
Question
Write a program to hide an image inside of another image
a) allocate memory for a properly-sized multi-dimensional array
b) for each pixel in the hidden image, encode that information along with the mask image
c) display the new image and write it to a file
Write a program to unmask the hidden image from an encoded image
a) allocate memory for a properly-sized multi-dimensional array
b) for each pixel in the encoded image, pull out the black and white information
c) display the hidden image
Important Note: you need to add the following line:
cvWaitKey(0); // Wait for a keystroke in the window
right before the ‘return 0;’ line in your main function. This will hold the windows open until you click on one of the windows and press a key.
2. What you need to do
If you type ‘make’ in the project5 directory, you’ll get output like this:
make: *** No rule to make target `solve_image.o', needed by `solve_image’. Stop.
this means that you need to create a file ‘solve_image.c This is where you should put the main function for the portion of the project to find the hidden image. Similarly, you should create a file, make_steg.c for the portion of the project that encodes the image.
Your goal (for the encode portion): to write a program that will:
prompt the user to enter two filenames of images (we have provided example .ppm image files to be used)
copy those images to an array (the ImageData struct, see provided code above)
create new ImageData object to hold changed image
allocate memory for the new image data
for each pixel in the image
drop the least significant bit from the mask image pixel value
add a 1 to that pixel value if the corresponding hidden pixel value should be white
add a 0 (or don’t) to that pixel value if the corresponding hidden pixel value should be black
display the new image
Your goal (for the solve portion): to write a program that will:
take a command-line argument which is the filename of an image (we have provided two ppm files (one grayscale, one black and white) to test with)
copy that image to an array (the ImageData struct, see provided code below)
create new ImageData object to hold changed image
allocate memory for the new image data
for each pixel in the image
if the last bit is zero
make the corresponding pixel in the new image black
if the last bit is one
make the corresponding pixel in the new image white
display the new image
If you recall from before, to do this you need to:
create new files named ‘solve_image.c’ and ‘make_steg.c’
put a ‘main’ functions in those files
it is in these files where you will put your code.
Explanation / Answer
Try this i gave this code upto my knowledge
c = imread('any_image.jpg');
message = 'hi this is sagar from nagpur..'
message = strtrim(message)
m = length(message) * 8;
AsciiCode = uint8(message);
binaryString = transpose(dec2bin(AsciiCode,8));
binaryString = binaryString(:);
N = length(binaryString);
b = zeros(N,1); %b is a vector of bits
for k = 1:N
if(binaryString(k) == '1')
b(k) = 1;
else
b(k) = 0;
end
end
s = c;
height = size(c,1);
width = size(c,2);
k = 1; Array=[];l=1;my=1;
for i = 1 : height
for j = 1 : width
LSB = mod(double(c(i,j)), 2);
if (k>m || LSB == b(k))
s(i,j) = c(i,j);
l=k+1;
else
if(LSB == 1)
s(i,j) = c(i,j) - 1;
else
s(i,j) = c(i,j) + 1;
Array(my)=l;
l=l+1;
my= my + 1;
end
k = k + 1;
end
end
end
imwrite(s, 'hiddenmsgimage.bmp');
k = 1;my=1;ur=1;
for i = 1 : height
for j = 1 : width
if( k<=m )
if (my<numel(Array) && Array(my)==ur)
b(k)=~(mod(double(s(i,j)),2));
else
b(k) = mod(double(s(i,j)),2);
end
k = k + 1;
my= my + 1;
end
ur=ur+1;
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.