1.算法运行效果图预览
2.算法运行软件版本
matlab2022a
3.算法理论概述
水印嵌入原理
水印提取原理:
将嵌入水印的图像再次进行二维CS-SCHT变换。
提取变换后的低频系数,并按照嵌入时的规则去除宿主图像内容的影响,恢复出水印信息 Wm′。
4.部分核心程序
```% figure;
% subplot(121);
% imshow(Irgb)
% subplot(122);
% imshow(I1)
%RGB转换为RGB2YUV
R = double(Irgb(:,:,1));
G = double(Irgb(:,:,2));
B = double(Irgb(:,:,3));
Y = 0.299R + 0.587G + 0.114B;
U = -0.147R - 0.289G + 0.436B;
V = 0.615R - 0.515G - 0.100*B;
YUV = cat(3, Y, U, V);
[I0,Marks1] = func_read_images(Y,I1);
I0 = imresize(I0,[512,512]);
%设置嵌入强度
Power = 5;
%设置块的大小
Blksize = 8;
RR = 60;
CC = 60;
%对水印进行置乱
Marks1s = Arnold(Marks1,1,0);
% figure
% subplot(131);
% imshow(Irgb,[]);
% title('原始图像');
% subplot(132);
% imshow(Marks1,[]);
% title('水印');
% subplot(133);
% imshow(Marks1s,[]);
% title('置乱后水印');
%对图像进行处理
[Mwk_1st] = func_wk_insert(I0,Marks1s,Power,Blksize,RR,CC);
Y = imresize(Y,[512,512]);
U = imresize(U,[512,512]);
V = imresize(V,[512,512]);
Mwk_1stYUV2 = cat(3,Mwk_1st,U,V);
%YUV2RGB
RGB1 = zeros(size(Mwk_1stYUV2));
RGB1(:,:,1) = Mwk_1st + 1.14 V;
RGB1(:,:,2) = Mwk_1st - 0.39 U - 0.58 V;
RGB1(:,:,3) = Mwk_1st + 2.03 U;
RGB1n(:,:,1)=awgn(RGB1(:,:,1),SNRS(ij),'measured');
RGB1n(:,:,2)=awgn(RGB1(:,:,2),SNRS(ij),'measured');
RGB1n(:,:,3)=awgn(RGB1(:,:,3),SNRS(ij),'measured');
%水印提取
Rs = double(RGB1n(:,:,1));
Gs = double(RGB1n(:,:,2));
Bs = double(RGB1n(:,:,3));
Ys = 0.299Rs + 0.587Gs + 0.114Bs;
Us = -0.147Rs - 0.289Gs + 0.436Bs;
Vs = 0.615Rs - 0.515Gs - 0.100*Bs;
Mwk_1st2 = Ys(:,:,1);
Msg1 = func_wk_desert(real(Mwk_1st2),Blksize,RR,CC,4);
%对水印进行逆置乱
Msg1s = Arnold(uint8(255*Msg1),1,1);
% figure
% subplot(231);
% imshow(Irgb,[]);
% title('原始图像');
% subplot(232);
% imshow(uint8(YUV));
% title('RGB转为YUV图片');
% subplot(233);
% imshow(Marks1);
% title('水印');
% subplot(234);
% imshow(uint8(RGB1));
% title('JPEG压缩攻击');
% subplot(236);
% imshow(Msg1s,[]);
% title('水印提取');
%%
%水印提取,计算NC和PSNR
Marks1 = imresize(Marks1,[RR,CC]);
NC(ij,jk) = func_nc(uint8(Marks1),uint8(Msg1s)) ;
end
end
figure;
plot(SNRS,mean(NC,2),'b-o');
xlabel('SNR');
ylabel('水印提取NC值');
```