Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
pmi432 / LR07 / 2read / image processing toolbox guide.pdf
Скачиваний:
166
Добавлен:
18.03.2015
Размер:
18.08 Mб
Скачать

6 Spatial Transformations

Resizing an Image

In this section...

“Overview” on page 6-2

“Specifying the Interpolation Method” on page 6-3 “Preventing Aliasing by Using Filters” on page 6-4

Overview

To resize an image, use the imresize function. When you resize an image, you specify the image to be resized and 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 an image by 1.25 times.

I = imread('circuit.tif'); J = imresize(I,1.25); imshow(I)

figure, imshow(J)

6-2

Resizing an Image

You can specify the size of the output image by passing a vector that contains the number of rows and columns in the output image. If the specified size does not produce the same aspect ratio as the input image, the output image will be distorted. If you specify one of the elements in the vector as NaN, imresize calculates the value for that dimension to preserve the aspect ratio of the image.

This example creates an output image with 100 rows and 150 columns.

I = imread('circuit.tif'); J = imresize(I,[100 150]); imshow(I)

figure, imshow(J)

To perform the resizing required for multiresolution processing, use the impyramid function.

Specifying the Interpolation Method

Interpolation is the process used to estimate an image value at a location in between image pixels. When imresize enlarges an image, the output image contains more pixels than the original image. The imresize function uses interpolation to determine the values for the additional pixels.

Interpolation methods determine the value for an interpolated pixel by finding the point in the input image that corresponds to a pixel in the output image and then calculating the value of the output pixel by computing a weighted average of some set of pixels in the vicinity of the point. The weightings are based on the distance each pixel is from the point.

By default, imresize uses bicubic interpolation to determine the values of pixels in the output image, but you can specify other interpolation methods and interpolation kernels. In the following example, imresize uses the bilinear interpolation method. See the imresize reference page for a complete list of interpolation methods and interpolation kernels available. You can also specify your own custom interpolation kernel.

Y = imresize(X,[100 150],'bilinear')

6-3

6 Spatial Transformations

Preventing Aliasing by Using Filters

When you reduce the size of an image, you lose some of the original pixels because there are fewer pixels in the output image and this can cause aliasing. Aliasing that occurs as a result of size reduction normally appears as “stair-step“ patterns (especially in high-contrast images), or as moiré (ripple-effect) patterns in the output image.

By default, imresize uses antialiasing to limit the impact of aliasing on the output image for all interpolation types except nearest neighbor. To turn off antialiasing, specify the 'Antialiasing' parameter and set the value to false.

Note Even with antialiasing, resizing an image can introduce artifacts, because information is always lost when you reduce the size of an image.

For more information, see the reference page for imresize.

6-4

Соседние файлы в папке 2read