0

I am studying in the field of steganography/watermarking. I am fairly new to this, so please bear with me! I found an excellent post on here How do I encapsulate some text information in an image and extract it using MATLAB? using LSB method, which I am OK with! The question I want to ask, can the code used in the link be modified to hide data in DWT transform using LSB. If so, how would I attempt it, as I said, I am fairly new to this. Would I get the four subbands and which ever subband I want to embed in,(i.e LH_1)just make changes to code, for example, where L is specified as cover image, would I change L to LL_1??

I am sorry If I confuse anyone with this question. But I need help to know! Thank you alot

edit

%Cover Image
origIm = imread('lena.bmp');


% Discrete Wavelet Transform
[LL LH HL HH]=dwt2(origIm,'haar');
dec=[...
    LL,LH
    HL,HH
    ...
    ];

%figure;imshow(dec,[]);title ('DWT');
%[visibleRows visibleColumns] = size(origIm);

A = importdata('minutiaTest.txt');
binaryString = transpose(dec2bin(A,8));
binaryString = binaryString(:);
N = length(binaryString);

b = zeros(N,1); %b is a vector of bits
   for k = 1:N
       if(binaryString(k) == '1')
              b(k) = 1;
       else
              b(k) = 0;
       end
   end
%c=HH;   
s = HH;
%figure (1);imshow(s);
height = size(HH,1);
width = size(HH,2);

k = 1; Array=[];l=1;my=1;
   for i = 1 : height
       for j = 1 : width
           LSB = mod(double(HH(i,j)), 2);
             if (k>N || LSB == b(k))
                s(i,j) = HH(i,j);
                    l=k+1;
             else 
       if(LSB == 1)
           s(i,j) = HH(i,j) - 1;
       else
           s(i,j) = HH(i,j) + 1;
             Array(my)=l;
                l=l+1;
                    my= my + 1;
       end
                          k = k + 1;
     end
   end
   end


  %figure (2); imshow(s);

  stego=idwt2(LL,LH,HL,HH,'haar');
  imwrite(uint8(stego), 'hiddenmsgimage.bmp');
  %imshow(stego);



  Stego = imread('hiddenmsgimage.bmp');
  %imshow(Stego);


 [LL LH HL HH]=dwt2(Stego,'haar');
dec=[...
    LL,LH
    HL,HH
    ...
    ];
%imshow(HH);
%figure;imshow(dec,[]);title ('DWT');
k = 1;my=1;ur=1;
for i = 1 : height
  for j = 1 : width
    if( k<=N )
      if (my<numel(Array) && Array(my)==ur)
         b(k)=~(mod(double(s(i,j)),2));
      else
         b(k) = mod(double(s(i,j)),2);
      end
    k = k + 1;
    my= my + 1;
 end
 ur=ur+1;
  end
end

Ok so this is what I have done so far. I am now trying to extract the data that I have hidden, can anyone help please?

Community
  • 1
  • 1
  • You have the right idea; treat the sub-bands as arrays with numbers numbers in the same way that an image is an array of numbers (pixels) and do your lsb substitution there however you like. If you need more specific help, you should be more detailed about the exact difficulty you're facing. – Reti43 Dec 04 '14 at 19:49
  • Thats great, thank you very much. I will give it a try,I may need some help again!:) – Hitmanpaddy Dec 05 '14 at 15:52
  • I was wondering can you help me out please? I am attempting to do what you suggested and I am having no luck! This is what I have got so far %Cover Image origIm = imread('lena.bmp'); %Discrete Wavelet Transform [LL LH HL HH]=dwt2(origIm,'haar'); dec=[... LL,LH HL,HH ... ]; figure;imshow(dec,[]);title ('DWT'); [visibleRows visibleColumns] = size(origIm); message = imread('Baboon.bmp'); [hiddenRows hiddenColumns] = size(message); databin=dec2bin(message); A = HH; A_size=size(A); %steg=idwt2(LL,LH,HL,HH,'haar'); I know I need a loop but I'm lost! – Hitmanpaddy Dec 08 '14 at 18:06
  • Ok Im sorry. I'm new here! It is just to display different subbands(i.e) It will plot them on one figure. – Hitmanpaddy Dec 08 '14 at 20:00
  • Before someone attempts to answer this question, there is a possible obstacle you need to address. Assume `origIm` has size 512x512, so that `HH` has size 256x256, which means 65536 pixels. If you want to hide an image by converting the pixel values to binary, each pixel has 8 bits, so it takes 8 `HH` pixels to embed one `message` pixel. Therefore, `message` can't have more than 8192 pixel, which would be a size of, for example, 64x128 but not bigger. Do you have ambitions of hiding anything bigger? Because you won't have anywhere near enough space. – Reti43 Dec 08 '14 at 22:13
  • Thank you Reti43! I have now updated code above. Instead I am trying to hide data from text file (fingerprint coordinates). The problem now I am facing is extraction of the embedded data. Can you help please? – Hitmanpaddy Dec 08 '14 at 22:53
  • Please,If someone can help. I am not asking for code,just some advice on how to go about retrieving the hidden data. many thanks – Hitmanpaddy Dec 09 '14 at 11:07
  • Please don't change the topic of the question, because it is unfair to those who were currently working on your previously changed question and it also makes any answers posted so far irrelevant. If you have resolved your initial enquiry, you can post an answer yourself, but create a new question for anything unrelated to the initial question. I would also suggest you learn the basics of Matlab and have a clear logic plan for your code before you attempt anything. Copying code snipets from the internet and hoping they'll do what you want, without understanding them, will not get you far. – Reti43 Dec 09 '14 at 16:34

0 Answers0