Skip to main content

Region-Based Segmentation

Region-based segmentation techniques grow or divide regions based on connectivity and similarity criteria. These methods complement threshold segmentation by considering spatial relationships between voxels, making them effective for isolating connected structures and separating touching objects.

Estimated time: 30 minutes

Prerequisites:

Medical Disclaimer

Segmentation results should be reviewed and validated by qualified professionals. These tools assist the segmentation process but are not a substitute for expert judgment.


Understanding Region-Based Methods

Region-based segmentation uses spatial connectivity to group voxels:

  • Region Growing — Starts from seed points and expands to include connected voxels meeting similarity criteria
  • Watershed — Treats intensity as elevation and finds boundaries where "water" would collect
  • GrowCut — Uses cellular automata to propagate labels from user-defined seeds

These methods are useful when:

  • Objects have similar intensity but are spatially separate
  • You need to isolate one object from a group
  • Threshold results include multiple connected components

Region Grow (Within Mask)

The Region Grow tool performs region growing on an existing mask to isolate connected regions. Starting from a seed point, it identifies and extracts all connected voxels as a new segment.

When to Use

  • You have a threshold segmentation containing multiple separate objects
  • You want to extract a single object from a combined mask
  • You need to verify connectivity between regions
  • Objects are disconnected or separable but contained in one mask

Understanding Connectivity

Region growing works on binary mask data using two connectivity modes:

  • 6-connectivity (default) — Only voxels sharing faces are considered connected. More conservative for object separation.
  • 26-connectivity — Voxels sharing faces, edges, or corners are connected. More inclusive for capturing thin connections.

Step-by-Step Workflow

  1. Create initial segmentation:

    • Use Threshold to create a mask containing all objects of interest
    • The mask may contain multiple disconnected structures
    • Apply any necessary filtering to clean the mask
  2. Open Region Grow:

    • Navigate to Segmentation → Create Mask → Region Grow
  3. Configure connectivity settings:

    • Connectivity: Choose 6-connected for conservative separation or 26-connected for inclusive segmentation
    • Multiple layer: Enable (checked) to process all slices; disable (unchecked) for current slice only
    • Keep original mask: Enable to preserve the source mask while creating results
  4. Configure result settings:

    • Target mask: Select where results will be stored (new mask or existing)
    • Mode: Choose Replace (default) to replace target mask or Merge to add to existing
  5. Place seed point:

    • Left-click on the desired object in either the 2D slice views or 3D view
    • Use Ctrl+drag in 3D view to rotate while selecting
    • Press P key as a shortcut for quick selection mode
    • The algorithm immediately identifies all connected voxels from the seed
  6. Review and repeat:

    • The isolated object appears in the target mask
    • Repeat steps 4-5 to extract additional objects as needed
    • Use Replace mode to create separate masks for each object
Connectivity Selection

Use 6-connectivity when you want strict separation—objects must share faces to be connected. Use 26-connectivity when thin diagonal bridges should be preserved as connections.

Practical Example: Isolating Vertebrae

1. Load a CT spine dataset
2. Create a threshold mask of all bone (HU 200-3000)
3. Open Region Grow with 6-connectivity enabled
4. Left-click on L1 vertebra → isolated L1 mask
5. Repeat for L2, L3, etc.
6. Individual vertebra masks ready for analysis

Dynamic Region Grow

Dynamic Region Grow expands regions from a seed point based on grayscale intensity. It offers two methods: Connectivity (statistical intensity matching) or Threshold (intensity range-based).

When to Use

  • You're segmenting directly from grayscale volume data (not an existing mask)
  • Target structure has relatively uniform or similar intensity
  • Object boundaries are defined by intensity gradients
  • You want to segment structures with consistent statistical properties

Method Selection

Choose one of two region growing approaches:

Connectivity Method:

  • Analyzes statistical properties around the seed point
  • Grows by including neighboring voxels with similar intensity statistics
  • Multiplier: Controls confidence interval (1.0 to 100.0, default: 1.0)
  • Number of iterations: Repetition count (default: 1)
  • Initial neighborhood radius: Starting region size in pixels (default: 1)
  • Best when intensity varies gradually within the object

Threshold Method:

  • Includes voxels within a specific intensity range
  • Fixed minimum and maximum intensity thresholds
  • Connectivity: 6 or 26 neighborhood
  • Best when you know the specific intensity range of your target

Step-by-Step Workflow

  1. Load volume data:

    • Ensure the target volume is the active object
    • No pre-existing mask is required
  2. Open Dynamic Region Grow:

    • Navigate to Segmentation → Create Mask → Dynamic Region Grow
  3. Select region growing method:

    • Choose Connectivity for statistical similarity-based growing
    • Choose Threshold for fixed intensity range growing
  4. Configure method parameters:

    • For Connectivity method:
      • Adjust Multiplier (default 1.0) to control sensitivity
      • Set Number of iterations (default 1)
      • Set Initial neighborhood radius in pixels (default 1 pixel)
    • For Threshold method:
      • Use the histogram to set Minimum threshold value
      • Use the histogram to set Maximum threshold value
      • Choose Connectivity mode (6 or 26)
  5. Configure options:

    • Fill cavities: Enable to automatically fill internal gaps
    • Multiple layer: Enable (default) for 3D growth; disable for 2D slice-only
  6. Configure result settings:

    • Target mask: Select destination (new or existing)
    • Mode: Choose Replace (default) or Merge
  7. Place seed point:

    • Left-click on the target structure in 2D or 3D view
    • Use Ctrl+drag to rotate in 3D while selecting
    • The region grows automatically from the seed
  8. Evaluate and refine:

    • If region is too small: increase tolerances/multiplier or widen threshold range
    • If region leaks: decrease tolerances/multiplier or narrow threshold range
    • Place additional seed points to segment multiple regions

Intensity Range Formula (Threshold Method)

Include voxel if: Ithreshold_minIvoxelIthreshold_max\text{Include voxel if: } I_{threshold\_min} \leq I_{voxel} \leq I_{threshold\_max}

where the voxel must also be connected (6 or 26 neighborhood) to the growing region.

Practical Example: Organ Segmentation

1. Load abdominal CT dataset
2. Open Dynamic Region Grow with Threshold method
3. Set threshold range (liver: 40-80 HU)
4. Left-click inside liver → liver mask created
5. Adjust threshold range and try again if needed
6. Enable Fill cavities to remove internal voids

Watershed Segmentation

Watershed segmentation separates touching or connected objects by treating the grayscale image as a topographic surface. It finds the ridges (watershed lines) where "water" would divide between different basins.

When to Use

  • Multiple objects are touching or nearly touching
  • Objects have similar intensity but need separation
  • You have a mask containing merged/connected objects
  • Objects have distinct centers but shared boundaries

How Watershed Works

The algorithm:

  1. Treats the grayscale image as elevation (intensity = height)
  2. Identifies local minima as starting points (catchment basins)
  3. Simulates "water flooding" from these points
  4. Draws watershed lines where water from different basins meets
  5. These lines define boundaries between separate objects

Step-by-Step Workflow

  1. Create initial segmentation:

    • Create a threshold mask containing the touching objects
    • Ensure all objects of interest are included in the mask
    • Optional: Apply morphological operations for better definition
  2. Open Watershed:

    • Navigate to Segmentation → Create Mask → Watershed
  3. Select target objects:

    • Target objects: Choose the mask(s) to process
      • Active Mask (current selection)
      • Selected Masks (multiple specific masks)
      • All Masks (all available masks)
  4. Configure connectivity:

    • Connectivity mode: Choose 6-connectivity (conservative) or 26-connectivity (inclusive)
  5. Adjust separation parameters:

    • Level (0.0 to 999.0, default: 1.0):
      • Controls the depth of segmentation hierarchy
      • Increase level: More aggressive separation (over-segmentation risk)
      • Decrease level: More conservative separation (under-segmentation risk)
      • Start with default (1.0) and adjust based on results
  6. Optional: Configure output and filtering:

    • Create a mask with multiple labels: Enable to get one multi-label mask instead of separate masks
    • Minimum object size: Remove fragments smaller than threshold (in voxels)
    • Remove objects that touch boundaries: Exclude incomplete objects at volume edges
  7. Click Apply:

    • The watershed transform processes the mask
    • Objects are separated along the watershed lines
  8. Review and iterate:

    • Check separation in all views
    • If over-segmented (too many splits): Decrease level value
    • If under-segmented (objects still connected): Increase level value
    • Adjust minimum size filter to remove noise
    • Re-apply as needed

Parameter Tuning Guide

ObservationAction
Objects still touchingIncrease level value
Too many small fragmentsDecrease level value or increase min size filter
Watershed lines in wrong placeAdjust level or apply smoothing before watershed
Incomplete objects at edgesEnable "Remove objects that touch boundaries"

Practical Example: Separating Vertebrae

1. Load CT spine dataset
2. Create bone mask via threshold (HU 200-3000)
3. Open Watershed with level = 1.0
4. Click Apply → vertebrae separated
5. If still touching: increase level to 2.0, re-apply
6. If over-segmented: decrease level to 0.5, re-apply
7. Optional: Enable \"Create multi-label mask\" for single output

GrowCut Segmentation

GrowCut uses a cellular automata approach where user-created seed masks compete to "grow" into unlabeled regions. Different seed labels expand based on intensity similarity and spatial proximity.

When to Use

  • You need interactive, fine-grained control over region growth
  • Objects have complex boundaries or low contrast
  • Multiple regions need simultaneous segmentation
  • Standard threshold or region growing produces poor results
  • You want to iteratively refine segmentation

Seed Preparation (Before GrowCut)

GrowCut requires existing mask objects with painted seed regions:

  1. Create seed masks (typically 2 or more):

    • Create Mask 1 (e.g., "Object_seeds")
    • Create Mask 2 (e.g., "Background_seeds")
    • Optionally create additional masks for multiple objects
  2. Paint seed regions using Edit Mask → Paint tool:

    • In Mask 1: Paint representative areas of your target structure
    • In Mask 2: Paint representative areas of background or other regions
    • Paint in key representative areas, not entire objects
    • Paint near boundaries to guide the algorithm
    • Each different label in the masks represents a separate seed region
  3. Key principles:

    • Minimum 2 different labels required
    • Each label grows independently based on intensity similarity
    • Seeds should be representative of their region's intensity
    • Place seeds throughout the region for better results
    • Avoid clustering all seeds in one area

Step-by-Step Workflow

  1. Prepare seed masks (as described above)

    • You need at least 2 mask objects with painted seeds
    • Each mask can contain multiple labels
    • Paint representative seed regions
  2. Open GrowCut:

    • Navigate to Segmentation → Create Mask → GrowCut
  3. Select seed mask objects:

    • Use the Seed mask object(s) checklist dropdown
    • Select all masks containing your seed regions
    • Multiple masks can be selected if seeds are in different masks
    • Each selected mask contributes its labels to the competition
  4. Configure seed parameters:

    • Seed locality (0.0 to 10.0, default: 0.0):
      • Controls how localized seed effects are
      • 0.0: Seeds influence throughout the image
      • Increase value: Reduces leakage into unwanted regions
      • Higher values require more even seed distribution
  5. Optional: Configure masking:

    • Enable Masking to restrict segmentation to a specific region
    • Select a mask object to segment within
    • GrowCut will only process voxels inside the masking object
  6. Optional: Configure threshold:

    • Enable Threshold to restrict segmentation to intensity range
    • Use histogram to set minimum and maximum values
    • GrowCut will only consider voxels within this range
  7. Configure output:

    • Target mask: Select where results will be stored
    • Mode: Choose Replace (default) or Merge
    • Multiple layer: Enable (default) for 3D; disable for 2D only
  8. Click Apply:

    • The cellular automata algorithm runs
    • Different seed labels compete for unlabeled voxels
    • Regions expand based on intensity similarity and distance
  9. Review and refine:

    • Check the segmentation in all views
    • If results are poor:
      • Go back and add more seeds to existing masks
      • Increase seed locality to reduce leaks
      • Adjust seed placement for better representation
      • Enable masking/threshold to restrict segmentation
    • Click Apply again to re-run with improved seeds

Seed Locality Guidance

SituationAction
Leaking into adjacent structuresIncrease seed locality (0.5-2.0)
Seeds too localized, poor growthDecrease seed locality or add more seeds
Uneven seed distributionIncrease seed locality and improve seed spacing

Practical Example: Segmenting Organs

1. Create "Liver_seeds" mask, paint liver areas
2. Create "Other_tissue_seeds" mask, paint surrounding areas
3. Open GrowCut, select both seed masks
4. Set seed locality = 0.5
5. Click Apply → liver segmented
6. If leaking: increase seed locality to 1.0, re-apply
7. If incomplete: add more seeds to liver_seeds, re-apply
8. Refine iteratively

LiveWire Segmentation

LiveWire provides semi-automatic boundary tracing by snapping to high-contrast edges. It combines user input with edge detection for precise boundary following.

When to Use

  • You need precise boundary following with complex shapes
  • Objects have clear, well-defined edges
  • Fully manual tracing would be too time-consuming
  • Automatic methods struggle with boundary definition

Step-by-Step Workflow

  1. Open Edit Mask:

    • Navigate to Segmentation → Operations → Edit Mask
  2. Select the LiveWire tool:

    • Click the LiveWire button in the mask editing tools
  3. Configure LiveWire parameters:

    • Curvature weight: Higher values favor smoother, more curved paths
    • Edge length weight: Higher values favor shorter paths
    • Adjust based on your image's characteristics
  4. Trace the boundary:

    • Left-click to set the starting anchor point
    • Move the mouse — the path snaps to nearby edges
    • Left-click again to place intermediate anchor points along the boundary
    • Continue around the object's perimeter
    • Right-click to close the contour
    • The enclosed region becomes part of the mask
  5. Refine the result:

    • LiveWire works best on high-contrast edges
    • Place anchor points at corners or where auto-path deviates
    • The algorithm snaps to nearby edge features
    • Multiple passes can refine the boundary
LiveWire Technique

Place anchor points at corners, shape transitions, and wherever the automatic path diverges from the desired boundary. The tool works best on edges with good contrast.


Voids and Inclusions Detection

Voids and Inclusions detection identifies internal features (defects or particles) within objects using grayscale intensity analysis. It finds regions that differ significantly from surrounding material based on contrast analysis.

When to Use

  • Detecting manufacturing defects (air bubbles, porosity, cracks)
  • Finding foreign particles or contaminants
  • Identifying calcifications or dense regions in soft tissue
  • Quality control and inspection applications
  • Material defect analysis

Detection Methods

Choose a detection mode:

Void Detection:

  • Identifies regions with lower intensity than surrounding material
  • Examples: air pockets, porosity, internal gaps

Inclusion Detection:

  • Identifies regions with higher intensity than surrounding material
  • Examples: dense particles, foreign objects, calcifications

Choose a contrast analysis method:

Absolute Method:

  • Uses fixed intensity threshold for defect detection
  • Best when you know the specific intensity threshold
  • Can auto-estimate with "Auto absolute contrast"

Relative Method:

  • Uses percentage difference from local mean intensity
  • Best for materials with varying baseline intensity
  • Expressed as percentage (0-100%)

Step-by-Step Workflow

  1. Load volume data:

    • Ensure the target volume is active
    • Volume should contain the objects to analyze
  2. Open Voids and Inclusions:

    • Navigate to Segmentation → Create Mask → Voids and Inclusions
  3. Select target volumes:

    • Target object(s):
      • Active Volume (current selection)
      • Selected Volumes (specific volumes)
      • Visible Volumes (visible in viewport)
      • All Volumes (all available)
  4. Configure analysis type:

    • Mode: Choose Void (low intensity) or Inclusion (high intensity)
    • Method: Choose Absolute (fixed threshold) or Relative (percentage-based)
  5. Set analysis parameters:

    • For Absolute method:
      • Set Absolute contrast value (intensity threshold)
      • Or enable Auto absolute contrast for automatic estimation
    • For Relative method:
      • Set Relative contrast (%) (default: 20%)
    • Air gray value: Reference intensity for background (or enable auto)
  6. Optional: Configure ROI masking:

    • Enable ROI Mask to analyze within specific region
    • Select the Mask object to confine analysis
    • Only voxels inside the mask will be analyzed
  7. Optional: Configure advanced filtering:

    • Expand Filter Result section for advanced options
    • Size filters: Set minimum and maximum size (in volume or voxels)
    • Shape filters: Compactness and sphericity ranges
    • Volume fraction range: Filter by defect percentage
    • Equivalent diameter range: Filter by defect sphere size
    • Maximum count: Limit number of detected defects
  8. Click Apply:

    • The algorithm analyzes the volume for defects
    • Detected voids/inclusions are marked in output mask
  9. Review and refine:

    • Examine detected defects in views
    • If too many small defects detected: increase minimum size filter
    • If missing large defects: adjust contrast settings
    • If too many detections: refine shape or size filters
    • Re-apply with adjusted parameters

Method Selection Guide

ScenarioRecommended Method
Know exact intensity thresholdAbsolute with fixed value
Materials with varying baselineRelative with percentage
Want automatic detectionAbsolute with auto-contrast
Need high sensitivityLower absolute contrast value
Need to eliminate noiseIncrease minimum size filter

Practical Example: CT Inspection

1. Load industrial CT scan of cast part
2. Open Voids and Inclusions
3. Select mode: Void, method: Absolute
4. Enable "Auto absolute contrast"
5. Set minimum size: 8 voxels (eliminate noise)
6. Click Apply → air pockets detected
7. Review in 3D → defects highlighted
8. Export results for quality report

Split Mask

Automatically separate all disconnected components in a mask into individual regions.

When to Use

  • You have a mask with multiple disconnected objects
  • You want each object as a separate mask
  • You need to analyze individual components separately

Step-by-Step Workflow

  1. Select the mask containing multiple disconnected objects
  2. Navigate to Segmentation → Operations → Split Mask
  3. Configure connectivity:
    • Connectivity: Choose 6-connectivity (conservative) or 26-connectivity (inclusive)
  4. Optional: Configure filtering:
    • Number of largest regions: Separate only the biggest components
    • Other size-based filters as needed
  5. Click Apply
  6. Individual masks are created for each disconnected component

This is useful after threshold segmentation when you want each object as a separate mask for individual analysis.


Filter Regions

Remove unwanted small or large regions from masks to clean up segmentation results.

When to Use

  • Removing noise or small fragments from segmentation
  • Keeping only large components
  • Cleaning threshold results

Step-by-Step Workflow

  1. Select the mask to filter
  2. Navigate to Segmentation → Operations → Filter Regions
  3. Configure filtering criteria:
    • Keep largest only: Retain only the single largest component
    • Number of largest regions: Retain only the top N largest components
    • Minimum region size: Remove regions smaller than this threshold (in voxels)
  4. Click Apply
  5. Filtered mask is created with unwanted regions removed

Practical Exercise: Separating Vertebrae

This exercise demonstrates separating touching structures using multiple region-based techniques.

Part 1: Initial Segmentation

  1. Load a CT spine dataset
  2. Navigate to Segmentation → Threshold
  3. Set thresholds to capture all vertebrae:
    • Range: approximately 200-3000 HU
    • Enable Filter regions to remove small noise
    • Set Minimum region size: 100 voxels
  4. Apply to create combined bone mask (all vertebrae together)

Part 2: Method 1 - Region Grow (Extract Single Vertebra)

  1. Navigate to Segmentation → Create Mask → Region Grow
  2. Set Connectivity: 6-connected (conservative)
  3. Set Target mask: Create new "Vertebra_L1"
  4. Set Mode: Replace
  5. Left-click on one specific vertebra in a slice view
  6. The single vertebra is isolated in the new mask
  7. Repeat for additional vertebrae (L2, L3, etc.)
  8. Result: Individual vertebra masks via manual extraction

Part 2: Alternative Method - Watershed (Automatic Separation)

  1. Start with the combined bone mask from Part 1
  2. Navigate to Segmentation → Create Mask → Watershed
  3. Set Connectivity mode: 6-connected
  4. Set Level: 1.0 (start with default)
  5. Optional: Enable Create a mask with multiple labels for single output
  6. Click Apply
  7. Vertebrae are automatically separated along watershed lines
  8. Review results:
    • If vertebrae still touching: increase Level to 2.0, re-apply
    • If over-segmented: decrease Level to 0.5, re-apply
  9. Result: All vertebrae separated into individual masks

Part 3: Analysis

  1. Verify separation quality in all views (axial, sagittal, coronal)
  2. Use individual vertebra masks for:
    • Measurement and statistical analysis
    • Surface generation for surgical planning
    • Individual volumetric assessment
    • Fracture or degeneration analysis

Comparison of Methods

MethodApproachBest For
Region GrowManual extraction with seed pointsPrecise control, one structure at a time
WatershedAutomatic separation using topographyAll objects at once, less manual effort
Split MaskAutomatic component separationDisconnected objects, quality filtering

Choosing the Right Method

ScenarioRecommended MethodReason
Isolate one object from many connected objectsRegion GrowDirect extraction with seed point
Segment based on uniform intensityDynamic Region Grow (Threshold method)Intensity range-based growth
Segment with varying statistical intensityDynamic Region Grow (Connectivity method)Statistical similarity-based
Separate touching or nearly touching objectsWatershedAutomatic topographic separation
Complex boundaries with interactive controlGrowCutSeed-based competitive growth
Precise boundary following on clear edgesLiveWireSnap-to-edge tracing
Remove small noise fragmentsFilter RegionsSize-based cleanup
Separate all disconnected componentsSplit MaskAutomatic component isolation
Detect internal defects or particlesVoids and InclusionsContrast-based detection
Multiple objects, minimal manual effortWatershedFully automatic separation

Troubleshooting

Region Grow Issues

IssueSolution
Region grows too much (leaks)Decrease tolerance; try 6-connectivity; use manual editing to break bridges
Region stops too earlyIncrease tolerance; use multiple seed points; check input data quality
Connectivity mode ineffectiveTry opposite connectivity setting; may need preprocessing

Dynamic Region Grow Issues

IssueSolution
Region too small (threshold method)Widen threshold range (min/max values)
Region too small (connectivity method)Increase multiplier value
Region leaks into adjacent structuresNarrow threshold range or decrease multiplier
Too many iterations affecting qualityReduce number of iterations; check initial parameters

Watershed Issues

IssueSolution
Objects still touching (under-segmented)Increase level value (try 2.0, 3.0, etc.)
Too many fragments (over-segmented)Decrease level value (try 0.5, 0.25, etc.)
Watershed lines in wrong locationAdjust level; apply smoothing before watershed
Poor separation qualityEnable minimum size filter to remove fragments

GrowCut Issues

IssueSolution
Leaking into adjacent regionsIncrease seed locality (try 0.5-2.0)
Poor segmentation qualityAdd more seed regions in key areas; improve seed distribution
Incomplete segmentationAdd additional seeds to sparse areas; refine seed placement
Incorrect label assignmentAdjust seed locality; add more background seeds

General Region-Based Segmentation Issues

IssueSolution
Noisy segmentation resultsApply smoothing or filtering before segmentation
Holes in the segmentationEnable "Fill cavities" in Dynamic Region Grow
Boundary artifactsRefine seeds or thresholds; use Edit Mask for manual cleanup
Slow processingReduce data size via cropping; optimize parameters

Scripting Region-Based Segmentation

Region Grow with Scripting

import ScriptingApi as api

app = api.Application()
mask_operations = app.get_mask_operations()

# Perform region grow on an existing mask
region_grow_segmentation_params = api.RegionGrowSegmentationParams()
region_grow_segmentation_params.source_mask_name = "BoneMask"
region_grow_segmentation_params.fully_connected = False # 6-connectivity
region_grow_segmentation_params.multiple_layer = True
region_grow_segmentation_params.seeds = [[-24, 8, 1864]] # X, Y, Z coordinates

try:
result_mask = mask_operations.region_grow("CT_Volume", region_grow_segmentation_params)
print(f"Isolated region created: {result_mask}")
except Exception as e:
print(f"Region grow failed: {e}")

Dynamic Region Grow with Scripting

import ScriptingApi as api

app = api.Application()
mask_operations = app.get_mask_operations()
volume_operations = app.get_volume_operations()

# Threshold-based dynamic region grow
dynamic_region_grow_threshold_segmentation_params = api.DynamicRegionGrowThresholdSegmentationParams()
dynamic_region_grow_threshold_segmentation_params.lower_threshold = 200 # Lower intensity bound
dynamic_region_grow_threshold_segmentation_params.upper_threshold = 3000 # Upper intensity bound
dynamic_region_grow_threshold_segmentation_params.fully_connected = False # 6-connectivity
dynamic_region_grow_threshold_segmentation_params.multiple_layer = True
dynamic_region_grow_threshold_segmentation_params.fill_cavities = True
dynamic_region_grow_threshold_segmentation_params.seeds = [[-24, 8, 1864]] # X, Y, Z

try:
result_mask = mask_operations.dynamic_region_grow_threshold("LiverVolume", dynamic_region_grow_threshold_segmentation_params)
print(f"Segmented region: {result_mask}")
except Exception as e:
print(f"Dynamic region grow failed: {e}")

Watershed with Scripting

import ScriptingApi as api

app = api.Application()
mask_operations = app.get_mask_operations()

# Watershed segmentation for object separation
try:
result_masks = mask_operations.watershed_segmentation(
["BoneMask"],
2.0, # Level to control segmentation depth
100, # Min. object size to retain (Voxels)
False,
True, # Output a multi‑label mask
False
)
print(f"Separated regions: {len(result_masks)} objects")
for i, mask in enumerate(result_masks):
print(f" Object {i}: {mask}")
except Exception as e:
print(f"Watershed failed: {e}")

Next Steps

Continue your learning with:


See Also