3 files.ct

Contents of this section

This section describes functions from file files.ct.

3.1 export_PBM

[] = export_PBM(fn,r;g,b)
 export_PBM("file.pbm",x) writes integer matrix x in
   binary PBM (actually PGM) file "file.pbm". Matrix elements
   are truncated to the range 0..255. If all elements are
   equal to 0 or 1 a black and white PBM file will be written.

   export_PBM("file.pbm",r,g,b) creates a 24-bit PBM file.
   The integer matrices r,g and b represent the red, green
   and blue values. They must have equal dimensions.
See also:
import_PBM .
   Error codes:
   1: First arg not a string
   2: Argument is not integer matrix
   3: export_PBM must be called with 2 or 4 input args
   4: Dimensions of R,G,B matrices must be equal

3.2 export_RIS8

[] = export_RIS8(fn,x)
 export_RIS8("file.hdf",x) writes (appends) integer matrix x
   to HDF file "file.hdf" as a raster-8 image (Raster Image Set, RIS).
   When the file is opened with default settings using the usual
   HDF viewers such as Spyglass products, the first dimension grows
   vertically downward and the second dimension grows from left to
   right.

   The RIS8 HDF files can be read back using import.
See also:
export_matlab , save , import .
   Error codes:
   1: First argument not a string
   2: Second argument not an integer matrix
   

3.3 export_matlab

[] = export_matlab(fn...)
 export_matlab("file") saves all variables in Tela
   workspace in "file". Any previous contents of "file"
   are overwritten. The data are written in MATLAB
   binary format. Hidden Tela variables are not saved.

   export_matlab("file","var1","var2"...) saves only the
   specified variables. Notice that you have to give the
   variable names as strings.

   The resulting MAT-file can be read using the
   MATLAB 'load' command.
   
   Limitations (bugs): It is not possible to export
   local variables. If you try, the global ones will
   be written, if they have numeric values. Use
   export_matlab2 to achieve this, and to have explicit
   control of variable naming.
   
See also:
export_matlab2 , save , load , import .
   Error codes:
   1: Too few arguments
   2: Argument not a string
   3: Write error on file
   

3.4 export_matlab2

[] = export_matlab2(fn...)
 export_matlab2("file", var1,"name1", var2,"name2"...)
   saves objects var1,var2... in MATLAB binary format in "file".
   The objects will be named "name1", "name2"... .
   Any previous contents of "file" are overwritten.
   workspace in "file". Any previous contents of "file"
   is overwritten.

   The resulting MAT-file can be read using the
   MATLAB 'load' command.
   
See also:
export_matlab , save , load , import .
   Error codes:
   1: First arg not a string
   2: Even number of arguments
   3: Write error on file
   4: The 'name' argument is not a string
   

3.5 import

[] = import(filename; appendix)
 import("file") tries to load the contents of "file" in
   Tela workspace. All files accepted by load are also accepted
   by import. In addition, import accepts more general HDF files
   (SDS and 8-bit raster image files) as well as MATLAB binary
   files (MAT-files).

   import("file","app") appends the string "app" to the name
   of every variable imported.

   Restrictions:
   1) Only MATLAB files created on a similar architecture can be
   correctly imported. If this rule is not followed, the imported
   data will be garbage!
   2) MATLAB4.0 and higher saves arrays with more than 10000 elements
   as various integer formats, if all elements are whole numbers.
   Tela cannot read these files. A workaround is to perturb one element
   in MATLAB before saving so that it is not exactly integer.
   3) If file is HDF-file, import first tries to read all SDSs.
   Only if none was found, it tries to read all RIS8 datasets.
   The variable names are taken from the HDF labels, if the labels
   have been set. If there are no labels, the variables are named
   "Dataset1", "Dataset2", ... and "Image1", "Image2",... for
   SDS and RIS8 imports, respectively.
   
   For filename conventions, see load.
See also:
load , save , import1 , export_matlab , export_RIS8 , import_PBM .

   (The difference between import and import1 is that import1 reads
    only one object and returns it, whereas import reads several
        objects and assigns them directly to workspace variables.)
   Error codes:
   1: First arg not string or char
   2: First arg is not an HDF file
   3: File not found
   4: Cannot import file
   5: Unused error message
   6: Cannot import this Matlab file (O(letter'Oh) != 0, (can even Matlab?))
   7: Cannot import this Matlab file (P != 0). Is your array size >10000 and all integer? Try perturbing it
   8: Cannot import this Matlab file (T != 0, 1). Is it a sparse matrix? Make it full
   10: Bad Matlab binary file, premature end of file
   11: Second argument not a string
   

3.6 import1

[x] = import1(filename; label)
 import1("file") reads one object from "file". The imported
   object is returned. "File" can be one of the following:

   1) HDF file, in which case the first Scientific Data Set (SDS)
      is imported. The form import1("file.hdf","label") reads SDS
      with label "label", which is not necessarily the first one.

   2) D-style ASCII file of the following format:

        (line 1)   D=Nt dim1 dim2 ... dimN
        (any number M of blank lines or lines starting with '#')
        (line M+2) data1 data2 ....

       where N is the rank of the dataset and t is an optionial
       type specification letter: t may be either 'r', 'i', or 'c'
       for real, integer and complex data, respectively. If t is
       missing, real data are asssumed.

   3) Plain ASCII file of nrows x ncols real numbers. If nrows or
      ncols is 1, it will be returned as a vector, otherwise as a
      matrix. Missing entries are treated as zeros. This format
      is similar to Matlab's load for ASCII, except that '#'
      comments are accepted in the beginning.
       
See also:
import , load , save .
   See import for a difference between import and import1.
   For filename conventions, see load.
   Error codes:
   -1: Input arg not a char or string
   -2: File not found
   -3: Unknown format in ASCII file
   -4: Unknown format in ASCII file
   -5: Too high rank ASCII data
   -6: Syntax error in ASCII file dimension specification
   -7: Syntax error when reading D-style ASCII data
   -8: Internal error
   -9: Cannot import file
   -10: Second arg not a string
   -11: Specified label not found
   -12: Premature end of file in D-style ASCII
   -13: Syntax error when reading plain ASCII data
   

3.7 import_PBM

[r;g,b] = import_PBM(fn)
 x = import_PBM("file.pbm") reads PBM format image file.
   x will become integer matrix.
   [r,g,b] = import_PBM("file.pbm") reads a color image
   and assigns the red, green and blue components to
   matrices r,g,b.
   All six PBM formats (P1-P6) are recognized. If a color
   image (P3 or P6) is loaded using only one output argument,
   the average of color components is computed and assigned
   to x. If a greyscale image is loaded using three output
   args, only the first (r) output arg will be filled,
   g and b are assigned the VOID value. You might use
   a code like

   [r,g,b] = import_PBM("file.pbm");
   if (isvoid(g)) {g=r; b=r};

   to continue processing in 24-bit mode.
See also:
import , export_PBM .
   Error codes:
   -1: First arg not a string
   -2: Could not open input file
   -3: Input file is not PBM file
   -4: Width or height not positive - improper PBM file
   -5: Color range not in 1..255
   -6: Two output args, give 1 or 3
   -7: Error when rading ASCII data
   -8: Pixel not 0 or 1 in 1-bit image
   -9: Pixel out of range 0..255
   -10: Could not read all binary data
   

3.8 load

[] = load(filename)
 load("file") loads the contents of "file"
   in Tela workspace.
   "file" must have been previously created using
   the 'save' command; it must be in a certain
   HDF format.

   Filename conventions:
   If the filename starts with "/", "./" or "..",
   it is considered absolute. Otherwise it is searched
   along TELAPATH. This applies to other file
   operations as well.
   
   The counterpart of load is save.
   To read more general HDF files and ASCII files,
   see import1.
   To load more general HDF files and MATLAB binary
   files, see import.
See also:
save , import , import1 , export_matlab .
   Error codes:
   1: Argument not string or char
   2: Argument is not an HDF file
   3: File not found
   

3.9 save

[] = save(fn...)
 save("file") saves all variables in Tela workspace
   in "file". Any previous contents of "file" is
   overwritten. The data are written as Scientific
   Data Sets in HDF format. Hidden variables are not saved.

   save("file","var1","var2"...) saves only the
   specified variables. Notice that you have to give
   the variable names as strings.

   Limitations (bugs): It is not possible to save
   local variables, since they are not bound to
   symbols. If you try, the global one, if any,
   will be saved.
   
See also:
load , export_matlab .
   Error codes:
   1: Too few arguments
   2: Argument not a string or char
   3: Unexpected HDF error
   

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter