image and text steganography

can any one correct this code please ?
this code hide the input message text in the cover image but the encoded message is not the input text (embedded text)
Simple Wavelet Steganography: Hide Message in Image using wavelet Transform Code MATLAB :
%%%%%%%%%%%%%%Encoding.m
clear
close all
clc
im=imread('cameraman.tif');
wname='haar';
msg='Grasshopper Network';
data=[];
for(i=1:length(msg))
d=msg(i)+0;
data=[data d];
end
imshow(im);
[cA1,cH1,cV1,cD1] = dwt2(im,wname);
dec1 = [cA1 cH1; cV1 cD1 ];
figure;imshow(uint8(dec1));
M=max(data);
data_norm=data/M;
n=length(data);
[x y]=size(cH1);
cH1(1,1)=-1*n/10;
cH1(1,2)=-1*M/10;
for(i=1:1:ceil(n/2))
cV1(i,y)=data_norm(i);
end
for(i=ceil(n/2)+1:1:n)
cD1(i,y)=data_norm(i);
end
CODED1=idwt2(cA1,cH1,cV1,cD1,wname);
figure;imshow(uint8(CODED1))
[x y]=size(cA1);
imshow(uint8(CODED1))
ms=abs(CODED1-double(im));
ms=ms.*ms;
ms=mean(mean(ms))
ps= (255*255)/ms;
ps=10*log10(ps)
imwrite(uint8(CODED1),'Stego.bmp','bmp');
return
%%%END of encoding.m%%%%%%%%%%%%%%%%
%%%%%Decoding.m%%%%%%%%%%%%%%%%%
im=imread('Stego.bmp');
[cA11,cH11,cV11,cD11] = dwt2(CODED1,wname);
data=[]
data_norm=[];
n=ceil(abs(cH11(1,1)*10));
M=ceil(abs(cH11(1,2)*10));
for(i=1:1:ceil(n/2))
data_norm(i)=cV11(i,y);
end
for(i=ceil(n/2)+1:1:n)
data_norm(i)=cD11(i,y);
end
data=ceil(data_norm*M)-1;
msg='';
for(i=1:length(data))
msg=strcat(msg,data(i));
end
msg

6 Comments

Geoff Hayes
Geoff Hayes on 27 Oct 2014
Edited: Geoff Hayes on 27 Oct 2014
eng - when you say that the encoded message is not the input text do you mean that the decoded message is not Grasshopper Network, but something else? Is it Fq`rrgnoodqMdsvnqj instead?
yes,i mean this sorry the decoded text is not the same the encoded text some letters is not correct
What does the decoded text look like?
when i have entred the encoded text 'Grasshopper Network' the decoded text is 'GqasshnooeqNesvnqj'
and any input text the decoded also is not the same
Attach your m-file with the paperclip icon, or read this.
So some of the characters in the decoded message are off by one. This could be due to the fact that the encoded image, CODED1, is cast as uint8 before being written to file, and then the decoded message is obtained as
data=ceil(data_norm*M)-1;
The subtraction of one works for some of the characters in the message (mapping them back to their original value) while it fails for others. You could contact the author of the code (copied from here), as there seems to be some known problems with the decoding.

Sign in to comment.

Answers (0)

Categories

Find more on Wavelet Toolbox in Help Center and File Exchange

Products

Asked:

eng
on 26 Oct 2014

Edited:

on 11 Jan 2016

Community Treasure Hunt

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

Start Hunting!