⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writedata.m

📁 基于图象的数据隐写和提取matlab代码
💻 M
字号:
function res = writedata(bindat, filename);
%bindat is a stream of binary values
%filename is the file to write to

binmat = [];

% Reconstruct binary matrix
[dnk, sizebindat] = size(bindat);
for i=1:(sizebindat/8)
   bintemp(i,:) = bindat((i-1)*8+1:i*8);
end

binmat=bintemp;

% Get a decimal vector
decvec = transpose(bin2dec(binmat));

% Typecast the decimal vector to a char
% Res is the data that we want to write to the file
res=char(decvec);

% Open the file
% Check to make sure that the file exists
fid = fopen(filename, 'w');
if (fid == -1) 
    error('write_file: cannot open file for writing');
end

% Write data res to file fid
fwrite(fid,res);

% Close the file
fclose(fid);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -