ptypy.utils.array_utils.crop_pad_symmetric_2d#

ptypy.utils.array_utils.crop_pad_symmetric_2d(A, newshape, center=None)#

Crops or pads Array A symmetrically along the last two axes (-2,-1) around center center to a new shape newshape.

Parameters:
  • A (array-like) – Input array, must be at least two-dimensional.

  • newshape (tuple, array_like) – New shape (for the last two axes). Must have at least 2 entries.

  • center (tuple, array_like, optional) – This coordinate tuple marks the center for cropping / padding If None, np.array(A.shape[-2:]) // 2 will be the center

Returns:

  • out (ndarray) – Cropped or padded array with shape A.shape[:-2]+newshape[-2:]

  • center (tuple) – Center in returned array, should be in the actual center of array.