MATLABshuiyin.zip

  • PUDN用户
    了解作者
  • matlab
    开发工具
  • 2KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2010-04-15 14:34
    上传日期
MATLAB实现水印效果,有两个程序哦大家可以比较参考
MATLABshuiyin.zip
  • MATLABshuiyin.txt
    10.3KB
内容介绍
http://home.q.yesky.com/space-208890-do-blog-id-279131.html 02-02 14:06 % Script file:dctblock.m % % Purpose:an algorithm to achieve the embeding watermarking to a image by % dct bloking and hvs,then detect the watermarking by % comparability. % % % Record of revisions: % Date Programmer Description of change % ==== ========== ===================== % 11/19/03 Mao Li Original code % Define variables: % a0 --Original gray image matrix % a1 --Embeded gray image matrix % da0 --the dct original gray image matrix % ca0 --the column vector of a0 % cda0 --the column vector of da0 % cda1 --the embeded column vector of cda0 % da1 --the image matrix of cda1 % r --image matrix row % c --image matrix column % k --the number of blocks % i --the subscript of a matrix % SNR --the similarity degree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % input original data ,block break and convert a block into a column vector % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear; clc; a0=imread('D:\work\pic\lena.bmp'); %a0=rgb2gray(a0); [r,c]=size(a0); k=(r*c/64); da0=blkproc(a0,[8,8],'dct2'); ca0=im2col(a0,[8,8],'distinct'); cda0=im2col(da0,[8,8],'distinct'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % produce the watermarking signal (random sequence) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% randn('state',110); w0=randn(1,5120); w0=reshape(w0,5,1024); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % changing submultiple % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpha=0.02; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % embed the watermarking into the low frequences coefficients % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% cda1=cda0; for i=1:k cda1(2,i)=cda0(2,i)+alpha*w0(1,i); cda1(3,i)=cda0(3,i)+alpha*w0(2,i); cda1(9,i)=cda0(9,i)+alpha*w0(3,i); cda1(10,i)=cda0(10,i)+alpha*w0(4,i); cda1(17,i)=cda0(17,i)+alpha*w0(5,i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % reconstruct the watermarking % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% da1=col2im(cda1,[8,8],[r,c,],'distinct'); a1=blkproc(da1,[8,8],'idct2'); figure; subplot(1,2,1),imshow(a0,[]),title('the original image'); subplot(1,2,2),imshow(a1,[]),title('the embeded image'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % detect the watemarking % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dca0=blkproc(a0,[8,8],'dct2'); dca1=blkproc(a1,[8,8],'dct2'); cdca0=im2col(dca0,[8,8],'distinct'); cdca1=im2col(dca1,[8,8],'distinct'); for i=1:k w1(1,i)=(cdca1(2,i)-cdca0(2,i))/alpha; w1(2,i)=(cdca1(3,i)-cdca0(3,i))/alpha; w1(3,i)=(cdca1(9,i)-cdca0(9,i))/alpha; w1(4,i)=(cdca1(10,i)-cdca0(10,i))/alpha; w1(5,i)=(cdca1(17,i)-cdca0(17,i))/alpha; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % calculate the similarity degree % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SNR=sum(sum(w0.*w1))/sqrt(sum(sum(w1.^2))) % Script file:dct_high.m % % Purpose:an algorithm to achieve the embeding watermarking to a image by % dct bloking and hvs,then detect the watermarking by % comparability. % % % Record of revisions: % Date Programmer Description of change % ==== ========== ===================== % 11/25/03 Mao Li Original code % Define variables: % a0 --Original gray image matrix % a1 --Embeded gray image matrix % da0 --the dct original gray image matrix % ca0 --the column vector of a0 % cda0 --the column vector of da0 % cda1 --the embeded column vector of cda0 % da1 --the image matrix of cda1 % r --image matrix row % c --image matrix column % k --the number of blocks % i --the subscript of a matrix % SNR --the similarity degree %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % input original data ,block break and convert a block into a column vector % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear; clc; a0=imread('D:\work\pic\lena.bmp'); %a0=rgb2gray(a0); [r,c]=size(a0); k=(r*c/64); da0=blkproc(a0,[8,8],'dct2'); ca0=im2col(a0,[8,8],'distinct'); cda0=im2col(da0,[8,8],'distinct'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % produce the watermarking signal (random sequence) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% randn('state',110); w0=randn(1,5120); w0=reshape(w0,5,1024); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % changing submultiple % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% alpha=0.02; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % embed the watermarking into the low frequences coefficients % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% cda1=cda0; for i=1:k cda1(48,i)=cda0(48,i)+alpha*w0(1,i); cda1(55,i)=cda0(55,i)+alpha*w0(2,i); cda1(56,i)=cda0(56,i)+alpha*w0(3,i); cda1(62,i)=cda0(62,i)+alpha*w0(4,i); cda1(63,i)=cda0(63,i)+alpha*w0(5,i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % reconstruct the watermarking % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% da1=col2im(cda1,[8,8],[r,c,],'distinct'); a1=blkproc(da1,[8,8],'idct2'); figure; subplot(1,2,1),imshow(a0,[]),title('the original image'); subplot(1,2,2),imshow(a1,[]),title('the embeded image'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % detect the watemarking % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dca0=blkproc(a0,[8,8],'dct2'); dca1=blkproc(a1,[8,8],'dct2'); cdca0=im2col(dca0,[8,8],'distinct'); cdca1=im2col(dca1,[8,8],'distinct'); for i=1:k w1(1,i)=(cdca1(48,i)-cdca0(48,i))/alpha; w1(2,i)=(cdca1(55,i)-cdca0(55,i))/alpha; w1(3,i)=(cdca1(56,i)-cdca0(56,i))/alpha; w1(4,i)=(cdca1(62,i)-cdca0(62,i))/alpha; w1(5,i)=(cdca1(63,i)-cdca0(63,i))/alpha; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % calculate the similarity degree % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SNR=sum(sum(w0.*w1))/sqrt(sum(sum(w1.^2))) http://www.ilovematlab.cn/thread-32752-1-1.html Matlab水印请高手帮忙看看这个程序的问题 这个程序是对图像进行水印的添加,分离及检测 但是换了其他的图像之后就会出错,我也不知道为什么只能是woman图像 错误如下: ??? Error using ==> plus Number of array dimensions must match for binary array op.
评论
    相关推荐
    • 数据库课程设计
      一个数据库课程设计,access管理工具实现,用的是窗体!
    • 数据库课程设计
      数据库课程设计十分完整有需要的请下载啊谢谢
    • 数据库课程设计
      广东工业大学数据库课程设计,可视化界面连接数据库,delphi7
    • 数据库课程设计
      数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述 数据库课程设计实验及其描述
    • 数据库课程设计
      数据库课程设计》由周爱武、汪海威、肖云编著,遵循数据库课程设计的具体要求,独立于具体的数据库教材,从实际应用系统的需求着手,引导读者逐步完成数据库设计全过程,重点讲解数据库系统的需求分析、概念设计、...
    • 数据库课程设计
      数据库课程设计人事管理系统 数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计人事管理系统数据库课程设计...
    • 数据库课程设计
      数据库课程设计,基于visual basic自助银行管理系统,界面很清爽,实用。同学都说好,所以就上传了!!!
    • 数据库课程设计
      数据库课程设计 里面有详细的文档资料 包含数据库一切的图 以及生成的数据库表文件 期末得分为优秀
    • 数据库课程设计
      可以作为数据库课程设计,也可以作为Java的课程设计,内容全面。本资源转载的,非本人原创。用于交流学习,特此申明!
    • 数据库课程设计
      数据库课程设计蓝天大学学生管理系统 2.商店信息管理系统 3.实验室机房收费管理系统 4.图书馆资料检索系统 5.企业库存管理系统 6.仓库管理系统 7.工程项目管理系统 8.教材管理系统 9.企业人事管理系统 10.企业财务...