Matlab数字水印处理系统设计与实现‌

一、课题介绍

本课题为基于MATLAB的小波变换dwt和离散余弦dct的多方法对比数字水印系统。带GUI交互界面。有一个主界面GUI,可以调用dwt方法的子界面和dct方法的子界面。流程包括,读取宿主图像和水印图像,嵌入,多种方法的攻击(剪切,加噪,旋转等),提取,最后利用psnr峰值信噪比进行评价不同攻击下,鲁棒性的好坏。

二、GUI界面

1、主界面

一、源码

1、读取宿主图像
[name,path]=uigetfile({'*.bmp';'gif'},'载入图像');

        X=imread([path,name]);  %获取位置
        axes(handles.axes1);%axes表示获取位置,这里选取的位置为axes1;
                imshow(X); %显示图像
        save('X');  %保存变量
       guidata(hObject,handles) %更新结构体;
2、读取水印图像
[name,path]=uigetfile({'*.bmp';'gif'},'载入图像');

        W=imread([path,name]);  %获取位置
        axes(handles.axes2);%axes表示获取位置,这里选取的位置为axes1;
        W=rgb2gray(W)
        W=imresize(W,[64 64])
        imshow(W); %显示图像
        save('W');  %保存变量
       guidata(hObject,handles) %更新结构体;

3、嵌入
for i = 1:64
    ref1(i)=mean(lowarray(:,i)); %对矩阵每列求均值
    ref2(i)=mean(lowarray(i,:)); %对矩阵每行求均值
    for j=1:64
        w(i,j,:)=int8(dec2bin(W(i,j),8))-48; %dec2bin将矩阵W的每个元素转换成二进制值,每个二进制长度为8
        result(i,j,1)=xor(w(i,j,1),(lowarray(i,j)>ref1(i)));
        result(i,j,2)=xor(w(i,j,2),(lowarray(i,j)>ref2(i)));
    end

end
for i=1:4096
    ref3tmp=[XCsource(16381+4*i:16384+4*i)];%128*128=16384
    ref3(i)=mean(ref3tmp);
    ref4tmp=[XCsource(32765+4*i:32768+4*i)];%128*256=32768
    ref4(i)=mean(ref3tmp);
    ref5tmp=[XCsource(49149+4*i:49152+4*i)];%(128+64)*256=49152  or (128+256)*128=49152
    ref5(i)=mean(ref5tmp);
    ref6tmp=[XCsource(65521+16*i:65536+16*i)];%256*256=65536 or 128*512=65536
    ref6(i)=mean(ref6tmp);
    ref7tmp=[XCsource(131057+16*i:131072+16*i)];%256*512=131072
    ref7(i)=mean(ref7tmp);
    ref8tmp=[XCsource(196593+16*i:196608+16*i)];%(128+256)*512=196608
    ref8(i)=mean(ref8tmp);
end
4、攻击
if get(handles.radiobutton1,'value')
    option=1;
   q=num2str(get(handles.edit3,'string'))
       Z = imrotate(Z,q,'crop');%旋转 角度可以控制
elseif get(handles.radiobutton2,'value')
    option=2;
    q1=str2num(get(handles.edit4,'string'))
    q2=str2num(get(handles.edit6,'string'))
    q3=str2num(get(handles.edit7,'string'))
    q4=str2num(get(handles.edit8,'string'))

    Z(q1:q2,q3:q4)=255;%剪切 区间和嵌入值可以控制



elseif get(handles.radiobutton3,'value')
    option=3;
    q=str2num(get(handles.edit5,'string'))
       Z=imnoise(Z,'gaussian',q);%加噪声 选择参数 help imnoise


elseif get(handles.radiobutton4,'value')
    option=4;
    Z=Z
end
axes(handles.axes4)
imshow(Z,[]);
5、提取
for i =1:64
    for j=1:64
        pick(i,j,3)=xor(std(i,j,3),(lowarray(i,j)>(alaph3*reref3(i,j))));
        pick(i,j,4)=xor(std(i,j,4),(lowarray(i,j)>(alaph4*reref4(i,j))));
        pick(i,j,5)=xor(std(i,j,5),(lowarray(i,j)>(alaph5*reref5(i,j))));
        pick(i,j,6)=xor(std(i,j,6),(lowarray(i,j)>(alaph6*reref6(i,j))));
        pick(i,j,7)=xor(std(i,j,7),(lowarray(i,j)>(alaph7*reref7(i,j))));
        pick(i,j,8)=xor(std(i,j,8),(lowarray(i,j)>(alaph8*reref8(i,j))));
    end
end

for i=1:64
    for j=1:64
        od=double(reshape(pick(i,j,:),1,8));
        dec(i,j)=bin2dec(char(od+48));
    end
end
6、psnr计算
origImg = double(origImg);
distImg = double(distImg);

[M N] = size(origImg);
error = origImg - distImg;
MSE = sum(sum(error .* error)) / (M * N);

if(MSE > 0)
    PSNR = 10*log(255*255/MSE) / log(10);
else
    PSNR = 99;
end

QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空