center_crop#
- pulserver.mrd.center_crop()[source]#
Crop the trailing axes of an image to a centred window.
- Parameters:
image – NumPy or Torch array.
shape – Extent of each trailing axis to keep; leading axes pass through.
- Returns:
A view of
image. Along each axis the sample at indexn // 2, the centre of a centred FFT ofnsamples, is at indexsize // 2of the window.- Return type:
array
- Raises:
ValueError – If
shapehas more axes thanimage, or an extent is not in1..image.shape[axis].
Examples
>>> import numpy as np >>> from pulserver.mrd import center_crop >>> image = np.arange(2 * 8).reshape(2, 8) >>> center_crop(image, (4,)).shape (2, 4) >>> center_crop(np.arange(8), (4,)) array([2, 3, 4, 5])