MATLAB: Error using “bitset” function for DCT steganography…please help

bitsetdct steganography ; jpeg;

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

Best Answer

"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.