Table of Contents

Name

xyopen, xyclose, xyread, xywrite, xysetpl - line based image I/O

Synopsis


#include <stdinc.h>#include <xyio.h>image *xyopen(handle, name, mode, naxis,
axes)int handle, naxis, axes[naxis];string name, mode;
void xyclose(handle)int
handle;
void xyclose(handle)int handle;
void xyread(handle, index, array)int
handle, index;real array[];
void xywrite(handle, index, array)int handle,
index;real array[];
void xysetpl(handle, naxis, nsize)int handle, naxis,
nsize[];
Descriptionxyopen opens an image file. For an input file, it determines
the size of each axis. For a output  file, it writes out this info. name
is the name of the file to be opened, mode the access mode. It can be "r"
or "w" to open the file in read or write mode, although the strings "old"
and "new" are also supported. naxis is the maximum number of axes that the
calling program can handle. For an input file, if the data file has fewer
than naxis axes, the higher dimensions are treated as having only one element.
If the data file has more than naxis axes, and the higher dimensions are
more than 1 element deep, xyopen will call error and die. axes is an input
array when writing and output for reading. It gives the number of elements
along each axis. xyopen returns a handle of the file, which is used in subsequent
operations.  xyclose closes a previously opened image file. 
xyread reads
a single row from an image. This accesses the plane given by the last call
to xysetpl(see below). index is the row number to read. This varies from
0 to axes[1]-1. array is the read row.  axes[0] elements are returned. xywrite
is the inverse of xyread. 
xysetpl sets up which (hyper) plane of a cube
is to be  accessed.  By default, if not called, the first plane will be
accessed. naxis is the size of the modified nsize array. nsize gives the
indices, along the 3rd, 4th, 5th, etc dimensions, of the plane that is
to be accessed. nsize[0] corresponds to the index along the 3rd dimension,
and can take values from 0 to axes[2]-1 etc. 
ExampleThe following example
shows how to sum all the pixel values in an an image: 
    real *data, sum=0;
    int  i, j, k, h, axes[3];
    xyopen(&h,"ccd","r",3,axes);
    data = (real *) allocate(axes[0] * sizeof(real);
    for(k=0; k<axes[2]; k++) {
        xysetpl(h,1,&k);
        for(j=0; j<axes[1]; j++) {
            xyread(h,j,data);
            for(i=0; i<axes[0]; i++) sum += data[i];
        }
    }
    printf("Sum = %g0,sum);

Limitations

Although the interface specification is the same as those of MIRIAD, images in NEMO are implemented only as 2- or 3D dimensional. Also, note that index and nsize are 0 based in NEMO, not 1 based as they are in MIRIAD.

See Also

image(3NEMO)

Author

Peter Teuben

Files


~/src/image/io      xyio.c

Update History


15-may-92    V1.0 Created           PJT
7-jan-99    V1.1 Fixed documentation bug    PJT


Table of Contents