how to extract watermarked image

3 views (last 30 days)
sumedha nishane
sumedha nishane on 14 Jan 2015
procedure is as follows: 1.QR code to watermark logo 2.decompose QR code 3.load the logo which is to be watermarked 4.generate the random matrix using pn sequence% 5.XOR the logo with random matrix 6.Add it with the decomposed QR code 7.apply the inverse DWT and get QR code with watermark 8.for extraction..apply smoothing filter 9.apply DWT to received QR code 10.apply DWT to smoothed QR code 11.get the difference between both 12.generate random matrix with pn code 13. XOR random matrix with decomposed QR code
if true
clear all;
close all;
i=rgb2gray(imread('F:\QR\qrcode.jpeg')); %QR code to watermark logo%
sX=size(i);
[m n]=size(i);
[LL,LH,HL,HH]=dwt2(i,'db1'); %decompose QR code% % figure(1); % subplot(2,2,1);imshow(LL);title('LL band of image'); % subplot(2,2,2);imshow(LH);title('LH band of image'); % subplot(2,2,3);imshow(HL);title('HL band of image'); % subplot(2,2,4);imshow(HH);title('HH band of image');
L= rgb2gray(imread('F:\QR\S.jpg')); % load the logo which is to be watermarked% L1=imresize(L,[200 200]); L2=2*L1; % size(L); % imtool(L);
G=63; % Code length %generate the random matrix using pn sequence% %Generation of first m-sequence using generator polynomial [45] sd1 =[1 0 1 0 1]; % Initial state of Shift register PN1=[]; % First m-sequence for j=1:G PN1=[PN1 sd1(5)]; if sd1(1)==sd1(4) temp1=0; else temp1=1; end sd1(1)=sd1(2); sd1(2)=sd1(3); sd1(3)=sd1(4); sd1(4)=sd1(5); sd1(5)=temp1; end % figure(2); % % stem(PN1) % imshow(PN1);
% title('M-sequence generated by generator polynomial [45]') PN2=imresize(PN1,[200 200]); PN3=2*PN2; % imtool(PN3); % % figure(3); % imshow(PN3); X=xor(L2,PN3); % XOR the logo with random matrix% % figure(4); % imshow (X); B=imresize(X,[200 200]); Z=2*B;
P=imadd(HH,Z); %Add it with the decomposed QR code% % figure(5); % imshow(P);
X = idwt2(LL,LH,HL,P,'db1',sX); % apply the inverse DWT and get QR code with watermark% % figure(6); % imshow(X,[]);
%-------------------------------------------------------------------------- %--------------------------------------------------------------------------
% image extraction % K = wiener2(X,[3 3]); %apply smoothing filter% figure(7); imshow(K);
[LL1,LH1,HL1,HH1]=dwt2(X,'db1'); %apply DWT to received QR code% % figure (8); % imshow(HH1); [LL2,LH2,HL2,HH2]=dwt2(K,'db1'); %apply DWT to smoothed QR code% % figure(9); % imshow(HH2);
S=HH1-HH2; % get the difference between both% figure(10); imshow(S);
G=63; % Code length % generate random matrix with pn code% %Generation of first m-sequence using generator polynomial [45] sd1 =[1 0 1 0 1]; % Initial state of Shift register PN4=[]; % First m-sequence for j=1:G PN4=[PN4 sd1(5)]; if sd1(1)==sd1(4) temp1=0; else temp1=1; end sd1(1)=sd1(2); sd1(2)=sd1(3); sd1(3)=sd1(4); sd1(4)=sd1(5); sd1(5)=temp1; end % figure(11); % % stem(PN1) % imshow(PN1);
% title('M-sequence generated by generator polynomial [45]') PN5=imresize(PN4,[200 200]); PN6=2*PN5; % imtool(PN6); % % figure(12); % imshow(PN6); R=xor(S,PN6); % XOR random matrix with decomposed QR code% figure(13); imshow (R); F=imresize(R,[200 200]); Z1=2*F;
end

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!