I did PVD modulus steganography in matlab.The Hiding process is correct and it shows the stego image.But the retrieval process is not correct. Can any one please sort out the problem in the retrieval process.
    6 views (last 30 days)
  
       Show older comments
    
I did PVD steganography in matlab. The Hiding process is correct and it shows the stego image.But the retrieval process is not correct. Function CreateeStego hides the secret, im1 is the cover image and im2 is the secret image. Function RecovrSecret retrieves the secret form the stego image. The input to the RecoverSecret is the stego image, this function is not working properly it only shows busy, does not obtains the output.
function [ Steg,capacity ] = CreateeStego( im1,im2 )
cCap = 0;
for dim = 1: 3
    em = im2(:,:,dim);
    em = em(:);
    len = length(em);
    in = [];
      in=[in dec2bin(len,20)];
      for i=1:len         %character convert to binary
          in=[in dec2bin(em(i),8)];
      end
      a = im1(:,:,dim);    %get cover image
      [r,c]=size(a);
      final=double(a);
      next=0;
      capacity=0; %bit space that can be embedded
      for x=0:1:r-1       %traverse through all the pixel value on
          for y=0:2:c-1   %the image by 2 consecutive pair non overlaping pixel
              g=a(1+x,1+y:2+y);
              g=double(g);
              d=g(1,2)-g(1,1);    %d=difference between 2 pixel
              lb=[0 8 16 32 64 128]; %lowerbound
              ub=[7 15 31 63 127 255]; %upperbound
              dap=abs(d);
              for i=1:1:6         %test the R boundary
                  if(dap >= lb(i)&& dap <= ub(i))
                      n=ub(i)-lb(i)+1; %quantization width of range
                      t=log2(n);       %maximum bit can be embedded between 2 pixel
                      capacity=capacity+t;
                      nt=2^t;
                      FREM =mod((g(1,1)+g(1,2)),nt);
                      if(next>length(in))
                          m=0;
                          m1=0;
                      elseif(next+t>length(in))
                          if(1+next>=length(in))
                              k=zeros(1,t);
                          else
                              k=in(1+next:length(in));
                          end
                          diff =next+t-length(in);
                          k1=zeros(1,t);
                          if(diff>0)
                              for j=1:next+t-length(in)
                                  k1(j)=k(j);
                              end
                          end
                          k=k1;
                          next=next+t;
                          %k=int2str(k);
                          k=bin2dec(char(k));
                          if(1+next>length(in))
                              m=0;
                              m1=0;
                          else
                              m=abs(FREM-k);
                              m1=2^t-abs(FREM-k);
                          end
                      else
                          k=in(1+next:t+next);
                          next=next+t;
                          k=bin2dec(char(k));
                          m=abs(FREM-k);
                          m1=2^t-abs(FREM-k);
                      end
                  end
              end
              if(FREM>k && m<=((2^t)/2) && g(1,1)>=g(1,2))
                  P0=[g(1,1)-ceil(m/2) g(1,2)-floor(m/2)];
              elseif (FREM>k && m<=((2^t)/2) && g(1,1)<g(1,2))
                  P0=[g(1,1)-ceil(m/2) g(1,2)-floor(m/2)];
              elseif (FREM>k && m>((2^t)/2) && g(1,1)>=g(1,2))
                  P0=[g(1,1)+ceil(m1/2) g(1,2)+floor(m1/2)];
              elseif (FREM>k && m>((2^t)/2) && g(1,1)<g(1,2))
                  P0=[g(1,1)+ceil(m1/2) g(1,2)+floor(m1/2)];
              elseif (FREM<=k && m<=((2^t)/2) && g(1,1)>=g(1,2))
                  P0=[g(1,1)+ceil(m/2) g(1,2)+floor(m/2)];
              elseif (FREM<=k && m<=((2^t)/2) && g(1,1)<g(1,2))
                  P0=[g(1,1)+ceil(m/2) g(1,2)+floor(m/2)];
              elseif (FREM<=k && m>((2^t)/2) && g(1,1)>=g(1,2))
                  P0=[g(1,1)-ceil(m1/2) g(1,2)-floor(m1/2)];
              elseif (FREM<=k && m>((2^t)/2) && g(1,1)<g(1,2))
                  P0=[g(1,1)-ceil(m1/2) g(1,2)-floor(m1/2)];
              end
              if((g(1,1)==0 || g(1,2)==0)&&(P0(1)<0 || P0(2)<0))
                  P1=[P0(1)+((2^t)/2) P0(2)+((2^t)/2)];
                  final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                  final(1+x,2+y)=P1(1,2);
              elseif((g(1,1)==255 || g(1,2)==255)&&(P0(1)>255 || P0(2)>255))
                  P1=[P0(1)-((2^t)/2) P0(2)-((2^t)/2)];
                  final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                  final(1+x,2+y)=P1(1,2);
              elseif(dap>128)
                  if(P0(1)<0 && P0(2)>=0)
                      P1=[0 P0(1)+P0(2)];
                      final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                      final(1+x,2+y)=P1(1,2);
                  elseif(P0(1)>=0 && P0(2)<0)
                      P1=[P0(1)+P0(2) 0];
                      final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                      final(1+x,2+y)=P1(1,2);
                  elseif(P0(1)>255 && P0(2)>=0)
                      P1=[255 P0(2)+(P0(1)-255)];
                      final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                      final(1+x,2+y)=P1(1,2);
                  elseif(P0(1)>=0 && P0(2)>255)
                      P1=[P0(1)+(P0(2)-255) 255];
                      final(1+x,1+y)=P1(1,1); %replace new pixel value into final
                      final(1+x,2+y)=P1(1,2);
                  end
              else
                  final(1+x,1+y)=P0(1,1); %replace new pixel value into final
                  final(1+x,2+y)=P0(1,2);
              end
          end
      end
      Steg(:,:,dim) = final;
      cCap = cCap + capacity;
  end
  display('Embedded Successfully');
  end
function RecIm = RecovrSecret(Image)
msg = [];
flag = 0;
[row,col,dim]=size(Image);
j=0;
length=0;
for p = 1:dim
      layer = Image(:,:,p);
      for x=0:1:row-1
          for y=0:2:col-1
              gp=layer(1+x,1+y:2+y);
              gp=double(gp);
              nd=abs(gp(1,2)-gp(1,1));
              lb=[0 8 16 32 64 128];
              ub=[7 15 31 63 127 255];
              for i=1:1:6
                  if(nd>=lb(i)&&nd<=ub(i))
                      w=ub(i)-lb(i)+1;
                      t=log2(w);
                      FREM=mod(gp(1,1)+gp(1,2),2^t);
                      k=dec2bin(FREM,t);
                      msg = [msg k];
                      j=j+t;
                      if(flag==0 && j>=20)
                          length=bin2dec(msg(1:20))+3;load tab; %possible 3 char error
                          length=length*7;
                          flag=1;
                      end
                      if(flag==1 && j>=length)
                          w=1;
                          for q=20:7:length-7
                              finalIm(w)=bin2dec(msg(1+q:7+q));
                              w=w+1;
                          end
                      end
                  end
              end
          end
      end
  RecIm(:,:,p) = reshape(finalIm,[256,256]);
end
end
0 Comments
Answers (1)
  Walter Roberson
      
      
 on 2 Oct 2015
        All of your "for" loops in the image recovery have finite length, and you have no "while" loops. Your image recovery therefore must terminate at some point. It might take a long time, but it will finish.
You should use the debugger to trace the execution of the routine and figure out where it is spending its time. You could pass in small images to verify that it is working.
0 Comments
See Also
Categories
				Find more on Image Processing Toolbox in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!