?? embedding1.m
字號(hào):
clear all;
close all;
clc;
X=imread('vis.jpg');
X = imresize(X,[512 512]);
figure;
imshow(X),title('Host Image');
I=X;
IW = X;
X = X(:,:,2); % Taking green plane alone for stego embedding
X=double(X);
[LL1,HL1,LH1,HH1]=dwt2(X,'db4'); % First level decomposition
[LL2,HL2,LH2,HH2]=dwt2(LL1,'db4'); % Second level decomposition
[LL3,HL3,LH3,HH3]=dwt2(LL2,'db4'); % Third level decomposition
figure;
subplot(3,4,1),imshow(uint8(LL1)),title('Approximation 1 coeff');
subplot(3,4,2),imshow(uint8(HL1)),title('H1 coeff');
subplot(3,4,3),imshow(uint8(LH1)),title('V1 coeff');
subplot(3,4,4),imshow(uint8(HH1)),title('D1 coeff');
subplot(3,4,5),imshow(uint8(LL2)),title('Approximation 2 coeff');
subplot(3,4,6),imshow(uint8(HL2)),title('H2 coeff');
subplot(3,4,7),imshow(uint8(LH2)),title('V2 coeff');
subplot(3,4,8),imshow(uint8(HH2)),title('D2 coeff');
subplot(3,4,9),imshow(uint8(LL3)),title('Approximation 3 coeff');
subplot(3,4,10),imshow(uint8(HL3)),title('H3 coeff');
subplot(3,4,11),imshow(uint8(LH3)),title('V3 coeff');
subplot(3,4,12),imshow(uint8(HH3)),title('D3 coeff');
w=imread('cam.jpg');
w2=im2bw(w); % Converting it in to logical image format
w1=imresize(w2,[64 64]);
W = w1;
figure;
imshow(W),title('Secret Image');
alpha = 0.05; % assign alpha value for embedding
%dividing
for m=0:15 %dividing into 16 blocks in horizontal direction
for n=0:15 %dividing into 16 blocks in vertical direction
for i=1+4*m:4+4*m
for j=1+n*4:4+4*n
z(i-m*4,j-n*4)=LL3(i,j);%we get 1 block of LL3
w3(i-m*4,j-n*4)=w1(i,j);% we get 1 block of stego
end
end
for i=1+4*m:4+4*m
for j=1+n*4:4+4*n
W3(i,j) = (1-alpha) * z(i-m*4,j-n*4) + (alpha * w3(i-m*4,j-n*4)); % Formula for embedding
end
end
for i=1+4*m:4+4*m
for j=1+n*4:4+4*n
LL3(i,j) = W3(i,j); %combining all blocks into 128*128 matrixHL2(i,j)
end
end
end % vertical block end
end % Horizontal end
%take inverse dwt
LL2=(idwt2(LL3,HL3,LH3,HH3,'db4')); % Reconstruction of HL2
LL1=(idwt2(LL2,HL2,LH2,HH2,'db4')); % Reconstruction of HL1
Y=(idwt2(LL1,HL1,LH1,HH1,'db4')); % Reconstructed stego image
IW(:,:,2) = Y; %Integrating stego green plane with original R and B plane
%figure;
%imshow(IW),title('Stego image');%stego image
imwrite(uint8(IW),'Stego.jpg');
figure;
subplot(1,3,1),imshow(I);title('Original Image');
subplot(1,3,2),imshow(W);title('Secret Image');
subplot(1,3,3),imshow(IW);title('Stego Image');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -