请将下列代码改成二维Arnold置乱提取:blocks = mat2cell(P_watermarked, blockSize * ones(1, floor(height/blockSize)), blockSize * ones(1, floor(width/blockSize))); B = zeros(0); for k = 1:numBlocks block = double(blocks{k}); DCT_block = dct2(block); % DCT变换 B(k) = DCT_block(I(k)); end B = reshape(B, 64, []); [Uw, Sw, Vw] = svd(B); Fw = U1*Sw*V1'; Ww = (Fw - S)/alpha; Ww = rearnold(Ww, 1, 1, key1); imshow(Ww,[]),title('提取水印') % 性能测试 psnrValue = psnr(double(P), P_watermarked); nc = max(max(normxcorr2(Ww, W))); disp(['PSNR: ', num2str(psnrValue)]); disp(['Normalized Correlation (NC): ', num2str(nc)]);
时间: 2023-09-06 22:08:43 浏览: 86
matlab代码arnold置乱
5星 · 资源好评率100%
首先将代码中的一维Arnold置乱函数 "rearnold" 改成二维的 "rearnold2",然后在提取部分添加二维Arnold置乱的代码即可:
blocks = mat2cell(P_watermarked, blockSize * ones(1, floor(height/blockSize)), blockSize * ones(1, floor(width/blockSize)));
B = zeros(0);
for k = 1:numBlocks
block = double(blocks{k});
DCT_block = dct2(block); % DCT变换
B(k) = DCT_block(I(k));
end
B = reshape(B, 64, []);
[Uw, Sw, Vw] = svd(B);
Fw = U1*Sw*V1';
Ww = (Fw - S)/alpha;
Ww = rearnold2(Ww, key1); % 添加二维Arnold置乱的代码
imshow(Ww,[]),title('提取水印')
% 性能测试
psnrValue = psnr(double(P), P_watermarked);
nc = max(max(normxcorr2(Ww, W)));
disp(['PSNR: ', num2str(psnrValue)]);
disp(['Normalized Correlation (NC): ', num2str(nc)]);
阅读全文