image in image using hiding

조회 수: 25(최근 30일)
elma ozge
elma ozge 2022년 1월 22일
편집: elma ozge 2022년 1월 24일
what we can do?
  댓글 수: 1
DGM
DGM 2022년 1월 22일
There are some examples on the File Exchange
And lots of threads on LSB encoding on the forum
If you're trying to cram a large 3-channel image into a single bitplane of a smaller 1-channel image, you're going to have to decide how much data you want to lose and how you want to lose it. Even after resizing the host image, you're still trying to fit 4.7E6 bits of data into 1.2E6 bits. You can reduce the size of the payload by reducing its geometry, or bits per sample. You can also convert it to an indexed image, but the question asks about embedding RGB content, so I don't know that's acceptable.
There's also the option to use more than the least-significant bit plane, but that would rapidly become visually noticeable. Certainly, occupying the 5 least-significant bit planes with payload would be more than obvious.
It's also worth noting that you're not maintaining the aspect ratio of the host image when you resize it, which is kind of a dead giveaway that the image has been modified. Use NaN in the geometry specification to specify a slack dimension.

댓글을 달려면 로그인하십시오.

채택된 답변

DGM
DGM 2022년 1월 22일
편집: DGM 2022년 1월 22일
Here.
You either need a much larger host image, or you need to reduce the payload size. The payload can be reduced by reducing its spatial resolution or its color resolution. This example does both.
% prepare host and payload images
Hpict = imread('cameraman.tif');
Hpict = imresize(Hpict,[550 NaN]);
Ppict = imread('peppers.png');
Ppict = imresize(Ppict,[256 NaN]);
payloadsize = size(Ppict);
hostsize = size(Hpict);
if prod(payloadsize)>prod(hostsize(1:2))
% assuming host is I and payload is RGB
error('host is too small to contain payload in 1 bitplane')
end
map = [hsv(6);1 1 1; 0 0 0];
Ppict = ind2rgb(rgb2ind(Ppict,map),map); % each channel is binarized
imshow(Ppict)
% vectorize payload, insert into host at LSB, write
Ppict = logical(Ppict(:));
bitplane = 1;
outputname = 'hppict.png';
Hlsb = bitget(Hpict,bitplane);
Hlsb(1:numel(Ppict)) = Ppict;
HPpict = bitset(Hpict,bitplane,Hlsb); % host with payload
imwrite(HPpict,outputname)
figure
imshow(HPpict)
% read image, extract payload, rectify
HPpict = imread(outputname);
PRpict = bitget(HPpict,bitplane);
PRpict = reshape(PRpict(1:prod(payloadsize)),payloadsize)*255;
figure
imshow(PRpict);
Note that in order for the payload to be rectified after extraction, its geometry needs to be known. In this example, I assume it's known. If it's not known, then it can be guessed from the factors of the vector length. Otherwise, the size vector itself can be embedded in the host along with the payload.
  댓글 수: 5
elma ozge
elma ozge 2022년 1월 24일
Thanks.

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Image Analyst
Image Analyst 2022년 1월 22일
I'm attaching an example of hiding a gray scale image in a gray scale image. It should be no problem for you to adapt it to use one or both as RGB images.
  댓글 수: 5
Image Analyst
Image Analyst 2022년 1월 24일
Yes, you can do what Yanqi said. Just make sure you have enough pixels to do the hiding. This means that you need to have at least 8 times the number of pixels in the red, green, and blue channels all summed together. So if your RGB image is 256x256x3 = 196,608 pixels, then you'll need to have a gray scale image of at least 196,608*8 = 1,572,864 gray scale pixels.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by