Displaying Images with Direct Graphics
The following sections show examples of reading and displaying image data using IDL's Direct graphics system. Working with images using Direct graphics is not as convenient as using the iImage tool, but may be desirable if you are incorporating images into a larger widget-based application, or if you need to programatically create a large number of processed images.
For a brief description of the IDL Direct graphics routines for displaying and manipulating images, refer to the Direct graphics and Image Processing sections of the Functional List of IDL Routines topic, found in the Online Help.
Displaying Images
Before processing an image, we must import the image into IDL.
For this example, we will continue to use the image.tif file.
- Read the file by entering the following code at the IDL command line:
- Since we are using Direct graphics, tell IDL to use a maximum of 256 colors and load a simple grayscale color map.
- Display the image with the TV procedure:
- Display the color-scaled image with the TVSCL procedure:

- Dismiss the graphics windows by clicking in the window's close icon or by entering WDELETE at the command line:
MYIMAGE=READ_TIFF(FILEPATH('image.tif', $
SUBDIRECTORY=['examples', 'data']))
Using the IDL command line, you can view an image with two different routines. The TV procedure writes an array to the display in its original form. The TVSCL procedure displays the image and scales the color values so that all of the table colors are used (up to 256 colors).
DEVICE, RETAIN=2, DECOMPOSED=0
LOADCT, 0
Resizing Images
The REBIN function makes it easy to resize a vector or array to new dimensions. The supplied dimensions must be proportionate (that is, integral multiples or factors) to the dimensions of the original image. Since the original image array is 768 by 512, we need to determine the correct dimensions of the resized image. To resize the image to half the original size, simply take half of the array's original dimensions.
- Create a new image with new dimensions using the REBIN function:

- Display the image:
NEWIMAGE=REBIN(MYIMAGE,384,256)
