Shrink or expand the size of an array an arbitrary amount using interpolation
FREBIN is an alternative to CONGRID or REBIN. Like CONGRID it
allows expansion or contraction by an arbitrary amount. ( REBIN requires
integral factors of the original image size.) Like REBIN it conserves
flux by ensuring that each input pixel is equally represented in the output
result = FREBIN( image, nsout, nlout, [ /TOTAL] )
image - input image, 1-d or 2-d numeric array
nsout - number of samples in the output image, numeric scalar
nlout - number of lines in the output image, numeric scalar
If not supplied, then set equal to 1
Optional Keyword Inputs
/total - if set, the output pixels will be the sum of pixels within
the appropriate box of the input image. Otherwise they will
be the average. Use of the /TOTAL keyword conserves surface flux.
The resized image is returned as the function result. If the input
image is of type DOUBLE or FLOAT then the resized image is of the same
type. If the input image is BYTE, INTEGER or LONG then the output
image is usually of type FLOAT. The one exception is expansion by
integral amount (pixel duplication), when the output image is the same
type as the input image.
Suppose one has an 800 x 800 image array, im, that must be expanded to
a size 850 x 900 while conserving surface flux:
IDL> im1 = frebin(im,850,900,/total)
im1 will be a 850 x 900 array, and total(im1) = total(im)
If the input image sizes are a multiple of the output image sizes
then FREBIN is equivalent to the IDL REBIN function for compression,
and simple pixel duplication on expansion.
If the number of output pixels are not integers, the output image
size will be truncated to an integer. The platescale, however, will
reflect the non-integer number of pixels. For example, if you want to
bin a 100 x 100 integer image such that each output pixel is 3.1
input pixels in each direction use:
n = 100/3.1 ; 32.2581
image_out = frebin(image,n,n)
The output image will be 32 x 32 and a small portion at the trailing
edges of the input image will be ignored.
Adapted from May 1998 STIS version, written D. Lindler, ACC
Added /NOZERO, use INTERPOLATE instead of CONGRID, June 98 W. Landsman
Fixed for nsout non-integral but a multiple of image size Aug 98 D.Lindler
DJL, Oct 20, 1998, Modified to work for floating point image sizes when
expanding the image.
Improve speed by addressing arrays in memory order W.Landsman Dec/Jan 2001
This page has no user notes yet. Be the first one!