Image Processing Toolbox    
padarray

Pad an array

Syntax

Description

B = padarray(A,padsize,method,direction) pads array A with padsize number of elements along each dimension, using specified method and direction. The N-th element of the padsize vector specifies the padding size for the N-th dimension of the array, A.

method can be a numeric scalar, in which case it specifies the value for all padding elements, or one of the following strings which specify other methods used to determine pad values. By default, METHOD sets the pad value to the 0.

Value
Meaning
'circular'
Pad with circular repetition of elements within the dimension.
'replicate'
Pad by repeating border elements of array.
'symmetric'
Pad array with mirror reflections of itself.

direction specifies where to pad the array along each dimension. By default, direction is 'post'.

Value
Meaning
'pre'
Pad before the first element of each dimension.
'post'
Pad after the last element of each dimension. This is the default.
'both'
Pads before the first element and after the last element of each dimension.

Class Support

When padding with a constant value, A can be numeric or logical. When padding using the 'circular', 'replicate', or 'symmetric' methods, A can be of any class. B is of the same class as A.

Example

Add three elements of padding to the beginning of a vector. The padding elements contain mirror copies of the array.

Add three elements of padding to the end of the first dimension of the array and two elements of padding to the end of the second dimension. Use the value of the last array element as the padding value.

Add three elements of padding to each dimension of a three-dimensional array. Each pad element contains the value 0.

See Also

circshift, imfilter


  otf2psf phantom