Zooming within an Object Display
Enlarging a specific section of an image is known as zooming. How zooming is performed within IDL depends on the graphics system. In Direct Graphics, you can use the ZOOM procedure to zoom in on a specific section of an image. If you are working with RGB images, you can use the ZOOM_24 procedure.
In Object Graphics, the VIEWPLANE_RECT keyword is used to change the view object. Using this method, the entire image is still contained within the image object, while the view is changed to only show specific areas of the image object. See the following section for more information.
Zooming in on an Object Graphics Image Display
The following example imports a grayscale image from the convec.dat binary file. This grayscale image shows the convection of the Earth's mantle. The image contains byte data values and is 248 pixels by 248 pixels. The VIEWPLANE_RECT keyword to the view object is updated to zoom in on the lower left corner of the image.
Example Code
See zooming_object.pro in the examples/doc/objects subdirectory of the IDL installation directory for code that duplicates this example. Run this example procedure by entering zooming_object at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT zooming_object.pro.
- Determine the path to the
convec.datfile: - Initialize the image size parameter:
- Import the image from the file:
- Initialize the display objects:
- Initialize the image object:
- Add the image object to the model, which is added to the view, then display the view in the window:
- Initialize another window:
- Change the view to enlarge the lower left quarter of the image:
- Display the updated view in the new window:
- Clean up the object references. When working with objects always remember to clean up any object references with the OBJ_DESTROY routine. Since the view contains all the other objects, except for the window (which is destroyed by the user), you only need to use OBJ_DESTROY on the view object.
oWindow = OBJ_NEW('IDLgrWindow', RETAIN = 2, $
DIMENSIONS = imageSize, $
TITLE = 'A Grayscale Image')
oView = OBJ_NEW('IDLgrView', $
VIEWPLANE_RECT = [0., 0., imageSize])
oModel = OBJ_NEW('IDLgrModel')
oModel -> Add, oImage oView -> Add, oModel oWindow -> Draw, oViewThe following figure shows the resulting grayscale image display.
oView -> SetProperty, $ VIEWPLANE_RECT = [0., 0., imageSize/2]The view object still contains the entire image object, but the region displayed by the view (the viewplane rectangle) is reduced in size by half in both directions. Since the window object remains the same size, the view region is enlarged to fit it to the window.

