IPSCALE Function
Scales an image by shrinking or expanding it.
Usage
result = IPSCALE(image, xscale, yscale[, zscale])
Input Parameters
image—A 2D or 3D array of any data type except complex or string containing an image; image, row or pixel-interleaved images; or a volume.
xscale—A scalar value specifying the scaling factor for the image width.
yscale—A scalar value specifying the scaling factor for the image height.
zscale—(optional) A scalar value specifying the scaling factor for the image depth. (Valid only for volumes when using the pixel replication or depletion scaling method.)
Returned Value
result—An array of the same data type as image.
Keywords
Bilinear—If set, the bilinear interpolation scaling algorithm is used. (Valid for images only; not valid for volumes.)
Intleave—A scalar string indicating the type of interleaving of 3D image arrays. Valid strings and the corresponding interleaving methods are:
'pixel'—The input array arrangement is (
p,
x,
y) for
p pixel-interleaved images of
x-by-
y.
'row'—The 3D
image array arrangement is (
x,
p,
y) for
p row-interleaved images of
x-by-
y.
'image'—The 3D
image array arrangement is (
x,
y,
p) for
p image-interleaved images of
x-by-
y.
'volume'—The input image array is treated as a single entity.
Neighbor—If set, the nearest neighbor interpolation scaling algorithm is used. This is the default scaling algorithm for the IPSCALE function. (Valid for images only; not valid for volumes.)
Pixel—If set, the pixel replication or depletion scaling algorithm is used. In this method, the xscale, yscale, and zscale input parameters are converted to their nearest integer values.
Shrink—If set, shrinks the image by the xscale, yscale, and zscale scaling factors.
Discussion
The IPSCALE function shrinks or expands the number of elements in image. If the Pixel keyword is used for selecting pixel replication/depletion, image can only be scaled by integer factors. New values in the expanded image are formed from replicated pixels in the original input image. This method provides expansion of the pixel size and has the advantage of exactly replicating existing information in the image instead of forming new values through interpolation. When expanding the image, the result will always appear as individual blocks.
If nearest neighbor or bilinear interpolation are selected using the Neighbor or Bilinear keywords, respectively, the image can be scaled by floating-point factors. New values in the expanded image are interpolated from original values at intervals, and appear where there might not have been values before.
The nearest-neighbor interpolation method is the default interpolation method. This is not a linear method, because new values that are needed are merely set equal to the nearest existing value of image. Therefore, when increasing the image size, the result may appear as individual blocks.
Example 1
image = IMAGE_READ(!IP_Data + 'airplane.tif')
IMAGE_DISPLAY, image
; Expand the image using pixel replication.
image_scale = IPSCALE(image('pixels'), 3, 3, /Pixel)
TV, image_scale
; Shrink the original image using pixel depletion.
image_scale = IPSCALE(image('pixels'), 3, 3, /Pixel, /Shrink)
TV, image_scale
Example 2
; Read an image.
image = IMAGE_READ(!IP_Data + 'photo.tif')
; Display the image.
IMAGE_DISPLAY, image
; Expand the image.
image_scale = IPSCALE(image('pixels'), 1.5, 1.5)
; Display the expanded image.
TV, image_scale
See Also
In the PV‑WAVE Reference: CONGRID