CDMA based using multiple PN sequences embeded into whole object

조회 수: 2 (최근 30일)
amitesh kumar
amitesh kumar 2011년 3월 12일
hii everyone
I am trying to run this watermark embedding code. my cover image size is 512x512, watermark image is 64x64 and key image is also having size is 64x64.
clear all;
% save start time
start_time=cputime;
k=2; % set the gain factor for embeding
% read in the cover object
file_name='lena.tif';
cover_object=double(imread(file_name));
% determine size of watermarked image
Mc=size(cover_object,1); %Height
Nc=size(cover_object,2); %Width
% read in the message image and reshape it into a vector
file_name='watermark1.bmp';
message=double(imread(file_name));
Mm=size(message,1); %Height
Nm=size(message,2); %Width
message_vector=round(reshape(message,Mm*Nm,1)./256);
% read in key for PN generator
file_name='key.bmp';
key=double(imread(file_name))./256;
% reset MATLAB's PN generator to state "key"
rand('state',key);
watermarked_image=cover_object;
% when message contains a '0', add pn sequence with gain k to cover image
for kk=1:length(message_vector)
pn_sequence=round(2*(rand(Mc,Nc)-0.5));
if message(kk) == 0
watermarked_image=watermarked_image+k*pn_sequence;
end
end
% convert back to uint8
watermarked_image_uint8=uint8(watermarked_image);
% write watermarked Image to file
imwrite(watermarked_image_uint8,'cdma_watermarked.bmp','bmp');
% display processing time
elapsed_time=cputime-start_time,
% % calculate the PSNR
% psnr=psnr(cover_object,watermarked_image_uint8,Mc,Nc),
% display watermarked Image
figure(1)
imshow(watermarked_image_uint8,[])
title('Watermarked Image')
but i am getting following error message after executing code
??? Error using ==> reshape
To RESHAPE the number of elements must not change.
Error in ==> TEST12 at 22
message_vector=round(reshape(message,Mm*Nm,1)./256);

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by