Image Processing Toolbox    

Image Resizing

To change the size of an image, use the imresize function. Using imresize, you can:

Specifying the Size of the Output Image

Using imresize, you can specify the size of the output image in two ways

Using the Magnification Factor

To enlarge an image, specify a magnification factor greater than 1. To reduce an image, specify a magnification factor between 0 and 1. For example, the command below increases the size of the image, I, by 1.25 times.

Specifying the Size of the Output Image

You can specify the size of the output image by passing a vector that contains the number of row and columns in the output image. The command below creates an output image, Y, with 100 rows and 150 columns.

Specifying the Interpolation Method

By default, imresize uses nearest neighbor interpolation to determine the values of pixels in the output image but you can specify other interpolation methods. This table lists the supported interpolation methods. See Interpolation for more information about these methods.

Argument Value
Interpolation Method
'nearest'
Nearest neighbor (the default)
'bilinear'
Bilinear interpolation
'bicubic'
Bicubic interpolation

In this example, imresize uses the bilinear interpolation method.

Using Filters to Prevent Aliasing

Reducing the size of an image can introduce artifacts, such as aliasing, in the output image because information is always lost when you reduce the size of an image. Aliasing appears as ripple patterns (called Moire patterns) in the output image.

When you reduce the size of the image using either bilinear or bicubic interpolation, imresize automatically applies a low-pass filter to the image before interpolation, to limit the impact of aliasing on the output image. You can specify the size of this filter or specify a different filter.

The imresize function does not apply a low-pass filter if nearest neighbor interpolation is used. Nearest neighbor interpolation is primarily used for indexed images, and low-pass filtering is not appropriate for these images.

You can also specify a filter of your own creation. For more information about specifying a filter, see the reference page for imresize.


  Image Types Image Rotation