www.pudn.com > SPIHT(Matlab).rar > func_ReadRaw.m


function result= func_ReadRaw(filename,nRow,nColumn)
% Matlab implementation of SPIHT (without Arithmatic coding stage)
%
% Read a RAW format gray scale image from disk
%
% input:    filename : input file
%           nSize : size of the output image
%           nRow : row of the output image
%           nColumn : column of the output image
%
% output:   result : output data in matrix format
%
% Jing Tian
% Contact me : scuteejtian@hotmail.com
% This program is part of my undergraduate project in GuangZhou, P. R. China.
% April - July 1999

fid = fopen(filename,'rb');
if (fid==1)   %fid=-1表示fid=-1表示filename不能成功打开
              %fid=0 表示标准输入,一直处于打开状态;
              %fid=1 表示标准输出,一直处于打开追加状态;
              %fid=2表示标准错误,一直处于打开追加状态;
   error('Cannot open image file...press CTRL-C to exit ');pause
end

nSize=nRow*nColumn;
temp = fread(fid, nSize, 'uchar');
fclose(fid);
result = reshape(temp, [nRow nColumn])';