基于DCT变换的图像水印方法
书本中提供的方法,我总是无法得到很好的效果。也许是我的小改出现了问题吧。
carrierI=imread('cameraman.tif');
watermarkI=imread('21.bmp');
watermarkI=imbinarize(watermarkI);
嵌入水印
%设置相同的随机数生成器状态J,作为检测时的系统密钥K
pn_sequence_zero = round(rand( 1, sum(DCT_coef(:))));
watermarkedI=DCT_encode(carrierI,watermarkI,DCT_coef,k,pn_sequence_zero);
xsz =255 * 255 * numel(carrierI)/ sum( sum( ( carrierI -
watermarkedI).^2));
fprintf("图像失真程度指标:峰值信噪比PSNR=%g",psnr);
图像失真程度指标:峰值信噪比PSNR=48.5722
提取水印
%设置相同的随机数生成器状态J,作为检测时的系统密钥K
pn_sequence_zero = round(rand( 1, sum(DCT_coef(:))));
watermark2I=DCT_decode(watermarkedI,carrierI,DCT_coef,pn_sequence_zero);
sim = corr2( watermarkI,watermark2I );