基於二維CS-SCHT變換和擴頻方法的彩色影像水印嵌入和提取演算法matlab模擬

简简单单做算法發表於2024-05-29

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.299*R + 0.587*G + 0.114*B;  
U   = -0.147*R - 0.289*G + 0.436*B;  
V   =  0.615*R - 0.515*G - 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.299*Rs + 0.587*Gs + 0.114*Bs;  
Us   = -0.147*Rs - 0.289*Gs + 0.436*Bs;  
Vs   =  0.615*Rs - 0.515*Gs - 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值');

  

相關文章