Azzera filtri
Azzera filtri

Image steganography in matlab:Retrieve hidden Image

2 visualizzazioni (ultimi 30 giorni)
Jessica
Jessica il 17 Apr 2014
Risposto: riyaz nadaf il 26 Gen 2019
I am trying to retrieve the image hidden in another image. This is the code I have so far but it is not working correctly. Can anyone tell me what Im doing wrong?
I1 = imread('c:/df/img/Lena1.png');
I2=I1;
output_stream="";
data_size_s=""; %In bytes and as a string
%We read the size of the target from the stego image (first 16 bits)
k=1;
for i=1:rows(I2)
for j=1:columns(I2)
if (k<18) s=dec2bin(double(I2(i,j,1)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
if (k<18) s=dec2bin(double(I2(i,j,2)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
if (k<18) s=dec2bin(double(I2(i,j,3)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
end
end
%We pass the size of the target image from string to integer
target_rows=uint32(bin2dec(substr(data_size_s, 1,8)));
target_columns=uint32(bin2dec(substr(data_size_s,9,8)));
data_size_int=target_rows*target_columns; % Data Size in bytes as integer
%We read the output_stream from the stego image
total_data_size=(8*data_size_int)+16; % Total length of the output stream (header + target data)
k=1;
for i=1:rows(I2)
for j=1:columns(I2)
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,1)),8); output_stream=strcat(output_stream,s(8)); k++; endif
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,2)),8); output_stream=strcat(output_stream,s(8)); k++; endif
if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,3)),8); output_stream=strcat(output_stream,s(8)); k++; endif
end
end
I3_rows=uint32(bin2dec(substr(output_stream,1,8)));
I3_columns=uint32(bin2dec(substr(output_stream,9,8)));
k=17;
I3=uint8(zeros(I3_rows,I3_columns,3));
% We create a empty crey-scale image with the dimensions of the target
total_data_size=(8*data_size_int)+16;
for i=1:I3_rows
for j=1:I3_columns
if (k<=total_data_size) I3(i,j,1)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
if (k<=total_data_size) I3(i,j,2)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
if (k<=total_data_size) I3(i,j,3)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
end
end
%We show the hidden image.
imshow(I3);
  3 Commenti
Jessica
Jessica il 17 Apr 2014
because I am not getting the correct image as a result. This is the image I am receiving.
Walter Roberson
Walter Roberson il 17 Apr 2014
There is nothing obviously wrong with that output. I probably would not have chosen to embed that particular image, but that's just me.

Accedi per commentare.

Risposte (3)

Image Analyst
Image Analyst il 17 Apr 2014
You need to go through the normal debugging process. We don't know your algorithm for hiding and recovering your image, and I don't really have time to learn it, as fascinating as it might be. We can fix an error message for you but we can't do complicated algorithm development.
  5 Commenti
Walter Roberson
Walter Roberson il 18 Apr 2014
Modificato: Walter Roberson il 18 Apr 2014
For what it's worth, I think you are probably putting the extracted information into the wrong place in the array. When you see exactly three fuzzy repeats of an image you should suspect that you have put three color planes horizontally next to each other instead of stacking them in the third dimension. Consider that if ColorMatrix is something by something by 3 then
reshape( permute(ColorMatrix, [1 3 2]), size(ColorMatrix) )
is going to have the right dimensions to look like a color matrix, but the data will be in the wrong order.
Image Analyst
Image Analyst il 18 Apr 2014
Jessica, can you post both the original "cover" image, and the original "image to be hidden" and which you hope to recover/extract?

Accedi per commentare.


Chris
Chris il 19 Apr 2014
I think what you need to do is determine if the image is RGB or Grayscale and then enter a correct loop for processing either a RGB image or Grayscale image. I think the 17th bit in the output_stream will be the determining factor for you.

riyaz nadaf
riyaz nadaf il 26 Gen 2019
i did this project. if you want matlab code contact
riyaznadaf034@gmail.com

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by