IDL congrid: resize the image

Examples


The following example reads some data from a file, displays it at its original size, then uses CONGRID to resize the array and display the magnified version.

  ; Select the file.
  file = FILEPATH('convec.dat', SUBDIRECTORY = ['examples', 'data'])
   
  ; Use READ_BINARY to read in the data,
  ; specifying known data dimensions.
  image = READ_BINARY(file, DATA_DIMS = [248, 248])
   
  ; Use the IMAGE function to display the original image with a color table.
  im = IMAGE(image, RGB_TABLE = 28)
   
  ; Use the CONGRID function to increase the image array
  ; size to 600 by 600 pixels and force bilinear interpolation.
  magnifiedIm = CONGRID(image, 600, 600, /INTERP)
   
  ; Display the magnified image in a new window
  ; with a color table.
  im2 = IMAGE(magnifiedIm, RGB_TABLE = 28)

Syntax


Result = CONGRID( ArrayXYZ [, /CENTER] [, CUBIC=value{-1 to 0}] [, /INTERP] [, /MINUS_ONE] )

Return Value


Returns the resized array. The returned array has the same number of dimensions as the original array and is of the same data type.

Arguments


Array

A 1-, 2-, or 3-dimensional array to resize. Array can be any type except string or structure.

X

The new X-dimension of the resized array. X must be an integer or a long integer, and must be greater than or equal to 2.

Y

The new Y-dimension of the resized array. If the original array has only 1 dimension, Y is ignored. If the original array has 2 or 3 dimensions Y MUST be present.

Z

The new Z-dimension of the resized array. If the original array has only 1 or 2 dimensions, Z is ignored. If the original array has 3 dimensions then Z MUST be present.

Keywords


CENTER

Set this keyword to shift the interpolation so that points in the input and output arrays are assumed to lie at the midpoint of their coordinates rather than at their lower-left corner.

CUBIC

Set this keyword to a value between -1 and 0 to use the cubic convolution interpolation method with the specified value as the interpolation parameter. Setting this keyword equal to a value greater than zero specifies a value of -1 for the interpolation parameter. Park and Schowengerdt (see reference below) suggest that a value of -0.5 significantly improves the reconstruction properties of this algorithm. This keyword has no effect when used with 3-dimensional arrays.

Cubic convolution is an interpolation method that closely approximates the theoretically optimum sinc interpolation function using cubic polynomials. According to sampling theory, details of which are beyond the scope of this document, if the original signal, f, is a band-limited signal, with no frequency component larger than ω0, and f is sampled with spacing less than or equal to 1/(2ω0), then f can be reconstructed by convolving with a sinc function: sinc(x) = sin(πx) / (πx).

In the one-dimensional case, four neighboring points are used, while in the two-dimensional case 16 points are used. Note that cubic convolution interpolation is significantly slower than bilinear interpolation.

For further details see:

Rifman, S.S. and McKinnon, D.M., “Evaluation of Digital Correction Techniques for ERTS Images; Final Report”, Report 20634-6003-TU-00, TRW Systems, Redondo Beach, CA, July 1974.

S. Park and R. Schowengerdt, 1983 “Image Reconstruction by Parametric Cubic Convolution”, Computer Vision, Graphics & Image Processing 23, 256.

INTERP

Set this keyword to force CONGRID to use linear interpolation when resizing a 1- or 2-dimensional array. CONGRID automatically uses linear interpolation if the input array is 3-dimensional. When the input array is 1- or 2-dimensional, the default is to employ nearest-neighbor sampling.

MINUS_ONE

Set this keyword to prevent CONGRID from extrapolating one row or column beyond the bounds of the input array. For example, if the input array has the dimensions (i, j) and the output array has the dimensions (x, y), then by default the array is resampled by a factor of (i/x) in the X direction and (j/y) in the Y direction. If MINUS_ONE is set, the array will be resampled by the factors (i-1)/(x-1) and (j-1)/(y-1).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值