steganographydwt

Using steganography to embed data in DWT subband coefficients


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


Solution

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