資源簡介
利用二維小波變換,在一幅圖像中嵌入水印,有水印檢測以及提取的源代碼,并有各部分程序作用的注釋。

代碼片段和文件信息
clear;
%裝入原圖像1
load?woman;
I=X;
%小波函數(shù)
type?=?‘db1‘;
%?2維離散Daubechies小波變換
[CA1?CH1?CV1?CD1]?=?dwt2(Itype);
C1?=?[CH1?CV1?CD1];
%系數(shù)矩陣大小
[length1?width1]?=?size(CA1);
[M1?N1]?=?size(C1);
%?定義閾值T1?
T1?=50;
alpha?=?0.2;
%在圖像中加入水印
for?counter2?=?1:?1:?N1
???for?counter1?=?1:?1:?M1
??????if(?C1(counter1?counter2)?>?T1?)???
?????????marked1(counter1counter2)?=?randn(11);
?????????NEWC1(counter1?counter2)?=?double(?C1(counter1?counter2)?)?+alpha?*?abs(?double(?C1(counter1?counter2)?)?)?*?marked1(counter1counter2)?;??????
??????else
?????????marked1(counter1?counter2)?=?0;
?????????NEWC1(counter1?counter2)?=?double(?C1(counter1?counter2)?);
??????end;?
???end;
end;
%重構(gòu)圖像
NEWCH1?=?NEWC1(1:length1?1:width1);
NEWCV1?=?NEWC1(1:length1?width1+1:2*width1);
NEWCD1?=?NEWC1(1:length1?2*width1+1:3*width1);
R1?=?double(?idwt2(CA1?NEWCH1?NEWCV1?NEWCD1?type)?);
%分離水印
watermark1?=?double(R1)?-?double(I);
figure(1);
subplot(121);
image(I);
axis(‘square‘);
title(‘原始圖像‘);
subplot(122);
imshow(R1/250);
axis(‘square‘);
title(‘Daubechies小波變換后圖像‘);
figure(2);
imshow(watermark1*10^16);
axis(‘square‘);
title(‘水印圖像‘);
%?水印檢測
newmarked1?=?reshape(marked1?M1*N1?1);
%?檢測閾值
T2?=?60;
?for?counter2?=?1:?1:?N1
??? for?counter1?=?1:?1:?M1
????????????if(?NEWC1(counter1?counter2)?>T2?)
???????????????NEWC1X(counter1?counter2)?=?NEWC1(counter1?counter2);
????????????else
???????????????NEWC1X(counter1?counter2)?=?0;
????????????end;
????????end;
??????end;
NEWC1X?=?reshape(NEWC1X?M1*N1?1);
correlation1?=?zeros(10001);
for?corrcounter?=?1:?1:?1000
??????if(?corrcounter?==?500)
???????correlation1(corrcounter1)?=?NEWC1X‘*newmarked1?/?(M1*N1);
??????else
???????rnmark?=?randn(M1*N11);
???????correlation1(corrcounter1)?=?NEWC1X‘*rnmark?/?(M1*N1);
??????end;??????
end;??
%?計(jì)算閾值
originalthreshold?=?0;
for?counter2?=?1:?1:?N1
??? for?counter1?=?1:?1:?M1
?????????????if(?NEWC1(counter1?counter2)?>?T2?)
???????????????originalthreshold?=?originalthreshold?+?abs(?NEWC1(counter1?counter2)?);
?????????????end;
?????????end;
??end;
originalthreshold?=?originalthreshold?*?alpha?/?(2*M1*N1);???
corrcounter?=?1000;
originalthresholdvector?=?ones(corrcounter1)?*?originalthreshold;
figure(3);
plot(correlation1?‘-‘);
hold?on;
plot(originalthresholdvector?‘--‘);
title(‘原始的加水印圖像‘);
xlabel(‘水印‘);
ylabel(‘檢測響應(yīng)‘);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2538??2008-12-23?19:57??shuiyin2.m
-----------?---------??----------?-----??----
?????????????????2538????????????????????1
- 上一篇:madplay庫文件
- 下一篇:VHDL源代碼
評論
共有 條評論