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 family | Main evidence | Main result |
|---|---|---|
| Connected components | Connectivity in a binary or label image | One label per connected object |
| Region growing | Seeds and a pixel or region rule | Regions grown from starting areas |
| Classifiers | Pixel values and class models | A class label for each pixel |
| Level sets | An initial boundary and image features | An evolving implicit boundary field |
| Watersheds | A scalar height or edge image, with optional markers | Catchment-basin labels and a region hierarchy |
| Label voting | Several aligned label images | A consensus label image |
| Superpixels | Image values and spatial position | Compact local region labels |
| Deformable meshes | An initial mesh and image forces | A 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 result | Useful next step | Relationship |
|---|---|---|
| Thresholded binary image | Connected components or region growing | Separates objects or expands selected regions |
| Classifier label image | Neighborhood refinement or label voting | Adds spatial agreement or combines decisions |
| Gradient or edge image | Watershed or level set | Converts image change into regions or a moving boundary |
| Superpixel label image | Classifier or region model | Replaces many pixels with compact local units |
| Binary mask or initial surface | Level set or deformable mesh | Refines a boundary with image and shape evidence |
| Several aligned segmentations | Label voting | Produces 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
| Trigger | Consequence | Guard |
|---|---|---|
| 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
| File | Why to read it |
|---|---|
| Modules/…/itkConnectedComponentImageFilter.h | Defines object labels from binary connectivity. |
Modules/Segmentation/ConnectedComponents/include/itkConnectedComponentImageFilter.hxx | Shows whole-image labeling, mask use, object counting, and output-range checks. |
| Modules/…/itkRelabelComponentImageFilter.h | Defines size-based relabeling and object-size reporting. |
| Modules/…/itkConnectedThresholdImageFilter.h | Defines seed-connected growth with an intensity range. |
| Modules/…/itkConfidenceConnectedImageFilter.h | Defines growth based on local statistics. |
| Modules/…/itkImageClassifierBase.h | Defines the image and class-label contract. |
| Modules/…/itkScalarImageKmeansImageFilter.h | Defines scalar-image clustering and label numbering. |
| Modules/…/itkMRFImageFilter.h | Explains neighborhood-aware label refinement. |
| Modules/…/itkSegmentationLevelSetImageFilter.h | Defines the implicit boundary and evolution terms. |
| Modules/…/itkSparseFieldLevelSetImageFilter.h | Defines the sparse active-boundary representation and its sign contract. |
| Modules/…/itkParallelSparseFieldLevelSetImageFilter.h | Defines the parallel sparse-field evolution model. |
| Modules/…/itkLevelSetEvolution.h | Introduces the v4 evolution model and representation choices. |
| Modules/…/itkMalcolmSparseLevelSetImage.h | Defines the one-layer sparse representation. |
| Modules/…/itkShiSparseLevelSetImage.h | Defines the two-layer sparse representation. |
| Modules/…/itkWhitakerSparseLevelSetImage.h | Defines the multi-layer real-valued sparse representation. |
| Modules/…/itkWatershedImageFilter.h | Defines catchment basins and their merge hierarchy. |
| Modules/…/itkMorphologicalWatershedFromMarkersImageFilter.h | Defines marker-controlled basin labels. |
| Modules/…/itkLabelVotingImageFilter.h | Defines consensus labels and tie behavior. |
| Modules/…/itkSLICImageFilter.h | Defines compact value-and-position clustering and connectivity. |
| Modules/…/itkDeformableSimplexMesh3DFilter.h | Defines image-force and internal-force mesh evolution. |
| Modules/…/itkDeformableSimplexMesh3DGradientConstraintForceFilter.h | Defines bounded gradient search along mesh-vertex normals. |