Image hiding inside an image

10 views (last 30 days)
lilly lord
lilly lord on 18 Jul 2022
Edited: lilly lord on 21 Jul 2022
Hello, I am trying to hide an image inside an image taking one row of the secret image at a time.
input = imread('peppers.png');% cover image
I1=imread('message1.png');%%% secret image grayscale 64*64
% Convert image to grayscale
% Resize the image to required size
input=imresize(input, [512 512]);
len = length(message) * 8;
% Get all the binary digits in separate row
bin_message = bin_message1(:);
% Length of the binary message
N = length(bin_message);
% Initialize output as input
output1 = input;
height = size(input, 1);
width = size(input, 2);
embed_counter = 1;
for i = 1 : height
for j = 1 : width
if(embed_counter <= len)
LSB = mod(double(input(i, j)), 2);
temp = double(xor(LSB, bin_message(embed_counter)));
output1(i, j) = input(i, j)+temp;
embed_counter = embed_counter+1;
%%%%%%%%%%%% 2nd row of I1 to hide
len = length(message2) * 8;
bin_message = bin_message2(:);
N2 = length(bin_message);
% Initialize output as input
output2 = output1;
height = size(output1, 1);
width = size(output1, 2);
% Counter for number of embedded bits
embed_counter = 1;
and ...............
this way I have tried to embed all 64 rows of the secret image. I want to apply a loop so that it can be done once. Can anyone help

Accepted Answer

GandaBerunda on 19 Jul 2022
Hi Lilly,
One suggestion which comes on the top of my head is that you can put the steganography part of the code as a separate function. Then you can iterate through the rows of the secret image and call that function. Hope it helps.
  1 Comment
lilly lord
lilly lord on 19 Jul 2022
Edited: lilly lord on 21 Jul 2022
Thank you very much. Your answer help me to solve this problem. I made the function and solve the issue

Sign in to comment.

More Answers (0)


Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!