how to hide a binary image within an rgb image?

1 次查看(过去 30 天)
i dont know matlab very well.i have written a code to hide binary image in an rgb image.but it does not work very well.the traces of the binary image can be seen in the rgb image after encrypting.how do i improve it?
%encryption
p=imread('flower.jpg');
q1=imread('colour.jpg');
p1=im2bw(p,.2);
[r c]=size(s);
[r1 c1]=size(q1);
figure(1),imshow(q1),title('original');
q1=imresize(q1,[r,c]);
qr=q1(:,:,1);
qg=q1(:,:,2);
qb=q1(:,:,3);
j=1;
length=r*c;
for i=1:length
if p1(i)==0
qr(j)=bitand(qr(j),0);
j=j+1;
else
qr(j)=bitor(qr(j),1);
j=j+1;
end
end
im=cat(3,qr,qg,qb);
figure(2),imshow(s);
%im=imresize(im,[r1 c1]);
figure(3),imshow(im),title('final');
==================================
%decryption
ir=im(:,:,1);
ig=im(:,:,2);
ib=im(:,:,3);
sz=size(ir);
l=sz(1)*sz(2);
d=zeros(r,c);
j=1;
for i=1:l
d(j)=bitand(ir(i),1);
j=j+1;
end
imshow(d);

采纳的回答

Shivaputra Narke
Shivaputra Narke 2014-1-29
You can use watermarking using DCT

更多回答(1 个)

Shivaputra Narke
Shivaputra Narke 2014-1-29
编辑:Walter Roberson 2016-1-11
I have written a simple code...
clear all;
host=imread('flowers.jpg');
signature=im2bw(imread('signature.tif'));
%%%both images must be of same size
%%%use imresize if its not
onesPosn=find(signature==1);
zerosPosn=find(signature==0);
host=imresize(host,[size(signature)]);
host_R =host(:,:,1);
host_G =host(:,:,2);
host_B =host(:,:,3);
host_R2=host_R;
host_R2(onesPosn)=bitor(host_R(onesPosn),1);
host_R2(zerosPosn)=bitand(host_R(zerosPosn),254);
encrypted=cat(3,host_R2,host_G,host_B);
figure;
subplot(2,2,1);imshow(host);title('original image')
subplot(2,2,2);imshow(signature);title('Binary image')
subplot(2,2,3);imshow(host_R);title('host RED plane')
subplot(2,2,4);imshow(encrypted);title('encrypted')
%-------------------------------------------------
%Decryption
dec_host_R=encrypted(:,:,1);
dec_signature=bitand(dec_host_R,1);
figure;
imshow(dec_signature,[]);title('Decrypted signature');

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by