2013-12-10 32 views
0

即时通讯工作在使用LSB技术..im使用traffic.avi和xylophone.mpg作为封面媒体和im使用licence.txt文件(在附件文件中)编码到视频中,但运行良好,但是当我使用输入文本的短消息时,它显示的错误是错误“ENCODE中的矩阵MSG必须有K列”

“ENCODE中的矩阵MSG必须有K列。有时当使用简短的文字提示错误“味精太长编码”

我不知道这是否2组编码方式以及如何修改代码,使其能够编码短味精......下面这是一些我猜的代码涉及到这个问题

 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. 

而且这种编码

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.'); 

低于这个是完整的ENCODE CODING继续第一部O后f上面的编码!

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

+0

请提供允许重现您的问题的代码,包括示例输入数据和所有变量的初始化。 – Daniel

+0

先生亲切地看到更新后的上述帖子..通过发布一些编辑后,完整的编码加上我用于输入的文本图片..tq –

回答

0

触发错误的代码是相当清楚的:

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 

所以基本上你只要有在msg超过80个字符得到的错误。我不确定80是否有意义,你可以尝试增加它,但这可能会破坏别的东西。

+0

然而,我设法编码的输入文本是大约6000 ++字符。 。我试图增加500,然后显示这个错误 ???试图访问msgmat(1,8);索引越界,因为size(msgmat)= [500,7]。 错误==>编码器39 if msgmat(vv,uu)== 1; –

+0

先采取行动我使用3des加密文本后,我编码..所以这是一个问题导致的encyrpt文本或什么 –

+0

先生亲切地看到更新以上post..ive做了一些编辑后通过完整的编码加上pic即时消息用于输入..tq的文本 –

相关问题