Image Scaling

Introduction

Translation only (1:1)

Image reduction (many:1)

Image enlargement (1:many)

C++ Examples

Image reduction through pixel averaging

The images below have been reduced in size by the indicated factors.

full size2 x 2 3 x 34 x 4

source code: reduce.cpp

Image reduction through sampling

Sampling reduces the size of an image by extracting pixels on a periodic sample grid, every 3th pixel in every 3th row, for example.

Sampling produces a different reduced image than averaging, especially in patterned regions. Compare the hat and hair in the examples below.

averagedsampled

source code: subsamp.cpp

Image enlargement through pixel replication

The images above have been restored to full size by pixel replication. Each image is labeled by its pixel block size

1 x 12 x 2 3 x 34 x 4

source code: dupl.cpp

Image enlargement through bilinear interpolation

The original image below was reduced in size by 4 x 4 and then restored to full size, first by bilinear interpolation then by pixel replication.

originalbilinear pixel replication

source code: resize.cpp

Matlab imresize function

B = IMRESIZE(A,M,'method') returns an image matrix that is M times larger (or smaller) than the image A. The image B is computed by interpolating using the method in the string 'method'. Possible methods are

B = IMRESIZE(A,M) uses 'nearest' as the default interpolation scheme.

reference: imresize.m

Matlab example

>> img = imread('pens.tif');
>> whos
  Name      Size         Bytes  Class

  img     480x512x3     737280  uint8 array

>> z1 = imresize(img,1/3.0,'bicubic');
>> imshow(z1);
>> tiffwrite(z1,'pens1.tif');

>> z3 = imcrop;
>> imshow(z3);
>> tiffwrite(z3,'pens3.tif');

>> z4 = imresize(z3,3.25,'bilinear');
>> imshow(z4);
>> tiffwrite(z4,'pens4.tif');


Maintained by John Loomis, last updated July 9, 1997