Padding arrays
Introduction
The padarray()
function generates a padded image from an array img
and a specification border
of the boundary conditions and amount of padding to add.
padarray([T], img, border)
The function returns a new image that is an expansion of the input image, in which additional pixels are derived from the border of the input image using the extrapolation scheme specified by border
.
The function supports one, two or multi-dimensional images. You can specify the element type T
of the output image.
The Pad
type
The type Pad
designates the form of padding which should be used to extrapolate pixels beyond the boundary of an image. Instances must set style
, a Symbol specifying the boundary conditions of the image.
The symbol must be one of:
-
:replicate
(repeat edge values to infinity), -
:circular
(image edges "wrap around"), -
:symmetric
(the image reflects relative to a position between pixels), -
:reflect
(the image reflects relative to the edge itself).
Refer to the documentation of Pad
for more details and examples for each option.
The Fill
type
The type Fill
designates a particular value which will be used to extrapolate pixels beyond the boundary of an image.
Refer to the documentation of Fill
for more details and illustrations.
2D Examples
3D Examples
Each example is based on a multi-dimensional array given by:
Note that each example will yield a new multi-dimensional array of type OffsetArray
, where prepended dimensions may be negative or start from zero.