Appendix B

Because a routine to load a LumiscanTM image into IDL would be a useful routine in other programs, it was written as a separate procedure. The comments contained in the header can be extracted using the DOC_LIBRARY routine to provide documentation on the how to use the routine consistent with the IDL library routines.

<read_lum.pro>

PRO READ_LUM, cFile, iImage
;+
; NAME:
;       READ_LUM
;
; PURPOSE:
;       Read the contents of a LUMISCAN(tm) format image file and return
;       the image in the form of an IDL variable.
;
; CATEGORY:
;       Input/Output.
;
; CALLING SEQUENCE:
;       READ_LUMI, cFile, image
;
; INPUTS:
;       file:   Scalar string giving the name of the LUMISCAN file.
;
; OUTPUTS:
;       image:  The 2D byte array to contain the image.
;
; SIDE EFFECTS:
;       None.
;
; EXAMPLE:
;       To open and read the LUMISCAN image file named "foo.img" in the
;       current directory, store the image in the variable IMAGE1 enter:
;
;               READ_LUM, "foo.img", image1
;
; MODIFICATION HISTORY:
;       Written May, 1996, Jonathan Buzzard.
;-

	ON_IOERROR, BAD_IO
	ON_ERROR, 1

	OPENR, unit, cFile, /GET_LUN, /BLOCK

	iWidth = 0
	iHeight = 0
	POINT_LUN, unit, 806

; test for the machines endian'es and load with byte swapping if big endian
; note: it should return 1 for a little endian machine and 0 for a big endian

	IF (BYTE(1, 0, 2))(0) EQ 1B THEN BEGIN

		READU, unit, iWidth
		READU, unit, iHeight
		POINT_LUN, unit, 2048
		iImage = INTARR(iWidth, iHeight)
		READU, unit, iImage

	ENDIF ELSE BEGIN

		READU, unit, width
		READU, unit, height
		BYTEORDER, iWidth, iHeight
		POINT_LUN, unit, 2048
		iImage = INTARR(iWidth, iHeight)
		READU, unit, iImage
		BYTEORDER, iImage

	ENDELSE

	FREE_LUN, unit
	RETURN

BAD_IO:	MESSAGE, 'Error occured accessing Lumiscan file : ' + cFile

END


PREVIOUS   CONTENTS   NEXT