padarray() - Image Processing
B = padarray(A,padsize) pads
array A with 0's (zeros). padsize is
a vector of nonnegative 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.ValueMeaning
'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 ({}).ValueMeaning
{'both'}Pads before the first element and after the last array
element along each dimension. This is the default.
'post'Pad after the last array element along each dimension.
'pre'Pad before the first array element along each dimension.
gpuarrayB = padarray(gpuarrayA,___) performs
the padding operation on a GPU, where gpuarrayA is
a gpuArray object that contains the image A. The
return value gpuarrayB is also a gpuArray. This
syntax requires the Parallel Computing Toolbox™.Code Generation support:
Yes.MATLAB Function Block support:
Yes.
Syntax
B = padarray(A,padsize)B = padarray(A,padsize,padval)B = padarray(A,padsize,padval,direction)gpuarrayB = padarray(gpuarrayA,___)
Example
a = [ 1 2 3 4 ];
b = padarray(a,[0 3],'symmetric','pre')
b ==
Output / Return Value
Limitations
Alternatives / See Also
Reference