trw.transforms.crop

Module Contents

Functions

_crop_5d(image, min, max)

_crop_4d(image, min, max)

_crop_3d(image, min, max)

_crop_2d(image, min, max)

_crop_1d(image, min, max)

transform_batch_random_crop_offset(array, crop_shape)

Calculate the offsets of array to randomly crop it with shape crop_shape

transform_batch_random_crop(array, crop_shape, offsets=None, return_offsets=False)

Randomly crop a numpy array of samples given a target size. This works for an arbitrary number of dimensions

transform_batch_random_crop_joint(arrays, crop_shape)

Randomly crop a list of numpy arrays. Apply the same cropping for each array element

trw.transforms.crop._crop_5d(image, min, max)
trw.transforms.crop._crop_4d(image, min, max)
trw.transforms.crop._crop_3d(image, min, max)
trw.transforms.crop._crop_2d(image, min, max)
trw.transforms.crop._crop_1d(image, min, max)
trw.transforms.crop.transform_batch_random_crop_offset(array, crop_shape)

Calculate the offsets of array to randomly crop it with shape crop_shape

Parameters
  • array – a numpy array. Samples are stored in the first dimension

  • crop_shape – a sequence of size len(array.shape)-1 indicating the shape of the crop

Returns

a offsets to crop the array

trw.transforms.crop.transform_batch_random_crop(array, crop_shape, offsets=None, return_offsets=False)

Randomly crop a numpy array of samples given a target size. This works for an arbitrary number of dimensions

Parameters
  • array – a numpy or Torch array. Samples are stored in the first dimension

  • crop_shape – a sequence of size len(array.shape)-1 indicating the shape of the crop

  • offsets – if None, offsets will be randomly created to crop with crop_shape, else an array indicating the crop position for each sample

  • return_offsets – if True, returns a tuple (cropped array, offsets)

Returns

a cropped array

trw.transforms.crop.transform_batch_random_crop_joint(arrays, crop_shape)

Randomly crop a list of numpy arrays. Apply the same cropping for each array element

Parameters
  • arrays – a list of numpy or Torch arrays. Samples are stored in the first dimension

  • crop_shape – a sequence of size len(array.shape)-1 indicating the shape of the crop

Returns

a cropped array