ants.segmentation.kmeans

Functions

kmeans_segmentation(image, k[, kmask, mrf])

K-means image segmentation that is a wrapper around ants.atropos

kmeans_segmentation(image, k, kmask=None, mrf=0.1)[source]

K-means image segmentation that is a wrapper around ants.atropos

ANTsR function: kmeansSegmentation

Parameters:
  • image (ants.core.ANTsImage) – input image

  • k (int) – integer number of classes

  • kmask (ANTsImage (optional)) – segment inside this mask

  • mrf (scalar) – smoothness, higher is smoother

Return type:

ants.core.ANTsImage

Example

>>> import ants
>>> fi = ants.image_read(ants.get_ants_data('r16'), 'float')
>>> fi = ants.n3_bias_field_correction(fi, 2)
>>> seg = ants.kmeans_segmentation(fi, 3)