error using "bitset" function for DCT steganography...please help

2 vues (au cours des 30 derniers jours)
Budoor Salem
Budoor Salem le 20 Nov 2016
Commenté : Budoor Salem le 25 Nov 2016
I was working on DCT steganography function after getting the quantized DCT coefficients I did this embedding function on the first channel of the image...my quantized DCT coefficients in this code called "channel_q" where I don't embed in the first DC coefficient of each block and I don't embed in 0 or 1 coefficient..using the "bitset" function for embedding the binary message in the quantized DCT coefficients.. I keep getting this error..can anyone help please..I am stuck at this point
??? Error using ==> bitset
Inputs must be non-negative integers.
Error in ==> jpeg_Embedding at 61
channel_q(i+ii-1,j+jj-1,k)=bitset(channel_q(i+ii-1,j+jj-1,k),1,BinaryMsg(j));
here is the embedding function
message='this is a message to test';
BinaryMsg=str2bin(message);
msgB_length=length(BinaryMsg);
%================================
if (ch == 1)% only embed in the luma
for k=1:1
for i=1:block_size:size(channel_q,1)
for j=1:block_size:size(channel_q,2)
for ii=1:block_size
for jj=1:block_size
if(~( channel_q(1,1)) || (channel_q(i,j) ~=0) || (channel_q(i,j) ~=1))
channel_q(i+ii-1,j+jj-1,k)=bitset(channel_q(i+ii-1,j+jj-1,k),1,BinaryMsg(j));
if (BinaryMsg(j)==msgB_length)
break;
else
BinaryMsg(j+1)
end
end
end
end
end
end
end
end
  1 commentaire
Jan
Jan le 20 Nov 2016
The message "Inputs must be non-negative integers" sounds clear. What is the type and the values of channel_q?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 21 Nov 2016
"For pixel values between [0, 255], 8x8 block DCT values can take values between -65280.0 and 65280.0 (±255x8x8)."
Your DCT is returning floating point values. You need to think about what it means to set a bit in a floating point value.
I experimented with
samp = uint8(reshape((1:64),8,8);
and took the dct2, int16() that, and then systematically changed one value by +1 or -1, idct2, uint8, compare to original. No matter which one location was changed by +1 or -1, the changed version and the original were exactly the same. I had to change by 2 in order to get a reconstructed array that was not the same as the original. I did not try systematically to prove that a change of 2 in a particular place would always result in a reconstruction different than the original.
  2 commentaires
Walter Roberson
Walter Roberson le 23 Nov 2016
channel_q16 = int16(channel_q);
now bitset() on the appropriate channel_q16 location and bit.
Afterwards,
channel_q = double(channel_q16);
and proceed to idct2.
However, you will find that setting the least significant bit is not enough; you will need to set some more significant bit.
Budoor Salem
Budoor Salem le 25 Nov 2016
Thank you Mr. Walter for the help and the advice it works :D

Connectez-vous pour commenter.

Plus de réponses (1)

Budoor Salem
Budoor Salem le 22 Nov 2016
At first, thank you Mr. Walter for taking the time answering me but I am sorry Mr. Walter I did not understand what I need to do is it like I need to convert my quantized DCT coefficients (channel_q) to uint8 before using the bitset??

Community Treasure Hunt

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

Start Hunting!

Translated by