ants.ops.pad_image
- pad_image(image, shape=None, pad_width=None, value=0.0, return_padvals=False)[source]
Pad an image to have the given shape or to be isotropic.
- Parameters:
image (
ants.core.ANTsImage) – image to padshape (
tuple) –if shape is given, the image will be padded in each dimension until it has this shape
if shape and pad_width are both None, the image will be padded along each dimension to match the largest existing dimension so that it has isotropic dimensions.
pad_width (
listofintegersorlist-of-listofintegers) – How much to pad in each direction. If a single list is supplied (e.g., [4,4,4]), then the image will be padded by half that amount on both sides. If a list-of-list is supplied (e.g., [(0,4),(0,4),(0,4)]), then the image will be padded unevenly on the different sidespad_value (
scalar) – value with which image will be padded
Example
>>> import ants >>> img = ants.image_read(ants.get_data('r16')) >>> img2 = ants.pad_image(img, shape=(300,300)) >>> mni = ants.image_read(ants.get_data('mni')) >>> mni2 = ants.pad_image(mni) >>> mni3 = ants.pad_image(mni, pad_width=[(0,4),(0,4),(0,4)]) >>> mni4 = ants.pad_image(mni, pad_width=(4,4,4))