Main Content

Image Pad

Pad image by adding rows, columns, or both

  • Image Pad block

Libraries:
Computer Vision Toolbox / Utilities

Description

The Image Pad block expands the dimensions of an image by padding its rows, columns, or both.

Examples

Ports

Input

expand all

Input image, specified as an M-by-N matrix or an M-by-N-by-P array, where P is the number of color planes in the input image.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point

Pad value, specified as a scalar. The block uses this value for each element of the rows or columns added to the input image.

Dependencies

To enable this port, set the Method parameter to Constant and the Pad value source parameter to Input port.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Output

expand all

Output image, returned as a padded matrix or an array. The dimensions of the output image are specified by the Specify parameter.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point

Parameters

expand all

Pad the image using one of these methods:

Specify the padding source as Specify via dialog or Input port.

  • Specify via dialog — Specify a pad value using the Pad Value parameter.

  • Input port — Specify a pad value using the PVal input port.

Dependencies

To enable this parameter, set the Method parameter to Constant.

Specify a scalar value with which to pad the image.

Dependencies

To enable this parameter, set the Method parameter to Constant and the Pad value source parameter to Specify via dialog.

Select how to specify the size of the image padding from these two options:

  • Pad size — Specify the number of columns and rows with which to pad the image, using the Number of added columns and Number of added rows parameters, respectively.

  • Output size — Specify the size of the padded output image using a combination of the Output row mode, Number of output rows, Output column mode, and Number of output columns parameters.

Select which sides of the input image to pad with additional columns:

  • Left — Add columns to the left side of the input image.

  • Right — Add columns to the right side of the input image.

  • Both left and right — Add columns to both the left and right sides of the input image.

  • No padding — Do not add columns to the input image.

Specify the number of columns in the output image using one of these options:

  • User-specified — Specify the number of columns in the output image using the Number of output columns parameter.

  • Next power of two — Add columns to the input image until the total number of columns is a power of two.

Dependencies

To enable this parameter, set the Specify parameter to Output size.

Specify the number of columns in the output image as a positive integer M. If the value of this parameter is less than the number of columns in the input image, then the output image contains only the last M columns of the input image.

Dependencies

To enable this parameter, set the Specify parameter to Output size and the Output column mode parameter to User-specified.

Specify how many columns to add to the input signal. The behavior of this parameter changes depending on whether you are padding only one side or both sides of the image.

Add columns toNumber of added columns Description
LeftPAdd P columns to the left side of the input image.
RightQAdd Q columns to the right side of the input image.
Both left and right[P Q]Add P columns to the left side and Q columns to the right side of the input image.

Dependencies

To enable this parameter, set the Specify parameter to Pad size and the Add columns to parameter to Left, Right, or Both left and right.

Select which sides of the input image to pad with additional rows:

  • Top — Add rows to the top of the input image.

  • Bottom — Add rows to the bottom of the input image.

  • Both top and bottom — Add rows to both the top and bottom of the input image.

  • No padding — Do not add rows to the input image.

Specify the number of rows in the output image using one of these options:

  • User-specified — Specify the number of rows in the output image using the Number of output rows parameter.

  • Next power of two — Add rows to the input image until the total number of rows is a power of two.

Dependencies

To enable this parameter, set the Specify parameter to Output size.

Specify the number of rows in the output image as a positive integer N. If the value of this parameter is less than the number of rows in the input image, then the output image contains only the last N rows of the input image.

Dependencies

To enable this parameter, set the Specify parameter to Output size and the Output row mode parameter to User-specified.

Specify how many rows to add to the input signal. The behavior of this parameter changes depending on whether you are padding only one side or both sides of the image.

Add rows toNumber of added rows Description
TopRAdd R rows to the top of the input image.
BottomSAdd S rows to the bottom of the input image.
Both top and bottom[R S]Add R rows to the top and S rows to the bottom of the input image.

Dependencies

To enable this parameter, set the Specify parameter to Pad size and the Add rows to parameter to Top, Bottom, or Both top and bottom.

You can specify how the block behaves when the input signal is truncated as one of these options:

  • None — Does not notify you when the signal is truncated.

  • Warning — Displays a warning message in the MATLAB® command window when the input signal is truncated.

  • Error — Displays an error dialog box and terminates the simulation when the input signal is truncated.

Dependencies

To enable this parameter, set the Specify parameter to Output size.

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Multidimensional Signals

no

Variable-Size Signals

no

More About

expand all

Extended Capabilities

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

Version History

Introduced in R2007a

See Also

Blocks

Functions