0

I have been doing more research on the topic of DWT Steganography. I have came across the code below on the web. This is the first time I have came across subbands coefficients being specified. I have an idea what the code does but I would like someone to verify it!

steg_coeffs = [4, 4.75, 5.5, 6.25, 7];

for jj=1:size(message,2)+1
    if jj > size(message,2)
        charbits = [0,0,0,0,0,0,0,0];
    else
        charbits = dec2bin(message(jj),8)';
        charbits = charbits(:)'-'0';
    end

    for ii=1:8
        bit_count = bit_count + 1;

        if charbits(ii) == 1
            if HH(bit_count) <= 0
                HH(bit_count) = steg_coeffs(randi(numel(steg_coeffs)));
            end
        else
            if HH(bit_count) >= 0
                HH(bit_count) = -1 * steg_coeffs(randi(numel(steg_coeffs)));
            end
        end
    end

I think the steg_coeffs are selected coeffiecnt of the HH subband, where bits will be embedded in these selected coefficients. I have googled randi and believe that it will randomise these specified coeffs on each iteration of the loop and embed in random selection coeffs. I am correct?? Thank you

1 Answers1

0

Typing help randi, you find out that randi(IMAX) will return a scalar, which will be an integer uniformly distributed (based on a prng) in the range 1:IMAX. To put simply, it chooses a random integer between 1 and IMAX.

numel(matrix) returns the total number of elements in the matrix.

So, steg_coeffs(randi(numel(steg_coeffs))) chooses a random element from steg_coeffs, by choosing a random index between 1 and 5.

The embedding algorithm is implemented in the following block.

if charbits(ii) == 1
    ...
else
    ...
end

Basically, if you're embedding a 1, the HH coefficient has to be positive. If it isn't, substitute it with one from steg_coeffs. Similarly, if you're embedding a 0, the HH coefficient has to be negative. If it isn't, substitute it with the negative of one from steg_coeffs.

The idea is that when you extract the secret, all you have to check is whether the HH coefficient is positive or negative, to know whether the bit has to be 1 or 0.

Reti43
  • 9,656
  • 3
  • 28
  • 44
  • Thank you Reti43. A very clear explanation as always :) – Hitmanpaddy Jan 05 '15 at 15:37
  • Hi Reti43. Just wondering when you say "by choosing a random index between 1 and 5" do you mean it could be anyone of steg_coeffs = [4, 4.75, 5.5, 6.25, 7]; or do you mean it could be 1,2,3,4,5. I am thinking it must be a random int from the array i.e 4.75, 6.25 etc but I just want to double check!thanks – Hitmanpaddy Jan 05 '15 at 17:26
  • The random index will be between 1 and 5. You then use that to access a specific elements of steg_coeffs, e.g. steg_coeffs(1) = 4, steg_coeffs(2) = 4.75, etc. So by choosing a random number between 1 and 5, you effectively choose a random element among 4, 4.75, 5.5, 6.25 and 7. – Reti43 Jan 05 '15 at 19:02
  • Hi,I have another query regarding the steg_coeffs. Why chose the coeffs from 4 to 7. From what I can gather,by looking at the HH coeffs in matlab, it is to do with a specific subband. I understand that all 4 subbands have different coeffs.If I was to chose HL for example, would the coeffs need to be different? Thanks – Hitmanpaddy Jan 13 '15 at 18:45
  • Yes, the subbands have different coefficients because they describe different information about the image. Why the code substitutes any coefficient, when it has to, with values between 4 and 7 can only be referenced by the intention of the code author, or the paper he based his code on. If I were to guess, I would say that the HH coefficients tend to have low values, so substituting them with other low values will not lead to extreme image distortions. – Reti43 Jan 13 '15 at 20:58