Routines (alphabetical) > Routines: E > EXPAND

# EXPAND

The EXPAND procedure shrinks or expands a two-dimensional array, using bilinear interpolation. It is similar to the CONGRID and REBIN routines.

This routine is written in the IDL language. Its source code can be found in the file `expand.pro` in the `lib` subdirectory of the IDL distribution.

## Example

Copy and paste the following example code to see EXPAND in action on a JPG image.

; Locate and read in an image file.

file = FILEPATH('rbcells.jpg', $

SUBDIR=['examples', 'data'])

READ_JPEG, file, img

; Use EXPAND to enlarge the original picture

; and save it as img2.

EXPAND, img, 864, 778, img2

; Display the original and expanded versions

; of the image in the same window.

a1 = IMAGE(img, LAYOUT=[2,1,1])

a2 = IMAGE(img2, LAYOUT=[2,1,2], /CURRENT)

; Change the dimensions again, saving as

; img3 and img4, then view them.

EXPAND, img, 432, 1200, img3

EXPAND, img, 1500, 389, img4

b1 = IMAGE(img3)

b2 = IMAGE(img4)

## Syntax

EXPAND, A, Nx, Ny, Result [, FILLVAL=value] [, MAXVAL=value]

## Arguments

### A

A two-dimensional array to be magnified.

### Nx

Desired size of the X dimension, in pixels.

### Ny

Desired size of the Y dimension, in pixels.

### Result

A named variable that will contain the magnified array.

## Keywords

### FILLVAL

Set this keyword equal to the value to use when elements larger than MAXVAL are encountered. The default is -1.

### MAXVAL

Set this keyword equal to the largest desired value. Elements greater than this value are set equal to the value of the FILLVAL keyword.

## Version History

Pre 4.0 | Introduced

## See Also

CONGRID, REBIN