ants.ops.threshold_image

threshold_image(image, low_thresh=None, high_thresh=None, inval=1, outval=0, binary=True)[source]

Converts a scalar image into a binary image by thresholding operations

ANTsR function: thresholdImage

Parameters:
  • image (ants.core.ANTsImage) – Input image to operate on

  • low_thresh (scalar (optional)) – Lower edge of threshold window

  • hight_thresh (scalar (optional)) – Higher edge of threshold window

  • inval (scalar) – Output value for image voxels in between lothresh and hithresh

  • outval (scalar) – Output value for image voxels lower than lothresh or higher than hithresh

  • binary (bool) – if true, returns binary thresholded image if false, return binary thresholded image multiplied by original image

Return type:

ants.core.ANTsImage

Example

>>> import ants
>>> image = ants.image_read( ants.get_ants_data('r16') )
>>> timage = ants.threshold_image(image, 0.5, 1e15)