91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 56KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-07
  • 語(yǔ)言: Matlab
  • 標(biāo)簽: LSB水印??DCT水印??matlab??

資源簡(jiǎn)介

通過(guò)使用matlab實(shí)現(xiàn)了LSB和DCT水印,并比較其優(yōu)缺點(diǎn),內(nèi)含圖片。

資源截圖

代碼片段和文件信息

%整理自lufei的水印代碼(數(shù)字水印論壇)
%整理:wyy022
%Project:? Threshold-based?Correlation?in?DCT?mid-band
%???????????Uses?two?PN?sequences;?one?for?a?“0“?and?another?for?a?“1“
%水印嵌入

clear?all;

%?保存開(kāi)始時(shí)間?
start_time=cputime;

k=30;???????????????????????????%?設(shè)置嵌入強(qiáng)度
blocksize=8;????????????????????%?設(shè)置塊的大小

midband=[???00011110;????%?defines?the?mid-band?frequencies?of?an?8x8?dct
????????????00111100;
????????????01111000;
????????????11110000;
????????????11100000;
????????????11000000;
????????????10000000;
????????????00000000?];
????????
%?讀入原始圖像
file_name=‘cam.png‘;
cover_object=double(imread(file_name));

%?原始圖像的行數(shù)與列數(shù)
Mc=size(cover_object1); ????????%原圖的行數(shù)
Nc=size(cover_object2); ????????%原圖的列數(shù)

%?確定可嵌入的最大信息量
max_message=Mc*Nc/(blocksize^2);

%?讀入水印圖像
file_name=‘nd.png‘;
message=double(imread(file_name));
%水印圖像的行數(shù)與列數(shù)
Mm=size(message1) ????????????????%水印圖像的行數(shù)
Nm=size(message2) ????????????????%水印圖像的列數(shù)

figure(1)
imshow(message[]);
title(‘水印‘);

%?將水印圖像矩陣轉(zhuǎn)換為0,1組成的向量
message=reshape(message1Mm*Nm);

%?檢查水印信息是否過(guò)大
if?(length(message)?>?max_message)
???error(‘水印太大‘)
end

%?將message_vector置為全1向量,并將message寫(xiě)入
message_vector=ones(1max_message);
message_vector(1:length(message))=message;

%?將cover_object寫(xiě)入watermarked?image
watermarked_image=cover_object;

key=1100;
%?重置隨機(jī)數(shù)發(fā)生器狀態(tài)為key
rand(‘state‘key)

%?生成偽隨機(jī)數(shù)
pn_sequence_zero=round(2*(rand(1sum(sum(midband)))-0.5));??

%?圖象分塊并嵌入
x=1;
y=1;
for?(kk?=?1:length(message_vector))
????%?分塊進(jìn)行DCT變換
????dct_block=dct2(cover_object(y:y+blocksize-1x:x+blocksize-1));
????
????%?如果message_vector==0?并且midband==1,那么嵌入?pn_sequence_zero
????ll=1;
????if?(message_vector(kk)==0)
????????for?ii=1:blocksize
????????????for?jj=1:blocksize
????????????????if?(midband(jjii)==1)
????????????????????dct_block(jjii)=dct_block(jjii)+k*pn_sequence_zero(ll);
????????????????????ll=ll+1;
????????????????end
????????????end
????????end
????end
????
????%?逆DCT變換
????watermarked_image(y:y+blocksize-1x:x+blocksize-1)=idct2(dct_block);????
????
????%?移動(dòng)到下一塊
????if?(x+blocksize)?>=?Nc
????????x=1;
????????y=y+blocksize;
????else
????????x=x+blocksize;
????end
end

%?轉(zhuǎn)換為uint8?并將watermarked_image_uint8寫(xiě)入watermarked_image_uint8.bmp
watermarked_image_uint8=uint8(watermarked_image);
imwrite(watermarked_image_uint8‘watermarked_image_uint8.bmp‘‘bmp‘);

%?顯示運(yùn)行時(shí)間
elapsed_time=cputime-start_time

%?計(jì)算psnr
A=watermarked_image_uint8;X=cover_object;
[height?width]=size(X);
X=double(X);
A=double(A);
sigma1=0;
for?i=1:height
for?j=1:width
sigma1=sigma1+(X(ij)-A(ij))^2;
end
end
mse=(sigma1/(height*width));???%均方誤差
psnr=10*log10((255^2)/mse)

%?顯示嵌入水印圖象與原始圖象
figure(2)
subplot(121);
imshow(watermarked_image_uint8[])
title(‘嵌入水印圖像‘)
subplot(122)
imshow(cover_object[]);
title(‘原始圖像‘);

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-06-03?09:29??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\
?????文件???????65240??2000-12-04?13:57??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\cam.png
?????文件????????3161??2011-06-01?11:05??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\dct2_embed.m
?????文件????????2351??2011-06-01?11:05??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\dct2_recover.m
?????文件????????2554??2011-05-30?10:25??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\dct2_zjdbr.m
?????文件?????????155??2011-05-21?10:58??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\nd.png
?????文件????????1472??2011-06-01?11:06??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\shuiyin.m
?????文件?????????797??2011-05-29?15:54??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\weitu.m
?????文件????????1740??2011-05-31?10:39??基于LSB算法與DCT算法的比較與實(shí)現(xiàn)\zjdb.m

評(píng)論

共有 條評(píng)論