The REBIN function resizes a vector or array to dimensions given by the parameters D i . The supplied dimensions must be integral multiples or factors of the original dimension. The expansion or compression of each dimension is independent of the others, so that each dimension can be expanded or compressed by a different value.
If the dimensions of the desired result are not integer multiples of the original dimensions, use the CONGRID function.
Assume the original vector X has n elements and the result is to have m elements.
Let f = n/m , the ratio of the size of the original vector, X to the size of the result. 1/ f must be an integer if n < m (expansion). f must be an integer if compressing, ( n > m ). The various resizing options can be described as:
The linear interpolation function, F ( X , p ) that interpolates X at location p , is defined as:
When expanding an array, REBIN interpolates , it never extrapolates . Each of the n -1 intervals in the n -element input array produces m/n interpolates in the m -element output array. The last m/n points of the result are obtained by duplicating element n -1 of the input array because their interpolates would lie outside the input array.
A = [0, 10, 20, 30] ; A four point vector.
B = REBIN(A, 12) ; Expand by a factor of 3.
0 3 6 10 13 16 20 23 26 30 30 30
Note that the last element is repeated three times. If this effect is undesirable, use the INTERPOLATE function. For example, to produce 12 equally spaced interpolates from the interval 0 to 30:
B = INTERPOLATE(A, 3./11. * FINDGEN(12))
Create and display a simple image by entering:
D = SIN(DIST(50)/4) & TVSCL, D
Resize the image to be 5 times its original size and display the result by entering: