from
Auxiliary Functions for Reading and Writing of Binary Data
by Christopher
A set of helper functions for reading and writing of readily formatted binary data.
|
| readbinary(fn, sz, prec)
|
function [ D ] = readbinary(fn, sz, prec)
%READBINARY reading binary data helper function.
% READBINARY(FN, SZ, PREC) reads binary data from the file FN and reshapes
% it according to the size array SZ.
% PREC controls the form and size of the result. See the list
% of allowed precisions under FREAD.
%
% % Example for reading a 200x200 uint16 image as single from the file img.raw:
% I = readbinary('img.raw', [200 200], 'uint16=>single');
%
% See also FREAD, WRITEBINARY
% Author(s): medical-image-processing.com
fid = fopen(fn);
D = fread(fid, prod(sz), prec);
fclose(fid);
D = reshape(D, sz);
|
|
Contact us at files@mathworks.com