The image I/O routines were developed to read and/or write image data. All application programs that do image processing will call a subset of these routines.
There are two ways to access an image in LAS. An image can be accessed sequentially or randomly. Each processing method is described in the next two sections: Random Image Processing and Sequential Image Processing.
A program can access the image I/O routines by linking in the following object library:
$LASLIB/las.a
A buffer for the random calls must either be allocated ahead of time by FORTRAN or C--or can be dynamically allocated in a C program by use of malloc routines. The allocated buffer must be large enough to hold at least one line of data (maximum number of samples times data type size).
If acc=IUPDATE, then c_ewrite() must be called to copy the buffer back to the file being updated before subsequent calls to c_eread(). Note that random image processing is faster than sequential image processing. In addition, there is no real limit to the number of bands that can be processed with random image processing.
A buffer for the sequential calls must either be allocated ahead of time by FORTRAN or C. The buffer for this type of allocation must be large enough to hold at least one line of data (maximum number of samples times data type size). If the routine is being written in C, then the buffer can be dynamically allocated using the c_ealloc() function.
Note that with sequential image processing there is a limit to the number of bands and/or image size before running out of buffer space.
Example using sequential imageio (written in 'C'):
/* Open input image(s) ----------------------*/ access = IREAD; opt[0] = 0; opt[1] = 0; for (band=0, image=0; image < nmrimg; image++) { status = c_eopens(&fdesc[image], hosin[image], bands[image], &sl, &ss, &nl, &ns, &offset1[band], &access, &odtype, &zero, &opt); band += nbands[image]; } /* Open output image --------------------*/ access = IWRITE; status = c_eopens(&fdesc[nmrimg], hosout, &totbnd, &one, &one, &nl, &ns, offset2, &access, &odtype, &zero, &opt); fdesc[nmrimg+1] = 0; /* Allocate I/O buffer 'C' only -------------------------------*/ thebuf = c_ealloc(fdesc, &bufsiz); /* Group images ---------------*/ c_egroup(fdesc, &gdesc, thebuf, &bufsiz); /* Main processing loop -----------------------*/ for (curlin=0; curlin < nl; curlin++) { status = c_estep(&gdesc); for (band=0; band < totbnd; band++) { /* DESIRED PROCESSING */ } } /* Final write --------------*/ status = c_estep(&gdesc); /* Close all image files in the group -------------------------------------*/ status = c_egclse(&gdesc); /* Free buffer --------------*/ free(thebuf);
This is a list of available Image I/O Routines: