Accelerating the pace of engineering and science

# impyramid

Image pyramid reduction and expansion

## Syntax

B = impyramid(A, direction)

## Description

B = impyramid(A, direction) computes a Gaussian pyramid reduction or expansion of A by one level. direction can be 'reduce' or 'expand'.

If A is m-by-n and direction is 'reduce', then the size of B is ceil(M/2)-by-ceil(N/2). If direction is 'expand', then the size of B is (2*M-1)-by-(2*N-1).

Reduction and expansion take place only in the first two dimensions. For example, if A is 100-by-100-by-3 and direction is 'reduce', then B is 50-by-50-by-3.

Note that impyramid uses the kernel specified on page 533 of the Burt and Adelson paper cited below:

$w=\left[\frac{1}{4}-\frac{a}{2},\frac{1}{4},a,\frac{1}{4},\frac{1}{4}-\frac{a}{2}\right]$, where .

The parameter a is chosen to be 0.375 so that the equivalent weighting function is close to a Gaussian shape and the weights can be readily applied using fixed-point arithmetic.

## Class support

A can be any numeric class except uint64 or int64, or it can be logical. The class of B is the same as the class of A.

## Examples

Compute a four-level multiresolution pyramid of the cameraman image.

```I0 = imread('cameraman.tif');
I1 = impyramid(I0, 'reduce');
I2 = impyramid(I1, 'reduce');
I3 = impyramid(I2, 'reduce');

imshow(I0)
figure, imshow(I1)
figure, imshow(I2)
figure, imshow(I3)```

## References

[1] Burt and Adelson, "The Laplacian Pyramid as a Compact Image Code," IEEE Transactions on Communications, vol. COM-31, no. 4, April 1983, pp. 532-540.

[2] Burt, "Fast Filter Transforms for Image Processing," Computer Graphics and Image Processing, vol. 16, 1981, pp. 20-51