Gaussian Pyramid

Perform Gaussian pyramid decomposition

Library

Transforms

visiontransforms

  • Gaussian Pyramid block

Description

The Gaussian Pyramid block computes Gaussian pyramid reduction or expansion to resize an image. The image reduction process involves lowpass filtering and downsampling the image pixels. The image expansion process involves upsampling the image pixels and lowpass filtering. You can also use this block to build a Laplacian pyramid. For more information, see Examples.

Note

This block supports intensity and color images on its ports.

PortOutputSupported Data TypesComplex Values Supported

Input

In Reduce mode, the input can be an M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes.

In Expand mode, the input can be a scalar, vector, or M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes.

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, 32-bit signed integer

  • 8-, 16-, 32-bit unsigned integer

No

Output

In Reduce mode, the output can be a scalar, vector, or matrix that represents one level of a Gaussian pyramid.

In Expand mode, the output can be a matrix that represents one level of a Gaussian pyramid.

Same as Input port

No

Use the Operation parameter to specify whether to reduce or expand the input image. If you select Reduce, the block applies a lowpass filter and then downsamples the input image. If you select Expand, the block upsamples and then applies a lowpass filter to the input image.

Use the Pyramid level parameter to specify the number of times the block upsamples or downsamples each dimension of the image by a factor of 2. For example, suppose you have a 4-by-4 input image. You set the Operation parameter to Reduce and the Pyramid level to 1. The block filters and downsamples the image and outputs a 2-by-2 pixel output image. If you have an M-by-N input image and you set the Operation parameter to Reduce, you can calculate the dimensions of the output image using the following equation:

ceil(M2)byceil(N2)

You must repeat this calculation for each successive pyramid level. If you have an M-by-N input image and you set the Operation parameter to Expand, you can calculate the dimensions of the output image using the following equation:

[(M1)2l+1]by[(N1)2l+1]

In the previous equation, l is the scalar value from 1 to inf that you enter for the Pyramid level parameter.

Use the Coefficient source parameter to specify the coefficients of the lowpass filter. If you select Default separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2], use the a parameter to define the coefficients in the vector of separable filter coefficients. If you select Specify via dialog, use the Coefficient for separable filter parameter to enter a vector of separable filter coefficients.

Examples

The following example model shows how to construct a Laplacian pyramid:

  1. Open this model by typing

    at the MATLAB® command prompt.

  2. Run the model to see the following results.

You can construct a Laplacian pyramid if the dimensions of the input image, R-by-C, satisfy R=MR2N+1 and C=Mc2N+1, where MR, MC, and N are integers. In this example, you have an input matrix that is 256-by-256. If you set MR and MC equal to 63 and N equal to 2, you find that the input image needs to be 253-by-253. So you use a Submatrix block to crop the dimensions of the input image to 253-by-253.

Fixed-Point Data Types

The following diagram shows the data types used in the Gaussian Pyramid block for fixed-point signals:

You can set the coefficients table, product output, accumulator, and output data types in the block mask.

Parameters

Operation

Specify whether you want to reduce or expand the input image.

Pyramid level

Specify the number of times the block upsamples or downsamples each dimension of the image by a factor of 2.

Coefficient source

Determine how to specify the coefficients of the lowpass filter. Your choices are Default separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2] or Specify via dialog.

a

Enter a scalar value that defines the coefficients in the default separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2]. This parameter is visible if, for the Coefficient source parameter, you select Default separable filter [1/4-a/2 1/4 a 1/4 1/4-a/2].

Coefficients for separable filter

Enter a vector of separable filter coefficients. This parameter is visible if, for the Coefficient source parameter, you select Specify via dialog.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Coefficients

Choose how to specify the word length and the fraction length of the coefficients:

  • When you select Same word length as input, the word length of the coefficients match that of the input to the block. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

  • When you select Specify word length, you can enter the word length of the coefficients, in bits. The block automatically sets the fraction length to give you the best precision.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the coefficients, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the coefficients. The bias of all signals in the Computer Vision Toolbox™ blocks is 0.

Product output

As shown in the previous figure, the output of the multiplier is placed into the product output data type and scaling. Use this parameter to specify how to designate the product output word and fraction lengths.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. The bias of all signals in the Computer Vision Toolbox blocks is 0.

Accumulator

As shown in the previous figure, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how to designate the accumulator word and fraction lengths.

  • When you select Same as product output, these characteristics match those of the product output.

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. The bias of all signals in the Computer Vision Toolbox blocks is 0.

Output

Choose how to specify the word length and fraction length of the output of the block:

  • When you select Same as input, these characteristics match those of the input to the block.

  • When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.

  • When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. The bias of all signals in the Computer Vision Toolbox blocks is 0.

Lock data type settings against change by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask. For more information, see fxptdlg (Fixed-Point Designer), a reference page on the Fixed-Point Tool in the Simulink® documentation.

See Also

Resize

Computer Vision Toolbox software

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Introduced before R2006a