image and text steganography
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Geoff Hayes
2014-10-28
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.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!