SelectComponents[m, "prop", crit]
computes a property for all components in a label matrix m and returns a version of m in which components that do not satisfy crit are replaced with zeros.

SelectComponents[m, "prop", n]
gives a label matrix for the first n components, ranked by property .

SelectComponents[m, "prop", n, p]
uses an ordering function p.

Details and OptionsDetails and Options

  • For the complete list of possible properties, see the reference page for ComponentMeasurements.
  • SelectComponents[..., {"prop1", "prop2", ...}, ...] computes multiple properties.
  • SelectComponents[m, Large] selects components whose size is greater than a globally determined threshold.
  • SelectComponents[m, Small] selects the smaller components.
  • SelectComponents[m, "prop", -n] returns a label matrix for the last n components.
  • SelectComponents also works with binary images, using the connectivity of nonzero pixels to compute the label matrix.
  • By default all eight pixels surrounding a pixel are treated as neighbors. Using the option setting CornerNeighbors->False treats only the four pixels in the coordinate directions as adjacent.
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »