webbpsf_ext.image_manip.pad_or_cut_to_size¶
- webbpsf_ext.image_manip.pad_or_cut_to_size(array, new_shape, fill_val=0.0, offset_vals=None, shift_func=<function fshift>, **kwargs)[source]¶
Resize an array to a new shape by either padding with zeros or trimming off rows and/or columns. The output shape can be of any arbitrary amount.
- Parameters
array (ndarray) – A 1D, 2D, or 3D array. If 3D, then taken to be a stack of images that are cropped or expanded in the same fashion.
new_shape (tuple) – Desired size for the output array. For 2D case, if a single value, then will create a 2-element tuple of the same value.
fill_val (scalar, optional) – Value to pad borders. Default is 0.0
offset_vals (tuple) – Option to perform image shift in the (xpix) direction for 1D, or (ypix,xpix) direction for 2D/3D prior to cropping or expansion.
shift_func (function) – Function to use for shifting. Usually either fshift or fourier_imshift.
- Returns
output (ndarray) – An array of size new_shape that preserves the central information of the input array.