0% found this document useful (0 votes)
55 views2 pages

Function

This function embeds a secret message into an image using steganography. It takes in the image and secret message as inputs. It extracts the bit planes of the image and embeds the message bits into the least significant bit planes by flipping bits based on the message values using XOR logic. It then recombines the bit planes and output image. The function embeds the entire message by processing blocks of bits and modifying image pixel bits accordingly.

Uploaded by

Neetesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views2 pages

Function

This function embeds a secret message into an image using steganography. It takes in the image and secret message as inputs. It extracts the bit planes of the image and embeds the message bits into the least significant bit planes by flipping bits based on the message values using XOR logic. It then recombines the bit planes and output image. The function embeds the entire message by processing blocks of bits and modifying image pixel bits accordingly.

Uploaded by

Neetesh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

function [l,i,f,x,y]=stegno(S)

I=double(imread('lena512.bmp'));
[x,y]=size(I);
m=round(rand(1,768900));
f=length(m);
if(rem(f,4)==1)
m=[m,0,0,0];
elseif(rem(f,4)==2)
m=[m,0,0];
elseif(rem(m,4)==3)
m=[m,0];
else
end
[p8,p7,p6, p5, p4,p3,p2, p1]=bit_extract(I);
U=[p1,p2,p3,p4];
A=U(:);
l=1;
i=1;
while(l<=f-3 && i<=5*floor(2*x*y/5)-4)
k1=xor(A(i),A(i+1));
k2=xor(A(i+2),A(i+3));
k3=xor(A(i),A(i+2));
k4=xor(1,A(i+4));
if(m(l)==k1 && m(l+1)==k2 && m(l+2)==k3 && m(l+3)~=k4)
A(i+4)=not(A(i+4));
elseif(m(l)==k1 && m(l+1)==k2 && m(l+2)~=k3&& m(l+3)==k4)
A(i)=not(A(i));A(i+1)=not(A(i+1));
elseif(m(l)==k1 && m(l+1)==k2 && m(l+2)~=k3&& m(l+3)~=k4)
A(i)=not(A(i));A(i+1)=not(A(i+1)); A(i+4)=not(A(i+4));
elseif(m(l)==k1 && m(l+1)~=k2 && m(l+2)==k3&& m(l+3)==k4)
A(i+3)=not(A(i+3));
elseif(m(l)==k1 && m(l+1)~=k2 && m(l+2)==k3&& m(l+3)~=k4)
A(i+3)=not(A(i+3));A(i+4)=not(A(i+4));
elseif(m(l)==k1 && m(l+1)~=k2 && m(l+2)~=k3 && m(l+3)==k4)
A(i+2)=not(A(i+2));
elseif(m(l)==k1 && m(l+1)~=k2 && m(l+2)~=k3&& m(l+3)~=k4)
A(i+2)=not(A(i+2)); A(i+4)=not(A(i+4));
elseif(m(l)~=k1 && m(l+1)==k2 && m(l+2)==k3&& m(l+3)==k4)
A(i+1)=not(A(i+1));
elseif(m(l)~=k1 && m(l+1)==k2 && m(l+2)==k3&& m(l+3)~=k4)
A(i+1)=not(A(i+1)); A(i+4)=not(A(i+4));
elseif(m(l)~=k1 && m(l+1)==k2 && m(l+2)~=k3&& m(l+3)==k4)
A(i)=not(A(i));
elseif(m(l)~=k1 && m(l+1)==k2 && m(l+2)~=k3&& m(l+3)~=k4)
A(i)=not(A(i));A(i+4)=not(A(i+4));
elseif(m(l)~=k1 && m(l+1)~=k2 && m(l+2)==k3&& m(l+3)==k4)
A(i+1)=not(A(i+1));A(i+3)=not(A(i+3));
elseif(m(l)~=k1 && m(l+1)~=k2 && m(l+2)==k3&& m(l+3)~=k4)
A(i+1)=not(A(i+1)); A(i+4)=not(A(i+4));A(i+3)=not(A(i+3));
elseif(m(l)~=k1 && m(l+1)~=k2 && m(l+2)~=k3 && m(l+3)==k4)
A(i+1)=not(A(i+1)); A(i+2)=not(A(i+2));
elseif(m(l)~=k1 && m(l+1)~=k2 && m(l+2)~=k3 && m(l+3)~=k4)
A(i)=not(A(i)); A(i+3)=not(A(i+3)); A(i+4)=not(A(i+4));
else
A(i)=A(i);A(i+1)=A(i+1);A(i+2)=A(i+2);A(i+3)=A(i+3);A(i+4)=A(i+4);

end
l=l+4;i=i+5;
end
i=2*x*y+1;
while(l<=f-1 && i<=3*floor(4*4*x*y/3)-2)
k1=xor(A(i),A(i+1));
k2=xor(A(i+1),A(i+2));
if(m(l)==k1 && m(l+1)~=k2)
A(i+2)=not(A(i+2));
l=l+2;i=i+3;
elseif(m(l)~=k1 && m(l+1)==k2)
A(i)=not(A(i));
l=l+2;i=i+3;
elseif(m(l)~=k1 && m(l+1)~=k2)
A(i+1)=not(A(i+1));
l=l+2;i=i+3;
else
l=l+2;i=i+3;
end
end
q1=A(1:x*y);
q2=A(x*y+1:2*x*y);
q3=A(2* x*y+1:3*x*y);
q4=A(3*x*y+1:4*x*y);
q1=reshape(q1,x,y);
q2=reshape(q2,x,y);
q3=reshape(q3,x,y);
q4=reshape(q4,x,y);
S=p8*2^7+p7*2^6+p6*2^5+p5*2^4+q4*2^3+q3*2^2+q2*2^1+q1*1;
end

You might also like