Introducing a new way to review your PRs.

Read the announcement

insightsoftwareconsortium / itk

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.

View on GitHub

19 documents · Updated Nov 23, 2026

docs / segmentation-methods

Segmentation methods

ITK segmentation methods divide an image into useful regions or fit a boundary to an object. They use image values, seeds, class models, markers, or an initial surface to produce label images, masks, level-set fields, or meshes. These results connect image preparation to later label, measurement, and geometry work through the Filtering framework and Image-processing filters.

Segmentation scope

Segmentation selects an output form that matches the question about an object. A label image assigns a value to each pixel or voxel. A level set or mesh keeps a more direct description of the boundary.

Method familyMain evidenceMain result
Connected componentsConnectivity in a binary or label imageOne label per connected object
Region growingSeeds and a pixel or region ruleRegions grown from starting areas
ClassifiersPixel values and class modelsA class label for each pixel
Level setsAn initial boundary and image featuresAn evolving implicit boundary field
WatershedsA scalar height or edge image, with optional markersCatchment-basin labels and a region hierarchy
Label votingSeveral aligned label imagesA consensus label image
SuperpixelsImage values and spatial positionCompact local region labels
Deformable meshesAn initial mesh and image forcesA fitted surface mesh

The Segmentation algorithm families page gives more detail on method choice. The Segmentation label processing page explains shared rules for label identity and cleanup.

Segmentation flow

Segmentation usually follows a staged flow. Image preparation exposes the signal. A method creates regions or a boundary. Label or geometry processing then makes the result useful to later stages.

This diagram shows the main paths. A workflow can skip stages or use more than one segmentation family.

flowchart LR
    A[Image or prior labels] --> B[Preparation and features]
    B --> C{Segmentation evidence}
    C --> D[Connectivity or seeded growth]
    C --> E[Class model]
    C --> F[Height or edge image]
    C --> G[Initial surface and image forces]
    D --> H[Label image]
    E --> H
    F --> H
    G --> I[Level-set field or mesh]
    H --> J[Label refinement and measurement]
    I --> K[Surface or spatial object]

The input and output must keep their meaning. A class label is not a connected-object identifier. A level-set field is not a binary mask until its zero boundary is tested or converted. See Image-processing filters for preparation and label operations.

Connected-component segmentation

Connected-component segmentation finds separate objects in a binary image by following pixel or voxel connectivity. Each object receives a distinct label. This changes a foreground mask into an object map that later filters can count, select, or measure. The family can also use a mask and a caller-defined neighbor rule. Modules/…/itkConnectedComponentImageFilter.h• L25-44 Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentImageFilter.hxx#L47-L165 Modules/…/itkConnectedComponentFunctorImageFilter.h• L25-47 Modules/…/itkHardConnectedComponentImageFilter.h• L26-46

Connectivity is part of the object definition. Face connectivity keeps diagonal contact separate in two dimensions. Full connectivity also joins edge- or corner-touching pixels. The pass labels the full image region and checks that the output type can represent every object. Relabeling can then sort objects by size, remove small objects, and report pixel or physical size. Modules/…/itkConnectedComponentImageFilter.h• L29-44 Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentImageFilter.hxx#L137-L149 Modules/…/itkRelabelComponentImageFilter.h• L29-63 Modules/…/itkRelabelComponentImageFilter.h• L160-205

Connected components often bridge image-processing filters and object-level analysis. For background values, label identity, and label cleanup, see Segmentation label processing.

References: Modules/…/itkConnectedComponentImageFilter.h• L25-44 Modules/…/itkConnectedComponentImageFilter.hxx• L47-165 Modules/…/itkConnectedComponentFunctorImageFilter.h• L25-47 Modules/…/itkHardConnectedComponentImageFilter.h• L26-46 Modules/…/itkRelabelComponentImageFilter.h• L29-63

Region-growing segmentation

Region growing starts from one or more seed locations and expands through connected pixels that meet a similarity rule. It is useful when a user can identify representative points or when the target has a local intensity pattern. Direct threshold growth uses an inclusive value range. Neighborhood-connected growth also checks the surrounding neighborhood. Modules/…/itkConnectedThresholdImageFilter.h• L54-60 Modules/…/itkNeighborhoodConnectedImageFilter.h• L25-31

Confidence growth estimates statistics near a seed and accepts connected values inside a confidence range. It can update that range from the growing region over several passes. Other methods support interactive multi-object propagation, energy-based region merging, and Voronoi cell partitioning. These methods all turn local evidence into region labels, but they differ in whether the main control is a seed, a merge rule, or a cell model. Modules/…/itkConfidenceConnectedImageFilter.h• L26-51 Modules/…/itkFastGrowCut.h• L33-47 Modules/…/itkKLMRegionGrowImageFilter.h• L31-79 Modules/…/itkVoronoiPartitioningImageFilter.h• L25-31

Region-growing results are usually masks or label images. Their label meaning must remain clear before later combination or measurement. The Segmentation algorithm families page compares the seed, propagation, merge, and partition paths.

References: Modules/…/itkConnectedThresholdImageFilter.h• L54-60 Modules/…/itkNeighborhoodConnectedImageFilter.h• L25-31 Modules/…/itkConfidenceConnectedImageFilter.h• L26-51 Modules/…/itkFastGrowCut.h• L33-47 Modules/…/itkKLMRegionGrowImageFilter.h• L31-79 Modules/…/itkVoronoiPartitioningImageFilter.h• L25-31

Classifier-based segmentation

Classifier-based segmentation assigns each pixel to a class from its measured values. The image classifier keeps the image grid and applies class membership rules with a decision rule. This lets multiband pixels become class labels without losing their image position. Modules/…/itkImageClassifierBase.h• L27-65

The family supports configured and learned class models. K-means estimates clusters from starting intensity means. Bayesian classification combines class membership with optional prior information and chooses the strongest posterior value. Markov random field classification adds neighborhood agreement to the value-based decision. This makes it useful as a second stage when a value-only result lacks spatial coherence. Modules/…/itkScalarImageKmeansImageFilter.h• L37-55 Modules/…/itkBayesianClassifierImageFilter.h• L29-62 Modules/…/itkMRFImageFilter.h• L58-87

Classifier models and membership rules use the statistics concepts described in Numerical optimization and statistics. The output class dictionary must stay stable when another classifier or label-voting step consumes the result.

References: Modules/…/itkImageClassifierBase.h• L27-65 Modules/…/itkScalarImageKmeansImageFilter.h• L37-55 Modules/…/itkScalarImageKmeansImageFilter.h• L124-146 Modules/…/itkBayesianClassifierInitializationImageFilter.hxx• L72-108 Modules/…/itkBayesianClassifierImageFilter.h• L29-62 Modules/…/itkMRFImageFilter.h• L58-87

Level-set segmentation

Level-set segmentation represents a boundary as the zero surface of a scalar level-set function. The function evolves from an initial seed or surface under image and shape forces. The boundary can expand, contract, smooth, or follow image edges without being stored as a fixed set of points. Modules/…/itkSegmentationLevelSetImageFilter.h• L29-42

The output remains an implicit field. The zero crossing marks the boundary. Feature images, curvature, propagation, and advection terms control how the boundary responds to the data. Sparse-field solvers keep detailed values in layers around the active boundary and use fixed signed values farther away. Modules/…/itkSegmentationLevelSetImageFilter.h• L58-84 Modules/…/itkSparseFieldLevelSetImageFilter.h• L128-226 Modules/…/itkParallelSparseFieldLevelSetImageFilter.h• L135-228

An active-contour workflow commonly prepares an edge potential, creates an initial signed field, evolves the level set, and thresholds the zero surface into a mask. The parallel sparse-field form keeps the active-boundary model while distributing the work across work units. Shape-prior level sets add learned shape and pose evidence to image evidence. Modules/…/GeodesicActiveContourImageFilterTest.py• L58-64 Modules/…/GeodesicActiveContourImageFilterTest.py• L81-142 Modules/…/itkShapePriorMAPCostFunctionBase.h• L27-42

ITK also provides a newer v4 level-set framework. It separates level-set representations from evolution terms and stopping rules. Its sparse representations use different layer schemes: Malcolm uses one signed layer, Shi uses two signed layers, and Whitaker keeps several real-valued layers. They provide the same boundary and geometric evaluation role to the evolution framework. Modules/…/itkLevelSetEvolution.h• L42-57 Modules/…/itkMalcolmSparseLevelSetImage.h• L30-42 Modules/…/itkShiSparseLevelSetImage.h• L26-38 Modules/…/itkWhitakerSparseLevelSetImage.h• L28-42

Level-set work depends on image features, signed distance ideas, narrow-band updates, and numerical stopping rules. Use Image-processing filters when the feature image needs smoothing or gradient preparation.

References: Modules/…/itkSegmentationLevelSetImageFilter.h• L29-42 Modules/…/itkSegmentationLevelSetImageFilter.h• L58-84 Modules/…/itkSparseFieldLevelSetImageFilter.h• L128-226 Modules/…/itkParallelSparseFieldLevelSetImageFilter.h• L135-228 Modules/…/itkShapePriorMAPCostFunctionBase.h• L27-42 Modules/…/itkLevelSetEvolution.h• L42-57 Modules/…/itkMalcolmSparseLevelSetImage.h• L30-135 Modules/…/itkShiSparseLevelSetImage.h• L26-135 Modules/…/itkWhitakerSparseLevelSetImage.h• L28-159

Watershed segmentation

Watershed segmentation treats a scalar image as a height map. Each location is assigned to a catchment basin reached by steepest descent. An edge or gradient image often supplies the height map, so strong boundaries can separate the basins. Modules/…/itkWatershedImageFilter.h• L29-48

The method forms local basins and records how neighboring basins merge as a flood level rises. This hierarchy lets a workflow choose a fine or coarse label image. A threshold can suppress shallow minima. Marker-based watershed imposes selected minima and preserves the marker labels, which helps limit over-segmentation. Modules/…/itkWatershedImageFilter.h• L50-71 Modules/…/itkMorphologicalWatershedFromMarkersImageFilter.h• L38-62

Watershed outputs are label images. Their values identify regions rather than original intensity classes. Label 0 can represent watershed lines or background, and morphological labels are not ordered by object size. See Segmentation label processing before size-based selection or relabeling. Modules/…/itkMorphologicalWatershedImageFilter.h• L25-35 Modules/…/itkMorphologicalWatershedImageFilter.h• L86-112

References: Modules/…/itkWatershedImageFilter.h• L29-71 Modules/…/itkMorphologicalWatershedImageFilter.h• L25-35 Modules/…/itkMorphologicalWatershedFromMarkersImageFilter.h• L38-62

Label voting

Label voting combines several segmentations of the same image into one consensus label image. At each location it chooses the label with the most votes. This is a post-segmentation step, not a method for deriving labels from raw intensity values. Modules/…/itkLabelVotingImageFilter.h• L25-35

Voting depends on spatial alignment and shared label meaning. A tie receives an undecided label instead of silently choosing one class. Binary voting uses neighborhood birth and survival thresholds. Binary median voting smooths a foreground mask by counting foreground neighbors. Modules/…/itkLabelVotingImageFilter.h• L40-68 Modules/…/itkVotingBinaryImageFilter.h• L25-29 Modules/…/itkBinaryMedianImageFilter.h• L25-39

For the rules for background, ties, relabeling, and cleanup, see Segmentation label processing.

References: Modules/…/itkLabelVotingImageFilter.h• L25-68 Modules/…/itkVotingBinaryImageFilter.h• L25-103 Modules/…/itkBinaryMedianImageFilter.h• L25-101

Superpixel segmentation

Superpixel segmentation groups nearby pixels into compact regions that follow local image boundaries. SLIC treats image value and image position as one clustering space and returns a label for every pixel. Modules/…/itkSLICImageFilter.h• L27-50 Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx#L100-L180

Superpixels are often intermediate units rather than final object labels. They reduce the number of image elements for later classification, graph, or measurement work while keeping local image structure. Region size and spatial weight set the balance between compact shape and value similarity. An optional connectivity pass makes each label spatially connected and handles fragments that are too small for the expected scale. Modules/…/itkSLICImageFilter.h• L101-161 Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx#L413-L561 Modules/Segmentation/SuperPixel/include/itkSLICImageFilter.hxx#L664-L678

References: Modules/…/itkSLICImageFilter.h• L27-50 Modules/…/itkSLICImageFilter.h• L101-161 Modules/…/itkSLICImageFilter.hxx• L100-180 Modules/…/itkSLICImageFilter.hxx• L413-561 Modules/…/itkSLICImageFilter.hxx• L664-678

Deformable mesh segmentation

Deformable mesh segmentation fits a three-dimensional surface to image evidence by moving the vertices of an initial mesh. Internal forces preserve shape and smoothness. External forces from image change pull the surface toward a target boundary. Modules/…/itkDeformableSimplexMesh3DFilter.h• L43-68

The gradient-constraint force variant searches for a strong gradient along each vertex normal within a configured range. It can search in the normal direction, the inverse direction, or both. This gives the force a bounded direction and distance instead of relying only on the local gradient. Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.h• L136-141 Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.h• L193-230

This family produces geometry instead of a per-voxel label image. It is useful when the final product must support surface shape, topology, or spatial queries. See the mesh and spatial-object page for downstream surface use.

References: Modules/…/itkDeformableSimplexMesh3DFilter.h• L43-74 Modules/…/itkDeformableSimplexMesh3DFilter.h• L145-179 Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.h• L136-141 Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.h• L193-230

Representation relationships

The families differ in the evidence they trust and in the form of their result. One method can supply seeds, markers, features, or a starting surface for another method.

Starting resultUseful next stepRelationship
Thresholded binary imageConnected components or region growingSeparates objects or expands selected regions
Classifier label imageNeighborhood refinement or label votingAdds spatial agreement or combines decisions
Gradient or edge imageWatershed or level setConverts image change into regions or a moving boundary
Superpixel label imageClassifier or region modelReplaces many pixels with compact local units
Binary mask or initial surfaceLevel set or deformable meshRefines a boundary with image and shape evidence
Several aligned segmentationsLabel votingProduces one consensus result

The output representation sets the next contract. A label image can be relabeled or voted on. A level-set field can be thresholded or converted to a surface. A mesh can enter geometric workflows. Each conversion must preserve object identity and physical position.

References: Modules/…/itkConnectedComponentImageFilter.h• L25-44 Modules/…/itkBayesianClassifierImageFilter.h• L33-54 Modules/…/itkSegmentationLevelSetImageFilter.h• L79-84 Modules/…/itkDeformableSimplexMesh3DFilter.h• L43-68

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep connectivity rules aligned across connected components, region growth, watershed, and superpixel consumers.
  • Keep seed, marker, prior, and mask meaning aligned across region growing, marker watershed, and level-set initialization.
  • Preserve class-label meaning across classifiers, neighborhood refinement, and label voting.
  • Keep level-set sign, zero-surface, feature, and stopping rules aligned with mask and surface conversion.
  • Keep sparse-field layer counts large enough for the geometry terms that read the active boundary.
  • Keep the chosen v4 sparse representation compatible with the evolution terms and geometric evaluations.
  • Preserve marker labels, background values, watershed-line behavior, and relabeling assumptions.
  • Keep aligned label images and their label dictionaries consistent before voting.
  • Check superpixel connectivity when a downstream consumer expects one connected region per label.
  • Keep mesh images registered, and keep constrained force range and search direction consistent with the target boundary.
  • Check that connected-component output types can represent the number of detected objects.

Important failure modes

TriggerConsequenceGuard
Diagonal contact uses the wrong connectivity rule.Objects merge or split into several labels.Treat connectivity as part of the object definition.
A seed or acceptance rule does not match the target.Region growth leaks or stops too early.Use representative seeds and a suitable similarity rule.
Class labels have different meanings at the same numeric value.Label voting produces a plausible but wrong result.Align images and use one label dictionary.
The level-set feature has weak or reversed boundary evidence.The surface stops at the wrong place or moves away from the target.Prepare the feature image and check sign and force direction.
Sparse-field layers do not cover the required neighborhood.Geometry terms read arbitrary background values.Set the layer count for the largest stencil or derivative.
A watershed has many noise-driven minima and no useful merge level or markers.The result is over-segmented.Smooth or threshold the height image, or provide markers.
Watershed lines or unordered labels are treated as object labels.Background and object selection are misread.Preserve the label contract and relabel before size-based selection.
Voting inputs are not aligned or use different class dictionaries.The consensus label has the wrong meaning.Register inputs and establish shared label semantics first.
A superpixel label is disconnected.A consumer expecting one region per label misreads it.Enable connectivity enforcement when required.
A constrained mesh force uses a mismatched image, range, or search direction.Vertices move to a false edge or receive no useful force.Keep source images registered and choose a matching search range.
The output type cannot represent all connected objects.Connected-component generation fails before a valid label image exists.Use an output type with enough value range.

Key files

FileWhy to read it
Modules/…/itkConnectedComponentImageFilter.hDefines object labels from binary connectivity.
Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentImageFilter.hxxShows whole-image labeling, mask use, object counting, and output-range checks.
Modules/…/itkRelabelComponentImageFilter.hDefines size-based relabeling and object-size reporting.
Modules/…/itkConnectedThresholdImageFilter.hDefines seed-connected growth with an intensity range.
Modules/…/itkConfidenceConnectedImageFilter.hDefines growth based on local statistics.
Modules/…/itkImageClassifierBase.hDefines the image and class-label contract.
Modules/…/itkScalarImageKmeansImageFilter.hDefines scalar-image clustering and label numbering.
Modules/…/itkMRFImageFilter.hExplains neighborhood-aware label refinement.
Modules/…/itkSegmentationLevelSetImageFilter.hDefines the implicit boundary and evolution terms.
Modules/…/itkSparseFieldLevelSetImageFilter.hDefines the sparse active-boundary representation and its sign contract.
Modules/…/itkParallelSparseFieldLevelSetImageFilter.hDefines the parallel sparse-field evolution model.
Modules/…/itkLevelSetEvolution.hIntroduces the v4 evolution model and representation choices.
Modules/…/itkMalcolmSparseLevelSetImage.hDefines the one-layer sparse representation.
Modules/…/itkShiSparseLevelSetImage.hDefines the two-layer sparse representation.
Modules/…/itkWhitakerSparseLevelSetImage.hDefines the multi-layer real-valued sparse representation.
Modules/…/itkWatershedImageFilter.hDefines catchment basins and their merge hierarchy.
Modules/…/itkMorphologicalWatershedFromMarkersImageFilter.hDefines marker-controlled basin labels.
Modules/…/itkLabelVotingImageFilter.hDefines consensus labels and tie behavior.
Modules/…/itkSLICImageFilter.hDefines compact value-and-position clustering and connectivity.
Modules/…/itkDeformableSimplexMesh3DFilter.hDefines image-force and internal-force mesh evolution.
Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.hDefines bounded gradient search along mesh-vertex normals.