Implementing steganography in wavelet transform

15 views (last 30 days)
Hi
here's my code for implementing steganography in wavelet transform, trying to hide text in cover image, but the problem is that when the text message is longer that 'hello' it wont work, I dont know how to fix it :)
by the way, If you can help me with other source codes for implementing steganography in wavelet transform especially image steganography in wavelet transform, I would really appreciate it :)
%clear all
%close all
%clc
im=imread('cameraman.tif');
wname='haar';
msg='Hello world';
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
%%End of Decoding.m
  3 Comments
Mia Gonzalez
Mia Gonzalez on 16 Nov 2019
Do you know how we can do the decoding phase using the saved image from the encoding, rather than the variable CODED1? When I do, I am not able to recover the message.
Erwin Langi
Erwin Langi on 29 Jul 2020
Mia Gonzalez, I think i found the solution for your decoding phase and the variable CODED1 can be used in decode session.
I simply take the decoding phase to a new script and i change the msg variable to msg1 (or you can change to other name). After i run the encoding phase, then i run the decoding phase. done
the other way is to make function script that return stego, msg, ect..

Sign in to comment.

Answers (0)

Categories

Find more on Wavelet Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!