|
Image Processing : Transforming Image Geometry |
|
Image resizing, or scaling, supports further image analysis by either shrinking or expanding an image. Both the CONGRID and the REBIN functions resize one-, two- or three-dimensional arrays. The CONGRID function resizes an image array by any arbitrary amount. The REBIN function requires that the output dimensions of the new array be an integer multiple of the original image's dimensions.
When magnifying an image, new values are interpolated from the source image to produce additional pixels in the output image.When shrinking an image, pixels are resampled to produce a lower number of pixels in the output image. The default interpolation method varies according to whether you are magnifying or shrinking the image.
When magnifying an image:
When shrinking an image:
The following example uses CONGRID since it offers more flexibility. However, if you wish to resize an array proportionally, REBIN returns results more quickly. For an example of magnifying an image using the CONGRID function, complete the following steps.
| Example Code See magnifyimage.pro in the examples/doc/image subdirectory of the IDL installation directory for code that duplicates this example. |
file = FILEPATH('convec.dat', $
SUBDIRECTORY = ['examples', 'data'])
image = READ_BINARY(file, DATA_DIMS = [248, 248])
LOADCT, 28 DEVICE, DECOMPOSED = 0, RETAIN = 2
WINDOW, 0, XSIZE = 248, YSIZE = 248 TV, image
magnifiedImg = CONGRID(image, 600, 600, /INTERP)
WINDOW, 1, XSIZE = 600, YSIZE = 600 TV, magnifiedImg
The following figure displays the original image (left) and the magnified view of the image (right).
IDL Online Help (March 06, 2007)