[Index for tmp_for_tar/imgio] [Return to Master Index]

readfi

(tmp_for_tar/imgio/readfi.m)


Function Synopsis

im = readfi(fname)

Help text

       im = readfi(fname)

 readfi    Read a FI image file into Octave.  The FI image files may be
           gzipped.  FI is a floating point format, whose headers are
           similar to those of PGM/PPM/PBM, except that the header is
           `FI' and the data is represented by big-endian
           single-precision floating point (32 bits per element).
           And number of pixels is ALWAY size of matrix (contrary to PPM).

           im = readfi(fname)
           fname - name of FI file.
           im    - the image as an Octave variable.

           im = readpnm(fid)
           fid - file ID (for the PNM image file).
           im  - the image as an Octave variable.

 Created: 7.8.98.
 Version: 1.0



Cross-Reference Information

This function calls

Listing of function file tmp_for_tar/imgio/readfi.m

##       im = readfi(fname)
##
## Copyright (C) 1998 Ariel Tankus
## 
## This program is free software.
## This file is part of the Image Processing Toolbox for Octave
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
##

## readfi    Read a FI image file into Octave.  The FI image files may be
##           gzipped.  FI is a floating point format, whose headers are
##           similar to those of PGM/PPM/PBM, except that the header is
##           `FI' and the data is represented by big-endian
##           single-precision floating point (32 bits per element).
##           And number of pixels is ALWAY size of matrix (contrary to PPM).
##           
##
##           im = readfi(fname)
##           fname - name of FI file.
##           im    - the image as an Octave variable.
##
##           im = readpnm(fid)
##           fid - file ID (for the PNM image file).
##           im  - the image as an Octave variable.
##

## Author: Ariel Tankus <arielt@math.tau.ac.il>
## Created: 7.8.98.
## Version: 1.0

function im = readfi(fname)

## constants:
fiMagic = 'FI';

[fid, magicnum] = getmagicnum(fname);
if (~strcmp(magicnum, fiMagic))
    error("File contains no FI image.");
end

width  = str2num(getNonComment(fid, '#'));
[height, whitespace] = fscanf(fid, ' %s%c', "C");
if (~isspace(whitespace))
    error('Illegal character after header.');
end
height = str2num(height);

[data, count] = fread(fid, [width, height], 'float', 0, 'ieee-be');

if (count < width*height)
    error('Unable to read the whole image.  File might be truncated.');
end
im = data';		     # convert image [x,y] to matrix [m,n]

fclose(fid);

endfunction

Produced by oct2html on Sat Sep 14 9:47:03 2002
Cross-Directory links are: ON