0

im working on a video steganography using LSB technique..im using traffic.avi and xylophone.mpg as the cover medium and when im using the licence.txt file (in the attach file) to encode into the video it runs well however when im using a short messsage for the input text it shows an error which is

"The matrix MSG in ENCODE must have K columns." and sometimes when use short text it gives error "msg is too long to encode"

i have no idea what does this 2 set of coding means and how to edit the code to make it possible to encode a short msg...below this is some of the code that i guess relate to this problem

     num2add = 80-length(msg);  % Number of spaces to add to end of MSG.
     if num2add < 0, error('This message is too long to encode.'), end
     newmsg = [msg,repmat(' ',1,num2add)]; % 80 chars always encoded.
     msgmat = dec2bin(newmsg)-48; % Each row is a bin. rep. of an ascii char.

and also this coding

    if m_msg == 1
        type_flag = 2;  % binary vector
        [msg, added] = vec2mat(msg, k);
    elseif m_msg ~= k
        error('comm:encode:InvalidMatrixColumnSize','The matrix MSG in ENCODE must have K columns.'); 

BELOW THIS IS THE FULL ENCODE CODING continue after the first part of the above coding!

    B = pic1(:,:,1);   [piclngth pichght] = size(B);  % Choose the first page.
    dim1 = piclngth-2;   dim2 = pichght-3;   keyb = key(end:-1:1);
    rows = cumsum(double(key));   
    columns = cumsum(double(keyb));  % Coord pairs for KEY (rows,columns)
    A = zeros(dim1,dim2); % This matrix will house the hiding points.
    A = crtmtrx(A,rows,columns,dim1,dim2,key);
    idx = find(A==1);  % This same index will be used for pic matrix.

    for vv = 1:80  % This is the encoder.  
    for uu = 1:8 
    if msgmat(vv,uu)==1;
       if rem(B(idx(uu+8*(vv-1))),2)==0
            if(frame==1)
            disp('some pixel value of original frame');
            B(idx(uu+8*(vv-1)))
             end
          B(idx(uu+8*(vv-1))) = B(idx(uu+8*(vv-1)))+1;
            if(frame==1)
            disp('some pixel value of stegno video frame');
            B(idx(uu+8*(vv-1)))
             end
       end
    elseif rem(B(idx(uu+8*(vv-1))),2)==1
            if(frame==1)
            disp('some pixel value of original frame');
            B(idx(uu+8*(vv-1)))
             end
          B(idx(uu+8*(vv-1))) = B(idx(uu+8*(vv-1)))-1;
            if(frame==1)
            disp('some pixel value of stegno video frame');
            B(idx(uu+8*(vv-1)))
             end
         end
     end
   end
    global newpic;
    newpic = pic1;   newpic(:,:,1) = B;
    f(frame) = im2frame(newpic);
  end

    frameRate = get(vidObj,'FrameRate');


    movie2avi(f,'stegano_video.avi','compression','None', 'fps', 20);
    success = 1;

    function A = crtmtrx(A,rows,columns,dim1,dim2,key)
    % Creates the matrix used to find the points to hide the message.

    jj = 1;   idx = 1;
  while 640 > length(idx) %  Need 560 points to hide 80 characters.     
for ii = 1:length(rows)
    if rows(ii) < dim1
       rows(ii) = rem(dim1,rows(ii))+1;
    else
       rows(ii) = rem(rows(ii),dim1)+1;
    end
    if columns(ii) < dim2
       columns(ii) = rem(dim2,columns(ii))+1;
    else
       columns(ii) = rem(columns(ii),dim2)+1;
    end
    A(rows(ii),columns(ii)) = 1;
end
rows = jj*cumsum(double(columns))+round(dim2/2);  % Each pass is diff.
columns = jj*cumsum(double(rows))+round(dim1/2);
if jj > ceil(640/length(key))+2  % Estimate how many iters. needed.
   idx = find(A==1);
 end
   jj = jj+1;
end

this is some of the input text and the right one is the encypted txt

lisa adam
  • 1
  • 1
  • Please provide code which allows to reproduce your problem, including example input data and initialisation of all variables. – Daniel Dec 10 '13 at 09:59
  • sir kindly see the updated above post..ive made some edit by post the full encode coding plus the pic of text that im using for input..tq – lisa adam Dec 13 '13 at 17:27

1 Answers1

0

The code that triggers the error is pretty clear:

num2add = 80-length(msg);  % Number of spaces to add to end of MSG.
if num2add < 0, error('This message is too long to encode.'), end

So basically you will get the error as soon as there are more than 80 characters in msg. I am not sure whether the 80 is meaningfull, you can try to increase it but that may break something else.

Dennis Jaheruddin
  • 21,208
  • 8
  • 66
  • 122
  • however the input text that i manage to encode is about 6000++ characters..i've tried to increase it by 500 then it shows this error ??? Attempted to access msgmat(1,8); index out of bounds because size(msgmat)=[500,7]. Error in ==> encoder at 39 if msgmat(vv,uu)==1; – lisa adam Dec 13 '13 at 16:32
  • act first i encrypt the text using 3des after that i encode..so is it a problem cause by the encyrpt text or what – lisa adam Dec 13 '13 at 16:34
  • sir kindly see the updated above post..ive made some edit by post the full encode coding plus the pic of text that im using for input..tq – lisa adam Dec 13 '13 at 17:24