Clear Filters
Clear Filters

how to get the same image after extract watermark

2 views (last 30 days)
clear all;
% read in the cover object you want to use for embedding
file_name='lena512.bmp';
cover_object=imread(file_name);
% read the message image you want to hide in the cover image
file_name='watermark.jpg';
message=imread(file_name);
% determine the size of cover image used for embedding
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
% determine the size of message object to embed
Mm=size(message,1); %Height
Nm=size(message,2); %Width
%y = uint8(wgn(Mm,Nm,1));
% title the message object out to cover object size to generate watermark
for ii = 1:Mc
for jj = 1:Nc
watermark(ii,jj)=message(mod(ii,Mm)+1,mod(jj,Nm)+1);
end
end
% set the LSB of cover_object(ii,jj) to the value of the MSB of watermark(ii,jj)
watermarked_image=cover_object;
for ii = 1:Mc
for jj = 1:Nc
watermarked_image(ii,jj)=bitset(watermarked_image(ii,jj),1,watermark(ii,jj));
end
end
% write to file the two images
imwrite(watermarked_image,'lsb_watermarked.bmp');
figure(1)
imshow(watermarked_image,[])
title('Watermarked Image')
extarct code
clear all;
% read in watermarked image
file_name='lsb_watermarked.bmp';
watermarked_image=imread(file_name);
% determine size of watermarked image
Mw=size(watermarked_image,1); %Height
Nw=size(watermarked_image,2); %Width
% use lsb of watermarked image to recover watermark
for ii = 1:Mw
for jj = 1:Nw
watermark(ii,jj)=bitget(watermarked_image(ii,jj),1);
end
end
% scale the recovered watermark
watermark=(256*double(watermark));
% scale and display recovered watermark
figure(1)
imshow(watermark,[])
title('Recovered Watermark')
the ortiginal watermark image
watermark after extract
how i fix this?

Answers (0)

Community Treasure Hunt

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

Start Hunting!