i have written a code to hide a grayscale image within a rgb image.but while decrypting.the rgb image is retrieved.but the grayscale image is not.a black image is displayed instead.

1 回表示 (過去 30 日間)
%/encryption
p=imread('flower.jpg');
q=imread('msgimage.jpg');
p1=rgb2gray(p)
s=size(q);
[r c]=size(p1);
figure(1),imshow(q),title('original');
q2=imresize(q,[r c]);
qr=q2(:,:,1);
qg=q2(:,:,2);
qb=q2(:,:,3);
l=r*c;
qr=bitand(qr,uint8(240));
p2=bitshift(p1,-3);
im=bitor(qr,p2);
im=cat(3,qr,qg,qb);
%im1=imresize(im1,[s(1) s(2)]);
figure(2),imshow(p1);
figure(3),imshow(im),title('final');
=========================================
%/decryption
ir=im(:,:,1);
ig=im(:,:,2);
ib=im(:,:,3);
x=bitand(ir,uint8(240));
y=bitand(ir,uint8(15));
x=cat(3,ir,ig,ib);
figure(1),imshow(x);
figure(2),imshow(y);

採用された回答

Walter Roberson
Walter Roberson 2014 年 1 月 28 日
You have
im=bitor(qr,p2);
im=cat(3,qr,qg,qb);
which calculates im and then throws away that result and writes in a new one.

その他の回答 (1 件)

Shivaputra Narke
Shivaputra Narke 2014 年 1 月 28 日
編集済み: Walter Roberson 2014 年 1 月 28 日
Use following code...
Compare code and find the changes done.
Hope this help..
%/encryption
p=imread('flowers.jpg');
q=imread('msgimage.jpg');
p1=rgb2gray(p)
s=size(q);
[r c]=size(p1);
figure(1),imshow(q),title('original');
q2=imresize(q,[r c]);
qr=q2(:,:,1);
qg=q2(:,:,2);
qb=q2(:,:,3);
l=r*c;
qr=bitand(qr,uint8(240));
p2=bitshift(p1,-3);
im=bitor(qr,p2);
im=cat(3,im,qg,qb);
%im1=imresize(im1,[s(1) s(2)]);
figure(2),imshow(p1);
figure(3),imshow(im),title('final');
%/decryption
ir=im(:,:,1);
ig=im(:,:,2);
ib=im(:,:,3);
x=bitand(ir,uint8(240));
y=bitand(ir,uint8(15));
x=cat(3,ir,ig,ib);
figure(1),imshow(x);
figure(2),imshow(y,[]);
  2 件のコメント
chaithra
chaithra 2014 年 1 月 28 日
thank you very muchit worked .
Soumyaa Ghosal
Soumyaa Ghosal 2017 年 4 月 25 日
Can you please tell me which method of steganography is this ? Is this LSB or some other method ? Thanks in advance.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by