spread spectrum watermarking for hiding data on a image
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
i have written the code for spreading a water,ark on a image, based on spread spectrum watermarking. i am not getting the recovered watermark properly. since the programe is running succesfully and not showing any errors, i cudnt find out reason for not getting the output. please help me to rewrite the same. program is shown below.
clc;
clear all;
close all;
k=.0009; % set the gain factor for embeding
% read in the cover object
cover_object=double(dicomread('189.dcm'));
cover_object = uint8(255*mat2gray(cover_object));
figure, imshow(cover_object,[])
title('input Image')
% determine size of watermarked image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
[fname,path]=uigetfile({'*.txt';'*.*'},'selct file');
path=[path fname];
A=importdata(path);
x=A(1);
for i=2:size(A,1)
x=strcat(x,'\n');
x=strcat(x,A(i));
end
x=x{1};
c=dec2bin(x,8);
y=c(1,:);
for i=2:size(c,1)
y=strcat(y,c(i,:));
end
for i=1:size(y,2)
z(i)=double(y(i));
end
z(z(:)==48)=0;
z(z(:)==49)=1;
disp(z)
message=z;
[e f]=size(message);
%message=im2bw(message);
figure, imshow(message,[])
title('watermark message Image')
message_vector=message(:);
x=length(message_vector);
els = {'p',[-0.125 0.125],0};
lshaarInt = liftwave('haar','int2int');
lsnewInt = addlift(lshaarInt,els);
[LL,LH,HL,HH] = lwt2(double(cover_object),lsnewInt);
[LL1,LH1,HL1,HH1] = lwt2(double(HH),lsnewInt);
% figure,imshow(HH,[]);
% title(' HH band');
% figure,imshow(LL1,[]);
% title(' LL1 band');
w=0;
[m n]=size(LL1);
pn=zeros(x,m*n);
% add pn sequences to HH
for kk=1:x
pn_sequence_h=round(rand(1,m*n));
pn(kk,:)=pn_sequence_h;
if (message_vector(kk) == 1)
w=w+pn_sequence_h;
end
end
host_vector=HH1(:);
Iw=host_vector+k*w';
wm=buffer(Iw,n);
% figure, imshow(wm,[])
% title(' band after watermarking')
% perform IDWT
HH = uint8(ilwt2(LL1,LH1,HL1,wm,lsnewInt));
watermarked_image=uint8(ilwt2(LL,LH,HL,double(HH),lsnewInt));
% convert back to uint8
watermarked_image_uint8=uint8(watermarked_image);
% display watermarked image
figure,imshow(watermarked_image_uint8,[])
% extraction part
title('Watermarked Image')
els = {'p',[-0.125 0.125],0};
%
lshaarInt = liftwave('haar','int2int');
lsnewInt = addlift(lshaarInt,els);
[LL,LH,HL,HH] = lwt2(double(watermarked_image_uint8),lsnewInt);
[LL1,LH1,HL1,HH1] = lwt2(double(HH),lsnewInt);
iw=HH1(:);
for kk=1:x
if (sign(corr2(iw',pn(kk,:))) < 0)
message_vector(kk)=0;
else
message_vector(kk)=1;
end
end
if (message_vector== message')
disp('same watermark')
else
disp('differentwm')
end
0 Commenti
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!