|
Using IDL: Importing and Writing Data into Variables |
|
To import an image file into IDL using a macro, complete the following steps:
IDL_DIR/examples/data/muscle.jpg file where IDL_DIR is the installation directory for IDL. See Using the Select Image File Dialog Interface under DIALOG_READ_IMAGE for additional information if desired.
The muscle.jpg image data has been opened into a structure variable named MUSCLE_IMAGE. The Import Image macro opens and stores image data in a structure variable named filename_IMAGE where filename is the name of the file you opened without the extension.
| Note IDL variables must begin with a letter, and may contain only letters, digits, the underscore character, or the dollar sign. If the first character of filename is not a letter, the prefix "var" is added to the variable name. Any spaces within filename are converted to underscores. Any other illegal characters within filename are removed. |
The MUSCLE_IMAGE structure contains the following fields:
The structure can be viewed in the Variable Watch Window.
![]() |
You can specify which part of the structure variable you want to access by using the following syntax:
variable_name.element_name[.element_name]
For example, if you want to view the image, enter the following:
IIMAGE, MUSCLE_IMAGE.IMAGE
If you want to know the file type, enter the following:
PRINT, MUSCLE_IMAGE.QUERY.TYPE
IDL prints:
JPEG
IDL Online Help (March 06, 2007)