⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 embedding2.m

📁 Contain Matlab files in digital steganography
💻 M
字号:

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,'sym1'); % First level decomposition
[LL2,HL2,LH2,HH2]=dwt2(LL1,'sym1'); % Second level decomposition
[LL3,HL3,LH3,HH3]=dwt2(LL2,'sym1'); % 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.01; % 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,'sym1')); % Reconstruction of HL2
LL1=(idwt2(LL2,HL2,LH2,HH2,'sym1')); % Reconstruction of HL1
Y=(idwt2(LL1,HL1,LH1,HH1,'sym1')); % 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');
 



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -