replaces small connected components in a binary image image with background pixels.

replaces positive integers in a label matrix m with if their tally is small.

DeleteSmallComponents[..., n]
replaces components consisting of n or fewer elements.

Details and OptionsDetails and Options

  • DeleteSmallComponents by default treats all pixels surrounding a given pixel as adjacent. A given pixel has eight adjacent pixels in 2D and 26 adjacent pixels in 3D.
  • The option setting CornerNeighbors->False treats only the pixels in the coordinate directions as adjacent, which would include four pixels in 2D and six pixels in 3D.
  • DeleteSmallComponents[input, Method->method] specifies the method to use to determine the pixel size of small components.
  • The default setting is Method->"Cluster", corresponding to cluster variance maximization.
  • Possible settings for the Method option include:
  • "Cluster"cluster variance maximization (Otsu's algorithm)
    "Mean"use the mean of component sizes as the threshold
    "Median"use the median of component sizes as the threshold

ExamplesExamplesopen allclose all

Basic Examples (2)Basic Examples (2)

Delete small components in a binary image:

Click for copyable input

Remove small components from a label matrix:

Click for copyable input
New in 8 | Last modified in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »