The following commands will enable you to read and display an image. It is assumed that the image is in the "gif" format. Similar techniques are available for other common image formats.
You can either type the following commands (shown in red) into the IDL command line or store them in a script file and run them with the @ command. You must substitute the full path to your image file in the READ_GIF command.
The first step is to read an image file and store the results in an array. Here we will read a file named sailboat.gif and store it in an array A.
; Read the sailboat image and store it in an array
named A.
READ_GIF,'/abc1234/idl/images/sailboat.gif',A
If the command executed as expected then there is an array A in your IDL environment. If the command did not execute properly then you need to correct the name of the file path so it can find the image.
Although the image has been loaded into an array, you do not know what
size it is. You can
find the size and type of A by using HELP,A
Calculate the number of bytes that are needed to store A in a file. Compare your answer with the size of the sailboat.gif file. Can you speculate on why the answers might not be exactly the same?
We will now display the image. To do this we first create a window that
is the same size as the array.
; Create a window the same size as the array
to display the image.
WINDOW,1,XSIZE=256,YSIZE=384,TITLE='SAILBOATS'
Now display the image in the window. To do this use the TV command.
; Display the array as an image
TV,A
Read about the TV and TVSCL procedures in IDL Online Help.