?? program.m
字號(hào):
%將水印圖像按最不重要位(LSB)方法嵌入到載體圖像中,在把水印從載體圖像中提取出來
%注:整個(gè)算法分為水印嵌入部分和水印提取部分。
clc;
clear;
% 處理隱寫圖像
file_name='copyright.bmp';
mark=imread(file_name);
mark=rgb2gray(mark);
mark=round(double(mark)/255);
%顯示水印圖像
subplot(2,2,1),imshow(mark,[]),title('隱寫圖像');
% 讀入載體圖像
file_name='lena.bmp';
cover=imread(file_name);
subplot(2,2,2),imshow(cover,[]),title('載體圖像');
%獲取圖像大小
[m,n]=size(cover);
[r,c]=size(mark);
%隱寫嵌入算法
i = 1;j = 1;ii = 1;jj = 1;p = r*c;
while p~=0
cover(i,j) = bitset(cover(i,j),1,mark(ii,jj));
jj = jj+1;
j = j+1;p = p-1;
if jj == c+1
ii = ii+1;jj = 1;
end
if j == n+1
i = i+1;j = 1;
end
end;
subplot(2,2,3),imshow(cover,[]),title('含隱寫信息圖像');
imwrite(cover,'stego_cover.bmp','bmp');
file_name='stego_cover.bmp';
newcover=imread(file_name);
A = zeros(r,c);
[m,n] = size(newcover);
i = 1;j = 1;ii = 1;jj = 1;p = c*r;
while p~=0
A(ii,jj) = bitget(newcover(i,j),1);
jj = jj+1;
j = j+1;p = p-1;
if jj == c+1
ii = ii+1;jj = 1;
end
if j == n+1
i = i+1;j = 1;
end
end;
subplot(2,2,4),imshow(A,[]),title('提取的隱寫信息圖像');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -