Previous Getting Started with IDL: Images Next

Resizing an Image

The REBIN function in IDL 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 our original image array here is 768 by 512, we'll need to decide the correct dimensions of our new resized image. If we want to resize the image to half the original size then simply take half of the array's original dimensions.

  1. Create a new image with new dimensions using the REBIN function:
  2. NEWIMAGE=REBIN(MYIMAGE,384,256)  
    

     

  3. Now display the image:
  4. TV, NEWIMAGE  
    

     

    Figure 6-4: MYIMAGE resized to one half the original array size

    Figure 6-4: MYIMAGE resized to one half the original array size

     

  5. Enter WDELETE at the Command Line to dismiss the graphics window.
  6. WDELETE  
      
    


Note
The CONGRID function also shrinks or expands the size of an array. CONGRID differs from REBIN in that where REBIN requires that the new array size must be an integer multiple of the original size, CONGRID will resize an array to any arbitrary size. For more information, see CONGRID.

  IDL Online Help (March 06, 2007)