regrid(x, xgrid, ygrid, sx, sy)
Maps a 2D image onto a specified grid and returns the mapped image. Uses nearest-neighbor interpolation.
the two-dimensional image to be remapped.
the remapping cell grid: the coordinates of the corners of the remapped image in the coordinate system of the old image. Must be 2D arrays.
The interpolation grid dimensions within each grid cell. Must be scalars.
ngy are the dimensions of the grid, then the
dimensions of the resulting image are equal to
Areas in the remapped image for which there is no equivalent data in the original image are set to zero.
Identity mapping, i.e., mappings that return an exact copy of image
x, are given by
ny = dimen(x,1)/ngy,
indgen(fltarr(ngx,ngy),0)*dimen(x,0)/(ngx - 1) and
indgen(cx,1)*dimen(x,1)/(ngy - 1), with
integers greater than 1. Some examples of linear remappings, with
cy as above for
ngy = 2, are:
regrid(x,cx,cy,nx/2,ny/2) makes the image half the size.
regrid(x,cx/2,cy/2,nx/2,ny/2) selects the lower half of the image,
regrid(x,cx+100,cy,nx,ny) shifts the image over 100 pixels to the
left (in the direction of negative x).
rotates the image counterclockwise over angle
phi, i.e., the
positive x axis rotates over angle
phi in the direction of the
positive y axis.
If you need to combine some of these operations, then perform them on
ny, and only then apply them
to the image. For example, to rotate the image over 1 radian around
(100,200) and expand it by a factor of 3, you could do
cx2 = cx - 100 ; translate cy2 = cy - 200 cx3 = cx2*cos(1)+cy2*sin(1) ; rotate cy3 = -cx2*sin(1)+cy2*cos(1) cx4 = cx3 + 100 ; translate back cy4 = cx4 + 200 y = regrid(x,cx,cy,nx*3,ny*3)
See also: compress, expand, regrid3, regrid3ns
|• regrid Details:|