Cant extract embedded stego message after compression is applied to image?

妖精的绣舞 提交于 2019-12-25 04:45:23

问题


I am attempting to extract hidden data that has been hidden using DWT steganograpy.Then, when I apply compression, nothing happening! I have used the following code to compress my .bmp image, but no hidden message is being extracted after compression is applied. I tried running in debugger and it just seems to be jumping to the end of the code, after looping around only once. Any ideas of the problem. Data is extracting fine prior to compression being applied.

%%%%%%%%%%%%%%%%%%DECODING%%%%%%%%%%%%%%%%%%%%%%%
%clear;
filename='newStego.bmp';
stego_image=imread(filename);
compression=90;
file_compressed=sprintf('compression_%d_percent.jpg',compression);
imwrite(imread(filename),file_compressed,'Quality',compression);
new_Stego = double(imread (file_compressed));
[LL,LH,HL,HH] = dwt2(new_Stego,'haar');

message = '';
msgbits = '';
for ii = 1:size(HH,1)*size(HH,2)
    if HH(ii) > 0
        msgbits = strcat (msgbits, '1');
    elseif HH(ii) < 0
        msgbits = strcat (msgbits, '0');
    else
        return;
    end

    if mod(ii,8) == 0
        msgChar = bin2dec(msgbits);
        if msgChar == 0
            break;
        end
        msgChar = char (msgChar);
        message = [message msgChar]; 
        msgbits = '';


       disp(message);

    end


end

回答1:


Your compression scheme is lossy, which means that you irreversibly lose some information in compressing your data.

Specifically, jpeg compression transforms the pixel data to the frequency domain and zeroes out many high frequency components. The DWT detailed coefficients (LH, HL and HH) have some parallels to frequency coefficients and so will be strongly affected by this compression (the HH coefficients even more so). Keep in mind that even 100% quality jpeg compression is lossy, but the distortions are naturally minimised.

If you still want to compress your data, you must do it in a way that doesn't destroy the way you have embedded your information. You have two options:

  • Use a lossless compression scheme, e.g. png or zip.
  • Use a different steganography algorithm which is robust to jpeg compression.

Extra: The reason why your decoding process only loops around once is because one of the first few HH coefficients is 0, resulting in premature termination. Either that, or the first 8 coefficients are negative, which results to an extracted character of 0, which is your end of message condition.



来源:https://stackoverflow.com/questions/28190487/cant-extract-embedded-stego-message-after-compression-is-applied-to-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!