trim_small_clusters

trim_small_clusters(im, size=1)[source]

Remove isolated voxels or clusters of a given size or smaller

Parameters
  • im (ND-array) – The binary image from which voxels are to be removed.

  • size (scalar) – The threshold size of clusters to trim. As clusters with this many voxels or fewer will be trimmed. The default is 1 so only single voxels are removed.

Returns

im – A copy of im with clusters of voxels smaller than the given size removed.

Return type

ND-array

Examples

Click here to view online example.