• 大小: 4KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Matlab
  • 标签: 扩频水印  Matlab  

资源简介

王颖编写的图像水印 扩频方法 Matlab实现

资源截图

代码片段和文件信息

function [simPSNR]=kuopin_wangying(yuzhiaattack_styleattack_strength)
%%%attack_style用于设置选择何种攻击
%%%yuzhi用于选择嵌入系数
%%%a用于控制嵌入强度
%%%sim返回相关系数
%%%psnr返回峰值信噪比
%%%attack_strength用于控制攻击的强弱
%%%%%%%%%%%%%%%%%%%%%读入原始载体图像%%%%%%%%%%%%%%%%%%%%%%%%%
[xmap]=imread(‘lena.bmp‘);
[rowcol]=size(x);
M=row;
N=col;
MN=col*row;
figure(1);image(x)colormap(map);
title(‘原始图像‘‘Fontsize‘13‘color‘‘yellow‘);
x_source=x;
fun1=@dct2;%%%分割图像进行二维DCT变换
J1=blkproc(x[256256]fun1);
%%%%%%%%%%%%%%%%%%%%产生长度为1000的伪随机序列作为水印信息%%%%%%%%%%%
mm=normrnd(01[1 1000]);
MNm=1000;
z=mm;
num=1;
num1=1;
num2=1;
t=1;
%%%%%%%%%%%%%%%%%%%%水印信息嵌入%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
J11=J1;
for i=1:M
    for k=1:N
        if abs(J1(ik))>yuzhi&&t<=MNm&&(i+k>2)
            J11(ik)=J1(ik)*(1+a*z(t));
            t=t+1;
        end
    end
end
marksize=t-1;
J2=IDCT2(J11);%%%二维DCT逆变换
imwrite(uint8(round(J2))‘ss_watermarked.bmp‘);
%%%%%%%%%%%%%%%%%%%%计算合成信号的峰值信噪比%%%%%%%%%%%%%%%%%%%%%%
x_temp1=J2-double(x_source);
figure(10)imshow(uint8(round(100*x_temp1)));
imwrite((uint8(round(100*x_temp1)))‘ss_chazhi.bmp‘);
x_temp2=x_temp1(:);
x_temp3=abs(x_temp2);
x_temp4=x_temp3‘*x_temp3;
d_embed=x_temp4/(M*M);
SDR1=255*255/d_embed;
PSNR=10*log10(SDR1);
%%%%%%%%%%%%%%%%%%%%攻击%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
J2=imread(‘ss_watermarked.bmp‘);
if attack_style==1
    %%%(1)放大两倍的操作(当然提取之前要先缩小两倍)
xxx1=imresize(J22‘bicubic‘);
xxx2=imresize(xxx11/2‘bicubic‘);
yy=double(xxx2);
end
if attack_style==2
%%%(1)放大四倍的操作(当然提取之前要先缩小四倍)
xxx1=imresize(J24‘bicubic‘);
xxx2=imresize(xxx11/4‘bicubic‘);
yy=double(xxx2);
end
%(2)缩小1/4的操作
if attack_style==3
    xxx1=imresize(J23/4‘bicubic‘);
    xxx2=imresize(xxx14/3‘bicubic‘);
    yy=double(xxx2);
end
if attack_style==4
    xxx1=imresize(J22/4‘bicu

评论

共有 条评论