cdma_embed.m
上传用户:haoweisi88
上传日期:2010-02-03
资源大小:1950k
文件大小:2k
- %Name: Chris Shoemaker
- %Course: EER-280 - Digital Watermarking
- %Project: CDMA based using multiple PN sequences embeded into whole object
- % Watermark Embeding
- clear all;
- % save start time
- start_time=cputime;
- k=12; % set the gain factor for embeding
- % read in the cover object
- file_name='test.jpg' %'_lena_std_bw.bmp';
- cover_object=double(imread(file_name));
- figure(1)
- imshow(cover_object,[]);
- % 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='_copyright_small.bmp';
- message=double(imread(file_name));
- Mm=size(message,1); %Height
- Nm=size(message,2); %Width
- message_vector=fix(reshape(message,Mm*Nm,1)./2);
- % 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',1);
- %rand('state',key);
- watermarked_image=cover_object;
- % when message contains a '0', add pn sequence with gain k to cover image
- pn_sequence=round(2*(rand(Mc,Nc)-0.5));
- psnr1=psnr(cover_object,pn_sequence,Mc,Nc),
- %for kk=1:length(message_vector)
-
-
- %if message(kk) == 0
- % if message(kk) == 1
-
- % end
- %end
- watermarked_image=watermarked_image+k*pn_sequence;
- % 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(2)
- imshow(watermarked_image_uint8,[])
- figure(3)
- imshow(pn_sequence,[])
- title('Watermarked Image')