Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
利用MatLab实现图像隐写_Matlab_Image Processing_Octave_Steganography - Fatal编程技术网

利用MatLab实现图像隐写

利用MatLab实现图像隐写,matlab,image-processing,octave,steganography,Matlab,Image Processing,Octave,Steganography,我正在使用倍频程来解密图像。我必须恢复隐藏在载体图像中的图像。我的代码只有在目标图像是黑白的情况下才起作用,我如何调整它使其也能在彩色中起作用 I2 = imread('c:/df/output/stegoFlowers.png'); output_stream=""; data_size_s=""; %In bytes and as a string k=1; for i=1:rows(I2) for j=1:columns(I2) if (k<

我正在使用倍频程来解密图像。我必须恢复隐藏在载体图像中的图像。我的代码只有在目标图像是黑白的情况下才起作用,我如何调整它使其也能在彩色中起作用

 I2 = imread('c:/df/output/stegoFlowers.png');

 output_stream="";
 data_size_s="";     %In bytes and as a string  

 k=1;
 for i=1:rows(I2)
    for j=1:columns(I2)
     if (k<18) s=dec2bin(double(I2(i,j,1)),8); data_size_s=strcat(data_size_s,s(8)); k++; endif
     if (k<18) s=dec2bin(double(I2(i,j,2)),8); data_size_s=strcat(data_size_s,s(8));    k++; endif
     if (k<18) s=dec2bin(double(I2(i,j,3)),8); data_size_s=strcat(data_size_s,s(8));   k++; endif
 end
end

%We pass the size of the target image from string to integer
target_rows=uint32(bin2dec(substr(data_size_s, 1,8)));   
target_columns=uint32(bin2dec(substr(data_size_s,9,8))); 
data_size_int=target_rows*target_columns;  % Data Size in bytes as integer


%We read the output_stream from the stego image
total_data_size=(8*data_size_int)+16;    % Total length of the output stream (header +target data)

k=1;
for i=1:rows(I2)
  for j=1:columns(I2)
  if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,1)),8); output_stream=strcat(output_stream,s(8)); k++; endif
  if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,2)),8); output_stream=strcat(output_stream,s(8)); k++; endif
  if (k<=(total_data_size)) s=dec2bin(double(I2(i,j,3)),8); output_stream=strcat(output_stream,s(8)); k++; endif
  end
end


I3_rows=uint32(bin2dec(substr(output_stream,1,8)));
I3_columns=uint32(bin2dec(substr(output_stream,9,8)));
k=17;

I3=uint8(zeros(I3_rows,I3_columns,3));     
total_data_size=(8*data_size_int)+16;
for i=1:I3_rows
  for j=1:I3_columns
   if (k<=total_data_size) I3(i,j,1)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
     if (k<=total_data_size) I3(i,j,2)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif
    if (k<=total_data_size) I3(i,j,3)=uint8(bin2dec(substr(output_stream,k,8))); k=k+8; endif


  end
end

 %We show the hidden image.
 imshow(I3);

你说的黑白是指灰度吗?这段代码只在目标图像是黑白的情况下才有效,而不是彩色的情况下。嗯,我们说的是同一件事。无论如何,彩色图像的每个R、G和B分量都有3个平面。黑白图像只有一个平面。看起来你需要做的是隐藏所有三个颜色平面,为此你需要3倍的空间。