Image Processing Toolbox User's Guide |
Syntax
Description
B = padarray(A,padsize)
pads array A
with 0's (zeros). padsize
is a vector of positive integers that specifies both the amount of padding to add and the dimension along which to add it. The value of an element in the vector specifies the amount of padding to add. The order of the element in the vector specifies the dimension along which to add the padding.
For example, a padsize
value of [2 3]
means add 2 elements of padding along the first dimension and 3 elements of padding along the second dimension. By default, paddarray
adds padding before the first element and after the last element along the specified dimension.
B = padarray(A,padsize,padval)
pads array A
where padval
specifies the value to use as the pad value. padarray
uses the value 0 (zero) as the default. padval
can be a scalar that specifies the pad value directly or one of the following text strings that specifies the method padarray
uses to determine the values of the elements added as padding.
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. |
B = padarray(A,padsize,padval,direction)
pads A
in the direction specified by the string direction
. direction
can be one of the following strings. The default value is enclosed in braces ({}
).
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 1
Add three elements of padding to the beginning of a vector. The padding elements, indicated by the gray shading, contain mirror copies of the array elements.
Example 2
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. The example uses the value of the last array element as the padding value.
Example 3
Add three elements of padding to the vertical and horizontal dimensions of a three-dimensional array. Use default values for the pad value and direction.
A = [ 1 2; 3 4]; B = [ 5 6; 7 8]; C = cat(3,A,B) C(:,:,1) = 1 2 3 4 C(:,:,2) = 5 6 7 8 D = padarray(C,[3 3]) D(:,:,1) ==
D(:,:,2) ===
See Also
otf2psf | para2fan |
© 1994-2005 The MathWorks, Inc.