0
# Segmentation
1
2
Comprehensive image segmentation techniques including thresholding, region growing, level sets, and watershed methods for extracting anatomical structures and regions of interest.
3
4
## Capabilities
5
6
### Thresholding Methods
7
8
Basic and advanced thresholding for binary and multi-level segmentation.
9
10
```python { .api }
11
def BinaryThreshold(image: Image, lowerThreshold: float = 0.0,
12
upperThreshold: float = 255.0, insideValue: int = 1,
13
outsideValue: int = 0) -> Image:
14
"""
15
Binary thresholding segmentation
16
17
Args:
18
image: Input image
19
lowerThreshold: Lower intensity threshold
20
upperThreshold: Upper intensity threshold
21
insideValue: Value for pixels within threshold range
22
outsideValue: Value for pixels outside threshold range
23
24
Returns:
25
Binary segmented image
26
"""
27
28
def OtsuThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0,
29
numberOfHistogramBins: int = 128, maskValue: int = 255,
30
maskImage: Image = None) -> Image:
31
"""
32
Otsu automatic thresholding
33
34
Args:
35
image: Input image
36
insideValue: Value for foreground pixels
37
outsideValue: Value for background pixels
38
numberOfHistogramBins: Number of histogram bins for threshold computation
39
maskValue: Value in mask image to consider
40
maskImage: Optional mask to restrict threshold computation
41
42
Returns:
43
Binary segmented image using optimal threshold
44
"""
45
46
def TriangleThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0,
47
numberOfHistogramBins: int = 256) -> Image:
48
"""
49
Triangle method automatic thresholding
50
51
Args:
52
image: Input image
53
insideValue: Value for foreground pixels
54
outsideValue: Value for background pixels
55
numberOfHistogramBins: Number of histogram bins
56
57
Returns:
58
Binary segmented image using triangle method
59
"""
60
61
def LiThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0,
62
numberOfHistogramBins: int = 256) -> Image:
63
"""
64
Li's minimum cross entropy automatic thresholding
65
66
Args:
67
image: Input image
68
insideValue: Value for foreground pixels
69
outsideValue: Value for background pixels
70
numberOfHistogramBins: Number of histogram bins
71
72
Returns:
73
Binary segmented image using Li's method
74
"""
75
76
def MultipleThreshold(image: Image, numberOfThresholds: int = 1,
77
labelOffset: int = 0, numberOfHistogramBins: int = 256,
78
valleyEmphasis: bool = False) -> Image:
79
"""
80
Multi-level thresholding using multiple algorithms
81
82
Args:
83
image: Input image
84
numberOfThresholds: Number of threshold levels
85
labelOffset: Starting label value
86
numberOfHistogramBins: Number of histogram bins
87
valleyEmphasis: Emphasize valleys in histogram
88
89
Returns:
90
Multi-label segmented image
91
"""
92
```
93
94
**Usage Examples:**
95
96
```python
97
import SimpleITK as sitk
98
99
# Load grayscale image
100
image = sitk.ReadImage('brain_mri.nii')
101
102
# Basic binary thresholding
103
binary_seg = sitk.BinaryThreshold(image,
104
lowerThreshold=50,
105
upperThreshold=200,
106
insideValue=255,
107
outsideValue=0)
108
109
# Automatic Otsu thresholding
110
otsu_seg = sitk.OtsuThreshold(image)
111
112
# Get the computed threshold value
113
otsu_filter = sitk.OtsuThresholdImageFilter()
114
otsu_filter.Execute(image)
115
threshold_value = otsu_filter.GetThreshold()
116
print(f"Otsu threshold: {threshold_value}")
117
118
# Multi-level segmentation
119
multi_seg = sitk.MultipleThreshold(image, numberOfThresholds=3)
120
121
# Display results
122
sitk.Show(image, "Original")
123
sitk.Show(binary_seg, "Binary Threshold")
124
sitk.Show(otsu_seg, "Otsu Threshold")
125
sitk.Show(multi_seg, "Multi-level")
126
```
127
128
### Region Growing Methods
129
130
Seed-based region growing for connected component segmentation.
131
132
```python { .api }
133
def ConnectedThreshold(image: Image, seedList: list, lower: float = 0,
134
upper: float = 1, replaceValue: int = 1) -> Image:
135
"""
136
Connected component segmentation with intensity thresholds
137
138
Args:
139
image: Input image
140
seedList: List of seed points as [(x,y), (x,y,z), ...]
141
lower: Lower intensity threshold for region growing
142
upper: Upper intensity threshold for region growing
143
replaceValue: Value to assign to segmented region
144
145
Returns:
146
Binary image with segmented connected component
147
"""
148
149
def NeighborhoodConnected(image: Image, seedList: list, lower: float = 0,
150
upper: float = 1, radius: list = [1, 1, 1],
151
replaceValue: int = 1) -> Image:
152
"""
153
Neighborhood connected region growing
154
155
Args:
156
image: Input image
157
seedList: List of seed points
158
lower: Lower intensity threshold
159
upper: Upper intensity threshold
160
radius: Neighborhood radius per dimension
161
replaceValue: Value for segmented region
162
163
Returns:
164
Binary segmented image
165
"""
166
167
def VectorConnectedComponent(image: Image, seedList: list,
168
distanceThreshold: float = 1.0,
169
replaceValue: int = 1) -> Image:
170
"""
171
Connected component segmentation for vector images
172
173
Args:
174
image: Input vector image
175
seedList: List of seed points
176
distanceThreshold: Maximum distance for region inclusion
177
replaceValue: Value for segmented region
178
179
Returns:
180
Binary segmented image
181
"""
182
183
def ConfidenceConnected(image: Image, seedList: list, numberOfIterations: int = 4,
184
multiplier: float = 2.5, initialNeighborhoodRadius: int = 1,
185
replaceValue: int = 1) -> Image:
186
"""
187
Confidence connected region growing using statistical criteria
188
189
Args:
190
image: Input image
191
seedList: List of seed points
192
numberOfIterations: Number of growing iterations
193
multiplier: Standard deviation multiplier for threshold
194
initialNeighborhoodRadius: Initial neighborhood radius
195
replaceValue: Value for segmented region
196
197
Returns:
198
Binary segmented image
199
"""
200
```
201
202
**Usage Examples:**
203
204
```python
205
import SimpleITK as sitk
206
207
# Load image
208
image = sitk.ReadImage('liver_ct.nii')
209
210
# Define seed points (x, y, z coordinates)
211
seeds = [(145, 200, 50), (150, 205, 52)]
212
213
# Connected threshold segmentation
214
connected_seg = sitk.ConnectedThreshold(image,
215
seedList=seeds,
216
lower=100,
217
upper=200,
218
replaceValue=255)
219
220
# Neighborhood connected with larger radius
221
neighborhood_seg = sitk.NeighborhoodConnected(image,
222
seedList=seeds,
223
lower=80,
224
upper=220,
225
radius=[2, 2, 1],
226
replaceValue=255)
227
228
# Confidence connected (adaptive thresholds)
229
confidence_seg = sitk.ConfidenceConnected(image,
230
seedList=seeds,
231
numberOfIterations=5,
232
multiplier=2.0,
233
replaceValue=255)
234
235
# Compare segmentation methods
236
sitk.Show(image, "Original CT")
237
sitk.Show(connected_seg, "Connected Threshold")
238
sitk.Show(confidence_seg, "Confidence Connected")
239
```
240
241
### Level Set Methods
242
243
Advanced level set segmentation for complex boundary extraction.
244
245
```python { .api }
246
def GeodesicActiveContour(featureImage: Image, initialLevelSet: Image,
247
propagationScaling: float = 1.0, curvatureScaling: float = 1.0,
248
advectionScaling: float = 1.0, maximumRMSError: float = 0.02,
249
numberOfIterations: int = 1000) -> Image:
250
"""
251
Geodesic active contour level set segmentation
252
253
Args:
254
featureImage: Feature image (edge map)
255
initialLevelSet: Initial level set (distance map)
256
propagationScaling: Balloon force strength
257
curvatureScaling: Smoothness constraint strength
258
advectionScaling: Edge attraction strength
259
maximumRMSError: Convergence criterion
260
numberOfIterations: Maximum iterations
261
262
Returns:
263
Final level set function
264
"""
265
266
def ShapeDetectionLevelSet(featureImage: Image, initialLevelSet: Image,
267
propagationScaling: float = 1.0, curvatureScaling: float = 1.0,
268
maximumRMSError: float = 0.02, numberOfIterations: int = 1000) -> Image:
269
"""
270
Shape detection level set segmentation
271
272
Args:
273
featureImage: Feature image (speed function)
274
initialLevelSet: Initial level set
275
propagationScaling: Propagation force scaling
276
curvatureScaling: Curvature regularization
277
maximumRMSError: Convergence tolerance
278
numberOfIterations: Maximum iterations
279
280
Returns:
281
Evolved level set
282
"""
283
284
def ThresholdSegmentationLevelSet(featureImage: Image, initialLevelSet: Image,
285
lowerThreshold: float = 0, upperThreshold: float = 255,
286
curvatureScaling: float = 1.0, propagationScaling: float = 1.0,
287
numberOfIterations: int = 1000) -> Image:
288
"""
289
Threshold-based level set segmentation
290
291
Args:
292
featureImage: Input image for threshold-based speed
293
initialLevelSet: Initial level set
294
lowerThreshold: Lower intensity threshold
295
upperThreshold: Upper intensity threshold
296
curvatureScaling: Smoothness constraint
297
propagationScaling: Propagation force scaling
298
numberOfIterations: Maximum iterations
299
300
Returns:
301
Final level set segmentation
302
"""
303
304
def FastMarching(trialPoints: Image, speed: Image = None,
305
normalizeAcrossScale: bool = False, stoppingValue: float = 1e30) -> Image:
306
"""
307
Fast marching method for front propagation
308
309
Args:
310
trialPoints: Initial front positions (seed points)
311
speed: Speed function image (optional, uses uniform speed if None)
312
normalizeAcrossScale: Normalize speed across scale space
313
stoppingValue: Stop when front reaches this value
314
315
Returns:
316
Time-arrival function (distance map)
317
"""
318
```
319
320
**Usage Examples:**
321
322
```python
323
import SimpleITK as sitk
324
import numpy as np
325
326
# Load image
327
image = sitk.ReadImage('tumor_mri.nii')
328
329
# Preprocessing for level sets
330
smooth_image = sitk.CurvatureAnisotropicDiffusion(image,
331
timeStep=0.0625,
332
numberOfIterations=5,
333
conductanceParameter=3.0)
334
335
# Create feature image (edge map)
336
gradient_mag = sitk.GradientMagnitudeRecursiveGaussian(smooth_image, sigma=2.0)
337
feature_image = sitk.Sigmoid(gradient_mag, alpha=-0.5, beta=3.0, outputMaximum=1.0)
338
339
# Create initial level set (distance map from seed)
340
seed_image = sitk.Image(image.GetSize(), sitk.sitkFloat32)
341
seed_image.CopyInformation(image)
342
seed_image[100, 100, 50] = -5.0 # Initial contour
343
initial_levelset = sitk.SignedMaurerDistanceMap(seed_image,
344
insideIsPositive=False,
345
useImageSpacing=True)
346
347
# Geodesic active contour segmentation
348
segmentation = sitk.GeodesicActiveContour(featureImage=feature_image,
349
initialLevelSet=initial_levelset,
350
propagationScaling=1.0,
351
curvatureScaling=0.5,
352
advectionScaling=1.0,
353
numberOfIterations=500)
354
355
# Extract zero level set (final contour)
356
binary_result = sitk.BinaryThreshold(segmentation,
357
lowerThreshold=-1000.0,
358
upperThreshold=0.0,
359
insideValue=1,
360
outsideValue=0)
361
362
# Display results
363
sitk.Show(image, "Original")
364
sitk.Show(feature_image, "Feature Image")
365
sitk.Show(binary_result, "Level Set Result")
366
```
367
368
### Watershed Segmentation
369
370
Watershed-based segmentation for separating touching objects.
371
372
```python { .api }
373
def MorphologicalWatershed(image: Image, level: float = 0.0, markWatershedLine: bool = True,
374
fullyConnected: bool = False) -> Image:
375
"""
376
Morphological watershed segmentation
377
378
Args:
379
image: Input image (typically gradient magnitude)
380
level: Noise level threshold
381
markWatershedLine: Mark watershed boundaries
382
fullyConnected: Use 26-connectivity (3D) or 8-connectivity (2D)
383
384
Returns:
385
Labeled watershed regions
386
"""
387
388
def WatershedImageFilter(image: Image, level: float = 0.0, fullyConnected: bool = False) -> Image:
389
"""
390
Basic watershed transformation
391
392
Args:
393
image: Input image
394
level: Minimum depth threshold
395
fullyConnected: Connectivity type
396
397
Returns:
398
Watershed labeled image
399
"""
400
401
def MorphologicalWatershedFromMarkers(image: Image, markers: Image,
402
markWatershedLine: bool = True,
403
fullyConnected: bool = False) -> Image:
404
"""
405
Marker-controlled watershed segmentation
406
407
Args:
408
image: Input image (gradient magnitude)
409
markers: Marker image with seed regions
410
markWatershedLine: Mark watershed boundaries
411
fullyConnected: Connectivity type
412
413
Returns:
414
Labeled segmentation based on markers
415
"""
416
```
417
418
**Usage Examples:**
419
420
```python
421
import SimpleITK as sitk
422
423
# Load image with touching objects
424
image = sitk.ReadImage('cells.tif')
425
426
# Preprocessing for watershed
427
smooth = sitk.Median(image, radius=[2, 2])
428
gradient = sitk.GradientMagnitude(smooth)
429
430
# Basic watershed
431
watershed_basic = sitk.MorphologicalWatershed(gradient,
432
level=0.01,
433
markWatershedLine=True)
434
435
# Marker-controlled watershed
436
# Create markers from local minima
437
h_minima = sitk.HMinimaImageFilter()
438
h_minima.SetHeight(20)
439
minima = h_minima.Execute(sitk.InvertIntensity(smooth))
440
441
# Connected component labeling of minima
442
markers = sitk.ConnectedComponent(minima)
443
444
# Apply marker-controlled watershed
445
watershed_markers = sitk.MorphologicalWatershedFromMarkers(gradient,
446
markers=markers,
447
markWatershedLine=True)
448
449
# Display results
450
sitk.Show(image, "Original")
451
sitk.Show(watershed_basic, "Basic Watershed")
452
sitk.Show(watershed_markers, "Marker Watershed")
453
```
454
455
### Connected Components and Labeling
456
457
Connected component analysis for object identification and labeling.
458
459
```python { .api }
460
def ConnectedComponent(image: Image, fullyConnected: bool = False) -> Image:
461
"""
462
Connected component labeling
463
464
Args:
465
image: Binary input image
466
fullyConnected: Use full connectivity (26-conn 3D, 8-conn 2D)
467
468
Returns:
469
Labeled image with unique labels for each component
470
"""
471
472
def RelabelComponent(labelImage: Image, minimumObjectSize: int = 0,
473
sortByObjectSize: bool = True) -> Image:
474
"""
475
Relabel connected components by size
476
477
Args:
478
labelImage: Input labeled image
479
minimumObjectSize: Remove components smaller than this
480
sortByObjectSize: Sort labels by component size
481
482
Returns:
483
Relabeled image with size-based ordering
484
"""
485
486
def LabelShapeStatistics(labelImage: Image, intensityImage: Image = None) -> dict:
487
"""
488
Compute shape statistics for labeled regions
489
490
Args:
491
labelImage: Labeled segmentation image
492
intensityImage: Optional intensity image for intensity statistics
493
494
Returns:
495
Dictionary of shape and intensity statistics per label
496
"""
497
```
498
499
**Usage Examples:**
500
501
```python
502
import SimpleITK as sitk
503
504
# Load binary image
505
binary_image = sitk.ReadImage('binary_objects.png')
506
507
# Connected component labeling
508
labels = sitk.ConnectedComponent(binary_image, fullyConnected=False)
509
510
# Remove small components and relabel by size
511
cleaned_labels = sitk.RelabelComponent(labels,
512
minimumObjectSize=100,
513
sortByObjectSize=True)
514
515
# Compute shape statistics
516
shape_filter = sitk.LabelShapeStatisticsImageFilter()
517
shape_filter.Execute(cleaned_labels)
518
519
print(f"Number of objects: {shape_filter.GetNumberOfLabels()}")
520
for label in shape_filter.GetLabels():
521
area = shape_filter.GetPhysicalSize(label)
522
centroid = shape_filter.GetCentroid(label)
523
bbox = shape_filter.GetBoundingBox(label)
524
print(f"Label {label}: Area={area:.2f}, Centroid={centroid}")
525
526
# Create colored labels for visualization
527
colored_labels = sitk.LabelToRGB(cleaned_labels)
528
```
529
530
## Advanced Segmentation Patterns
531
532
### Multi-Modal Segmentation
533
534
```python
535
import SimpleITK as sitk
536
537
def multimodal_brain_segmentation(t1_image, t2_image, flair_image):
538
"""Multi-modal brain tissue segmentation"""
539
540
# Register images to T1 space
541
t2_registered = sitk.Registration(t1_image, t2_image)
542
flair_registered = sitk.Registration(t1_image, flair_image)
543
544
# Create feature vector image
545
vector_image = sitk.Compose(t1_image, t2_registered, flair_registered)
546
547
# Vector-based connected component segmentation
548
seeds = [(120, 140, 80)] # CSF seed
549
csf_seg = sitk.VectorConnectedComponent(vector_image,
550
seedList=seeds,
551
distanceThreshold=50.0)
552
553
# Tissue-specific thresholding
554
gm_mask = sitk.And(
555
sitk.BinaryThreshold(t1_image, 50, 120),
556
sitk.BinaryThreshold(t2_image, 80, 180)
557
)
558
559
wm_mask = sitk.And(
560
sitk.BinaryThreshold(t1_image, 120, 200),
561
sitk.BinaryThreshold(t2_image, 60, 120)
562
)
563
564
return csf_seg, gm_mask, wm_mask
565
566
# Apply multi-modal segmentation
567
t1 = sitk.ReadImage('t1.nii')
568
t2 = sitk.ReadImage('t2.nii')
569
flair = sitk.ReadImage('flair.nii')
570
571
csf, gray_matter, white_matter = multimodal_brain_segmentation(t1, t2, flair)
572
```
573
574
### Iterative Refinement
575
576
```python
577
import SimpleITK as sitk
578
579
def iterative_tumor_segmentation(image, initial_seeds, num_iterations=3):
580
"""Iterative refinement of tumor segmentation"""
581
582
current_seg = None
583
584
for iteration in range(num_iterations):
585
if iteration == 0:
586
# Initial segmentation
587
current_seg = sitk.ConfidenceConnected(image,
588
seedList=initial_seeds,
589
numberOfIterations=4,
590
multiplier=2.5)
591
else:
592
# Refine based on previous result
593
# Extract boundary for next iteration seeds
594
boundary = sitk.BinaryMorphologicalOpening(current_seg, [3, 3, 1])
595
596
# Update segmentation with refined parameters
597
current_seg = sitk.ConfidenceConnected(image,
598
seedList=initial_seeds,
599
numberOfIterations=iteration + 3,
600
multiplier=2.5 - iteration * 0.3)
601
602
# Morphological refinement
603
current_seg = sitk.BinaryMorphologicalClosing(current_seg, [2, 2, 1])
604
605
return current_seg
606
607
# Apply iterative segmentation
608
image = sitk.ReadImage('tumor_scan.nii')
609
seeds = [(150, 180, 45)]
610
refined_seg = iterative_tumor_segmentation(image, seeds, num_iterations=3)
611
```
612
613
### Hybrid Methods
614
615
```python
616
import SimpleITK as sitk
617
import numpy as np
618
619
def hybrid_vessel_segmentation(image):
620
"""Hybrid approach combining multiple segmentation methods"""
621
622
# Method 1: Vesselness-based segmentation
623
vesselness = sitk.HessianRecursiveGaussian(image, sigma=1.5)
624
vessel_enhanced = sitk.UnaryFunctorImageFilter(vesselness,
625
lambda x: x if x > 0.1 else 0)
626
627
# Method 2: Multi-scale filtering + thresholding
628
scales = [0.5, 1.0, 2.0]
629
enhanced_scales = []
630
631
for sigma in scales:
632
smoothed = sitk.Gaussian(image, sigma=sigma)
633
hessian = sitk.HessianRecursiveGaussian(smoothed, sigma=sigma)
634
enhanced_scales.append(hessian)
635
636
# Combine scales
637
multi_scale = enhanced_scales[0]
638
for enhanced in enhanced_scales[1:]:
639
multi_scale = sitk.Maximum(multi_scale, enhanced)
640
641
# Method 3: Region growing from automatic seeds
642
otsu_seeds = sitk.OtsuThreshold(image)
643
seed_points = extract_seed_points(otsu_seeds) # Custom function
644
645
region_grown = sitk.ConnectedThreshold(image,
646
seedList=seed_points,
647
lower=100, upper=300)
648
649
# Combine methods using voting
650
combined = sitk.Add(sitk.Cast(vessel_enhanced > 0.1, sitk.sitkUInt8),
651
sitk.Cast(multi_scale > 0.05, sitk.sitkUInt8))
652
combined = sitk.Add(combined, sitk.Cast(region_grown > 0, sitk.sitkUInt8))
653
654
# Final segmentation: majority vote
655
final_seg = sitk.BinaryThreshold(combined, 2, 3, 1, 0)
656
657
return final_seg
658
659
def extract_seed_points(binary_image):
660
"""Extract seed points from binary image"""
661
# Convert to numpy for processing
662
array = sitk.GetArrayFromImage(binary_image)
663
coords = np.where(array > 0)
664
665
# Sample subset of coordinates as seeds
666
indices = np.random.choice(len(coords[0]), size=min(50, len(coords[0])))
667
seed_points = [(int(coords[2][i]), int(coords[1][i]), int(coords[0][i]))
668
for i in indices]
669
670
return seed_points
671
672
# Apply hybrid segmentation
673
angiogram = sitk.ReadImage('vessels.nii')
674
vessel_seg = hybrid_vessel_segmentation(angiogram)
675
```
676
677
## Performance Optimization
678
679
### Memory-Efficient Processing
680
681
```python
682
import SimpleITK as sitk
683
684
def memory_efficient_segmentation(large_image_path, tile_size=(256, 256, 64)):
685
"""Process large images in tiles to manage memory"""
686
687
# Read image metadata without loading full image
688
reader = sitk.ImageFileReader()
689
reader.SetFileName(large_image_path)
690
reader.ReadImageInformation()
691
692
size = reader.GetSize()
693
spacing = reader.GetSpacing()
694
origin = reader.GetOrigin()
695
696
# Process in tiles
697
results = []
698
699
for z in range(0, size[2], tile_size[2]):
700
for y in range(0, size[1], tile_size[1]):
701
for x in range(0, size[0], tile_size[0]):
702
703
# Define region of interest
704
start = [x, y, z]
705
extract_size = [min(tile_size[0], size[0] - x),
706
min(tile_size[1], size[1] - y),
707
min(tile_size[2], size[2] - z)]
708
709
# Extract and process tile
710
extractor = sitk.ExtractImageFilter()
711
extractor.SetSize(extract_size)
712
extractor.SetIndex(start)
713
714
tile = extractor.Execute(reader.Execute())
715
716
# Segment tile
717
tile_seg = sitk.OtsuThreshold(tile)
718
719
# Store result with position info
720
results.append({
721
'segmentation': tile_seg,
722
'position': start,
723
'size': extract_size
724
})
725
726
# Reconstruct full segmentation
727
full_seg = sitk.Image(size, sitk.sitkUInt8)
728
full_seg.SetSpacing(spacing)
729
full_seg.SetOrigin(origin)
730
731
for result in results:
732
# Paste tile result back to full image
733
paster = sitk.PasteImageFilter()
734
paster.SetSourceSize(result['size'])
735
paster.SetSourceIndex([0, 0, 0])
736
paster.SetDestinationIndex(result['position'])
737
738
full_seg = paster.Execute(full_seg, result['segmentation'])
739
740
return full_seg
741
742
# Process large dataset efficiently
743
large_seg = memory_efficient_segmentation('huge_volume.nii')
744
```
745
746
## Type Definitions
747
748
```python { .api }
749
# Core Types
750
Image = sitk.Image
751
"""SimpleITK Image object representing n-dimensional medical images"""
752
753
PixelIDValueEnum = sitk.PixelIDValueEnum
754
"""Enumeration of pixel data types (sitkUInt8, sitkFloat32, etc.)"""
755
756
# Seed Point Types
757
SeedPoint = tuple[int, ...]
758
"""Seed point coordinates as (x, y) for 2D or (x, y, z) for 3D"""
759
760
SeedList = list[SeedPoint]
761
"""List of seed points for region growing algorithms"""
762
763
# Filter Parameter Types
764
ThresholdValue = float
765
"""Intensity threshold value for segmentation"""
766
767
IterationCount = int
768
"""Number of iterations for iterative algorithms"""
769
770
RadiusList = list[int]
771
"""Neighborhood radius per image dimension"""
772
773
# Statistics Types
774
LabelValue = int
775
"""Integer label identifier for segmented regions"""
776
777
ShapeStatistics = dict[str, float]
778
"""Dictionary containing shape measurements like area, perimeter, etc."""
779
780
ComponentStats = dict[LabelValue, ShapeStatistics]
781
"""Statistics dictionary keyed by component label"""
782
```