Can I embed a image in the following algorithm?

I have successfully added data into the image using the following code and algorithm image is attached below but now I want to embed an image inside an image (steganography) Please suggest proper method to do it
instead of data, Please suggest a method
clc;
clear all;
fprintf('The image matrix A-');
fprintf('\n');
A=imread('airplane.bmp');
figure(1), imshow(A); title('Original Image (Cover Image)');
[Z,map]=rgb2ind(A,256);
p=size(Z);
disp(p);
B=Z;
B(2:2:end,:) = fliplr(Z(2:2:end,:));
C=reshape(B',1,[]);
disp(Z)
fprintf('Inverse S-scan of A-');
fprintf('\n');
disp(C);
fprintf('Size Of Inverse S-scan Matrix-');
fprintf('\n');
z=size(C);
t=z(1)*z(2);
disp(t);
for n=1:1:t
if (n==1)
D(n)=C(1,1);
elseif n>1
D(n)=C(1,(n-1))-C(1,n);
end
end
for n=1:1:t
if (n==1)
E(n)=D(1,1);
else
if(D(n)>0)
E(n)=D(1,n)+1;
else
E(n)=D(1,n);
end
end
end
for n=1:1:t
if(n<2)
F(n)=E(1,n)+1;
else
F(n)=E(n);
end
end
for n=1:1:t
if(n==1)
G(n)=F(1,1);
else
G(n)=C(1,n-1)-F(1,n);
end
end
M=reshape(G,p(1),p(2));
M(:,2:2:end)=flipud(M(:,2:2:end));
M=M.';
N=ind2rgb(M,map);
figure(2);imshow(N);title('Stego Image');
peaksnr = psnr(M,B)
err = immse(M,B)

 Accepted Answer

Images are just a type of data. Reshape it to a vector if you need to. If the image size is not fixed then be sure to embed information about the image size.

4 Comments

you are right sir, but i am not able to understand where to input image data in the algorithm, i want to remove the data and insert image data
I am not certain but I think the data that is currently being embedded is the result of rgb2ind() of the original image, which is stored in the variable Z. It is difficult to tell. Unfortunately the code is not documented or commented.
I can upload the commented code if you want
Replace
[Z,map]=rgb2ind(A,256);
With assigning the desired data to Z

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!