LSB transform for image encryption

2 次查看(过去 30 天)
I want to use LSB transform to encode the message in the image. The length of the bit string is less than the size of the image. I wrote a code, but when the length of the message is less, I don't know how to do the encryption. Thank you for your guidance
clc;
clear;
close all;
img=imread('cameraman.tif');
[m,n]=size(img);
message=randi([0 1],m,n);
em=img;
for i=1:m
for j=1:n
pix=dec2bin(img(i,j),8);
if (message(i,j)==0);
pix(8)='0';
else
pix(8)='1';
end
em(i,j)=bin2dec(pix);
end
end

回答(2 个)

Walter Roberson
Walter Roberson 2023-1-21
For legal reasons we cannot discuss encryption here.
If you have two arrays and information is being transferred from a shorter array to a larger array, you have a few choices:
  • you could just stop transferring and leave the larger array to be whatever is appropriate
  • you could prefix size information into what is being transferred, so that the destination first retrieves the site and then knows how many locations to look at
  • you could pad with a constant
  • you could ensure that the data being transferred never includes a particular pattern, and then put the pattern at the place the data stops -- an "end of message" marker

Image Analyst
Image Analyst 2023-1-22

Community Treasure Hunt

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

Start Hunting!

Translated by