Image hiding inside an image

1 次查看(过去 30 天)
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
input=rgb2gray(input);
% Resize the image to required size
input=imresize(input, [512 512]);
message=I1(1,:);
len = length(message) * 8;
bin_message1=de2bi(message,'left-msb',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;
end
end
end
%%%%%%%%%%%% 2nd row of I1 to hide
message2=I1(2,:);
len = length(message2) * 8;
bin_message2=de2bi(message2,'left-msb',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

采纳的回答

GandaBerunda
GandaBerunda 2022-7-19
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 个评论
lilly lord
lilly lord 2022-7-19
编辑:lilly lord 2022-7-21
Thank you very much. Your answer help me to solve this problem. I made the function and solve the issue

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Encryption / Cryptography 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by