tensorflow_mri.resize_with_crop_or_pad

resize_with_crop_or_pad(tensor, shape, padding_mode='constant')[source]

Crops and/or pads a tensor to a target shape.

Pads symmetrically or crops centrally the input tensor as necessary to achieve the requested shape.

Parameters
  • tensor – A Tensor.

  • shape – A Tensor. The shape of the output tensor. The length of shape must be equal to or less than the rank of tensor. If the length of shape is less than the rank of tensor, the operation is applied along the last len(shape) dimensions of tensor. Any component of shape can be set to the special value -1 to leave the corresponding dimension unchanged.

  • padding_mode – A str. Must be one of 'constant', 'reflect' or 'symmetric'.

Returns

A Tensor. Has the same type as tensor. The symmetrically padded/cropped tensor.