ants.ops.crop_image

crop_image(image, label_image=None, label=1)[source]

Use a label image to crop a smaller ANTsImage from within a larger ANTsImage

ANTsR function: cropImage

Parameters:
  • image (ants.core.ANTsImage) – image to crop

  • label_image (ants.core.ANTsImage) – image with label values. If not supplied, estimated from data.

  • label (int) – the label value to use

Return type:

ants.core.ANTsImage

Example

>>> import ants
>>> fi = ants.image_read( ants.get_ants_data('r16') )
>>> cropped = ants.crop_image(fi)
>>> fi2 = ants.merge_channels([fi,fi])
>>> cropped2 = ants.crop_image(fi2)
>>> cropped = ants.crop_image(fi, fi, 100 )