Dear all, How to embed message bits in DWT coefficient values ?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I wanted to embed some message bits in DWT coefficient values of an image and transmit. After embedding the message bits when I have performed uint8() to transmit the image as a grayscale image, at the receiving end, I am not able to get back the message bit from the same coefficient values. On the other hand, if I don't perform uint8() function, I can retrive the message bit successfully.
採用された回答
Walter Roberson
2017 年 4 月 12 日
Use an Integer Wavelet Transform (iwt)
8 件のコメント
Manashee Malita
2017 年 4 月 13 日
編集済み: Manashee Malita
2017 年 4 月 13 日
Thank you sir, I have read these(which are in the link) but, not able to get my answer. My problem is that after embedding process, the image is reconstructed, but, the values are in double and when I convert it into uint8, some pixel values are also get changed which create a problem in retrieving the message in the receiving side. Thank you
After you use the integer wavelet, use uint8() before you do the embedding.
Thank you sir. It is working with Integer Wavelet Transform.
Hi, i am a beginner at image processing..i have the same problem after coverting to uint8 i cann't retrieve the hidden message.. i didn't get understand the solution of @Walter Roberson..when should i do the conversion and how?...plz i am a student and i need it so much..help me
Do not use dwt() at all. Use iwt() instead. The result will be integers that you can embed bits in.
shimaa samy
2017 年 5 月 5 日
編集済み: Walter Roberson
2017 年 5 月 6 日
first..thanks for your reply :)
yes i use lwt ..and it is also the same error..here is my code..i need your help so much..plz tell me what is wrong in my code
% reading the image
img=imread('c:\head4.tif');
% the row (the host row) in which i want to embed the secret message as an example at row
% 305 and start column 3 to end column 570
row_img=img(305,3:570);
% secret message is a vector
secret=[100,200,20,40,50,80,60,230,140,1,2,0,210,205,190,9,0,32,80,100,200,201,202,203,199,189,187,180,170,0,1,0,1,0,100];
secret_bin=dec2bin(secret,8);
secret_bin=secret_bin';
length_secret = size(secret_bin,1)*size(secret_bin,2);
wname = liftwave('haar','int2int');
host_row=double(row_img);
[CA, CD]=lwt(host_row,wname);
length_CA = size(CA,2);
c = 1;
% embedding the secret_bin in the last signficant bit of each CA ( 1 LSB of CA )
for b = 1:1:length_CA
if b <= length_secret
xb=CA(1,c);
if xb < 0
xb= abs(xb);
if strcmp(secret_bin(b), '0')
xb=bitset(xb,1,0);
else
xb=bitset(xb,1,1);
end
CA(1,c)=-xb;
else
if strcmp(secret_bin(b), '0')
CA(1,c) = bitset(CA(1,c),1,0);
else
CA(1,c) = bitset(CA(1,c),1,1);
end
end% end if xb<0
c = c+ 1;
if (c > length_CA)
c = 1;
end
end % if b <= length_secret
end % end for loop b=8:-1:1
stego_host_uint8 = uint8(ilwt(CA,CD,wname));
stego_host_dble = (ilwt(CA,CD,wname));
% Extracting the secret vector from the stego_host_uint8
watermarked_host=double(stego_host_uint8);
[CA_ex, CD_ex] = lwt(watermarked_host,wname);
length_CA_ex = size(CA_ex,2);
c = 1;
secret_bits_ex = zeros(1,size_data);
for b = 1:1:length_CA_ex
if b <= length_secret
xb=CA_ex(1,c);
if xb < 0
xb= abs(xb);
end
secret_bits_ex(b) = bitget(xb,1);
%letter = bitset(letter,b,bitget(xb,1));
c = c + 1;
end
end
% function i created
secret_ex=binRoundC2Dec(secret_bits_ex,8);
% comparison between the input secret vector and the extracted
message=secret';
if secret_ex == message
disp('yes equal');
else
disp('No Equal');
end
% the extracted output [100;200;20;40;114;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;162;0;1;0;1;0;100]
% the input secret [100;200;20;40;50;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;170;0;1;0;1;0;100]
% they are diffrent at positions 5 , 29 ...why?
shimaa samy
2017 年 5 月 5 日
編集済み: Walter Roberson
2017 年 5 月 6 日
% reading the image
img=imread('c:\head4.tif');
% the row (the host row) in which i want to embed the secret message as an example at row 305 and start column 3 to end column 570
row_img=img(305,3:570);
% secret message is a vector
secret=[100,200,20,40,50,80,60,230,140,1,2,0,210,205,190,9,0,32,80,100,200,201,202,203,199,189,187,180,170,0,1,0,1,0,100];
secret_bin=dec2bin(secret,8);
secret_bin=secret_bin';
length_secret = size(secret_bin,1)*size(secret_bin,2);
wname = liftwave('haar','int2int');
host_row=double(row_img);
[CA, CD]=lwt(host_row,wname);
length_CA = size(CA,2);
c = 1;
% embedding the secret_bin in the last signficant bit of each CA ( 1 LSB of CA )
for b = 1:1:length_CA
if b <= length_secret
xb=CA(1,c);
if xb < 0
xb= abs(xb);
if strcmp(secret_bin(b), '0')
xb=bitset(xb,1,0);
else
xb=bitset(xb,1,1);
end
CA(1,c)=-xb;
else
if strcmp(secret_bin(b), '0')
CA(1,c) = bitset(CA(1,c),1,0);
else
CA(1,c) = bitset(CA(1,c),1,1);
end
end% end if xb<0
c = c+ 1;
if (c > length_CA)
c = 1;
end
end % if b <= length_secret
end % end for loop b=8:-1:1
stego_host_uint8 = uint8(ilwt(CA,CD,wname));
stego_host_dble = (ilwt(CA,CD,wname));
% Extracting the secret vector from the stego_host_uint8
watermarked_host=double(stego_host_uint8);
[CA_ex, CD_ex] = lwt(watermarked_host,wname);
length_CA_ex = size(CA_ex,2);
c = 1;
secret_bits_ex = zeros(1,length_secret);
for b = 1:1:length_CA_ex
if b <= length_secret
xb=CA_ex(1,c);
if xb < 0
xb= abs(xb);
end
secret_bits_ex(b) = bitget(xb,1);
%letter = bitset(letter,b,bitget(xb,1));
c = c + 1;
end
end
% function i created
secret_ex=binRoundC2Dec(secret_bits_ex,8);
% comparison between the input secret vector and the extracted
message=secret';
if secret_ex == message
disp('yes equal');
else
disp('No Equal');
end
% the extracted output [100;200;20;40;114;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;162;0;1;0;1;0;100]
% the input secret [100;200;20;40;50;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;170;0;1;0;1;0;100]
% they are diffrent at positions 5 , 29 ...why?
% Extracting the secret vector from the stego_host_dble
watermarked_host_dbl=double(stego_host_dble);
[CA_ex_dbl, CD_ex_dbl] = lwt(watermarked_host_dbl,wname);
length_CA_ex = size(CA_ex_dbl,2);
c = 1;
secret_bits_ex_dbl = zeros(1,length_secret);
for b = 1:1:length_CA_ex
if b <= length_secret
xb=CA_ex_dbl(1,c);
if xb < 0
xb= abs(xb);
end
secret_bits_ex_dbl(b) = bitget(xb,1);
%letter = bitset(letter,b,bitget(xb,1));
c = c + 1;
end
end
% function i created
secret_ex_dbl=binRoundC2Dec(secret_bits_ex_dbl,8);
% comparison between the input secret vector and the extracted
message=secret';
if secret_ex_dbl == message
disp('yes equal from stego dble');
else
disp('No Equal from stego dble');
end
% the extracted output [100;200;20;40;50;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;170;0;1;0;1;0;100]
% the input secret [100;200;20;40;50;80;60;230;140;1;2;0;210;205;190;9;0;32;80;100;200;201;202;203;199;189;187;180;170;0;1;0;1;0;100]
% they are equal when extracting directly from double lwt without conversion to uint8
You appear to have posted this question as https://www.mathworks.com/matlabcentral/answers/338974-help-embedding-secret-message-using-lwt-cannot-extract-the-secret-message-correctly
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Wavelet Toolbox についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
