ImagePad

ImagePad[image,m]

pads image on all sides with m background pixels.

ImagePad[image,m,padding]

pads image on all sides using the value or method specified by padding.

ImagePad[image,{{left,right},{bottom,top}},]

pads image with the specified numbers of pixels on each side.

ImagePad[image,{{left,right},{front,back},{bottom,top}},]

pads a 3D image with the specified numbers of pixels.

ImagePad[video,]

pads frames of video.

Details

  • ImagePad is typically used to add a frame around or extend beyond an image.
  • The following forms of padding can be specified:
  • zan intensity value
    colora color (GrayLevel, RGBColor, etc.)
    {c1,c2,}list of channel values
    Automaticautomatic choice based on the boundary
    "Fixed"repetitions of the pixels on each boundary
    "Periodic"cyclic repetitions of the complete image
    "Reflected"reflections of the image in the boundary
    "Reversed"reversals of the complete image
    "TextureSynthesis"texture synthesis based on the complete image
    {"TextureSynthesis",mask}texture synthesis based on the specified mask
  • With {"TextureSynthesis",texturemask}, texturemask can be one of the following:
  • nuse an n-pixel-wide border for padding
    Scaled[s]use fraction s of pixel dimension on each side
    maskimagea binary mask specifying the region to use for padding
  • 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.
  • 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 a real type.
  • ImagePad[image,-m] removes m pixels from each side of image.

Examples

open allclose all

Basic Examples  (2)

Pad an image:

Pad using the fixed padding scheme:

Scope  (7)

Data  (3)

Pad an image equally on all sides:

Pad frames of a video:

Pad a 3D image:

Size  (1)

Pad with a uniform border width of 10 pixels:

Specify different paddings on each side:

Crop an image by specifying negative padding size:

Padding  (3)

Specify the padding color:

Use fixed padding:

Use reflected padding:

Use periodic padding:

If an image already has a fairly constant frame, the mean frame color is used for Automatic padding:

Without a constant color frame, black padding is used:

Pad using texture synthesis:

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

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

Use the butterfly to synthesize a texture for the border pixels:

Use the background to synthesize texture:

By default, zero padding is used:

Specify different padding sizes for each side:

Specify the padding color:

Use periodic padding:

Applications  (4)

Add an image frame using different padding schemes:

Create a tiled image using periodic padding:

Detect and remove almost uniform borders of an image:

Remove the border:

Synthesize texture using a pattern:

Properties & Relations  (3)

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

ImagePad only changes the border of an image:

Use Inpaint to fill regions inside an image:

ImagePad adds or removes a number of pixels on the sides:

Use ImageCrop to specify the output dimensions:

Possible Issues  (1)

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

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

Wolfram Research (2008), ImagePad, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePad.html (updated 2021).

Text

Wolfram Research (2008), ImagePad, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePad.html (updated 2021).

CMS

Wolfram Language. 2008. "ImagePad." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImagePad.html.

APA

Wolfram Language. (2008). ImagePad. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImagePad.html

BibTeX

@misc{reference.wolfram_2024_imagepad, author="Wolfram Research", title="{ImagePad}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImagePad.html}", note=[Accessed: 05-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_imagepad, organization={Wolfram Research}, title={ImagePad}, year={2021}, url={https://reference.wolfram.com/language/ref/ImagePad.html}, note=[Accessed: 05-November-2024 ]}