基于小波变换的数字图像处理(MATLAB源代码)

clear all; close all; clc;

M=256;%原图像长度

N=64; %水印长度

[filename1,pathname]=uigetfile('*.*','select the image'); 

image1=imread(num2str(filename1));

subplot(2,2,1);imshow(image1); title('original image');     % orginal image for watermarking

image1=double(image1);

imagew=imread('dmg2.tif');

subplot(2,2,2);imshow(imagew);title('original watermark');   %original watermark

%嵌入水印

[ca,ch,cv,cd] = dwt2(image1,'db1');

[cas,chs,cvs,cds] = dwt2(ca,'db1');

for i=1:N

    for j=1:N

        if imagew(i,j)==0

            a=-1;

        else

            a=1;

        end

        Ca(i,j)=cas(i,j)*(1+a*0.03);

    end

end

IM= idwt2(Ca,chs,cvs,cds,'db1') ;

markedimage=double(idwt2(IM,ch,cv,cd,'db1'));

%显示嵌入后水印图像

subplot(2,2,3);colormap(gray(256));image(markedimage);title

你可能感兴趣的:(WaterMark)