({{, (RefLink[ImagePad, paclet:ref/ImagePad])[image,m] 
pads image on all sides with m background pixels.}, {, (RefLink[ImagePad, paclet:ref/ImagePad])[image,m,padding]
pads image on all sides using the value or method specified by padding.}, {, (RefLink[ImagePad, paclet:ref/ImagePad])[image,{{left,right},{bottom,top}},…]
pads image with the specified numbers of pixels on each side.}, {, (RefLink[ImagePad, paclet:ref/ImagePad])[image,{{left,right},{front,back},{bottom,top}},…]
pads a 3D image with the specified numbers of pixels.}})

OpenersNotesSection(Spacer1)Details

The following forms of padding can be specified:

With {"TextureSynthesis",texturemask}, texturemask can be one of the following:

The padding value "Fixed" indicates that the rectangles of pixels added at each corner should be copies of the pixels at the corners of the original image.

"Reversed" indicates that the outermost layer of pixels in the image should be repeated as the innermost layer of pixels in the padding. "Reflected" specifies that these pixels should not be repeated.

(RefLink[ImagePad, paclet:ref/ImagePad])[image,…] typically gives an image that has the same type as image. Padding a binary image with arbitrary intensity or color pixels typically returns an image of type "Real".

(RefLink[ImagePad, paclet:ref/ImagePad])[image,-m] removes m pixels from each side of image.

OpenersPrimaryExamplesSection(Spacer1)Examples  (13)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Pad an image:

ImagePad[,20]

OpenersExampleSection1(Spacer1)Scope  (6)

OpenersExampleSubsection0(Spacer1)Data  (2)

Pad an image equally on all sides:

ImagePad[,10]

Pad a 3D image:

ImagePad[,10]

OpenersExampleSubsection1(Spacer1)Size  (1)

By default, black padding is used:

i=;

ImagePad[i,10]

Crop an image by specifying negative padding size:

ImagePad[i,-10]

Specify different paddings on each side:

ImagePad[i,{{5,10},{20,40}}]

OpenersExampleSubsection2(Spacer1)Padding  (3)

Specify the padding color:

i=;

ImagePad[i,20,Red]

Use fixed padding:

ImagePad[i,20,"Fixed"]

Use reflected padding:

ImagePad[i,20,"Reflected"]

Use periodic padding:

ImagePad[i,20,"Periodic"]

If an image already has a fairly constant frame, the mean frame color is used for (RefLink[Automatic, paclet:ref/Automatic]) padding:

ImagePad[,20,Automatic]

Without a constant color frame, black padding is used:

ImagePad[, 20, Automatic]

Pad using texture synthesis:

i=;

ImagePad[i,15,"TextureSynthesis"]

Select padding texture elements from a 15-pixel-wide border:

ImagePad[i,30,{"TextureSynthesis",15}]

Select padding texture elements from a specified fraction of pixel dimension on each side:

ImagePad[i,30,{"TextureSynthesis",Scaled[0.1]}]

Specify the region from which padding texture elements are selected, using a mask:

ImagePad[i,30,{"TextureSynthesis",}]

By default, zero padding is used:

i=;

ImagePad[i,5]

Specify different paddings on each side:

ImagePad[i,{{0,0},{0,0},{10,10}}]

Specify the padding color:

ImagePad[i,1,Red]

Use periodic padding:

ImagePad[i,17,"Periodic"]

OpenersExampleSection2(Spacer1)Applications  (2)

Detect almost uniform borders of an image:

i=;

BorderDimensions[i,.1]

Remove the border:

ImagePad[i,-%]

Synthesize texture using a pattern:

ImagePad[,100,"TextureSynthesis"]

OpenersExampleSection3(Spacer1)Properties & Relations  (3)

When padding a grayscale image with a color, a color image is returned:

ImagePad[,5,Brown]

ImageColorSpace[%]

(RefLink[ImagePad, paclet:ref/ImagePad]) only changes the border of an image:

i=;

ImagePad[i,5,"TextureSynthesis"]

Use (RefLink[Inpaint, paclet:ref/Inpaint]) to fill regions inside an image:

Inpaint[i,]

(RefLink[ImagePad, paclet:ref/ImagePad]) adds or removes a number of pixels on the sides:

ImagePad[,{{20,20},{-20,-20}},Padding->Yellow]

Use (RefLink[ImageCrop, paclet:ref/ImageCrop]) to specify the output dimensions:

ImageCrop[,{190,62},Padding->Yellow]

OpenersExampleSection4(Spacer1)Possible Issues  (1)

By default, texture synthesis may select any pixels of the image. This may introduce undesired parts:

i=;

ImagePad[i,40,"TextureSynthesis"]

Specify the region from which padding texture elements are selected, using a mask:

ImagePad[i,40,{"TextureSynthesis",}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageCrop, paclet:ref/ImageCrop])  ▪  (RefLink[BorderDimensions, paclet:ref/BorderDimensions])  ▪  (RefLink[ArrayPad, paclet:ref/ArrayPad])  ▪  (RefLink[PadLeft, paclet:ref/PadLeft])  ▪  (RefLink[Padding, paclet:ref/Padding])  ▪  (RefLink[Inpaint, paclet:ref/Inpaint])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Image Processing, paclet:tutorial/ImageProcessing])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Basic Image Manipulation, paclet:guide/BasicImageManipulation])}, {▪(RefLinkPlain[Geometric Operations, paclet:guide/ImageGeometry])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})