CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-itk

Insight Toolkit for N-dimensional image processing, segmentation, and registration in medical and scientific applications

Pending
Overview
Eval results
Files

level-sets.mddocs/reference/segmentation/

Level Set Segmentation

Level set methods for segmentation including geodesic active contours, shape detection, and threshold-based approaches.

Capabilities

Geodesic Active Contours

class GeodesicActiveContourLevelSetImageFilter:
    """
    Geodesic active contour level set segmentation.
    
    Template parameters:
    - input_image_type: Input image type (feature image)
    - output_image_type: Output image type (level set)
    """
    
    def SetFeatureImage(self, image):
        """Set the feature image (edge potential)."""
    
    def SetPropagationScaling(self, scaling):
        """
        Set propagation scaling.
        
        Parameters:
        - scaling: float - Propagation weight
        """
    
    def SetCurvatureScaling(self, scaling):
        """Set curvature scaling (smoothness)."""
    
    def SetAdvectionScaling(self, scaling):
        """Set advection scaling."""
    
    def SetNumberOfIterations(self, iterations):
        """Set number of iterations."""
    
    def SetMaximumRMSError(self, error):
        """Set convergence criterion."""

Shape Detection

class ShapeDetectionLevelSetImageFilter:
    """
    Shape detection level set filter.
    
    Template parameters:
    - input_image_type: Input image type
    - output_image_type: Output image type
    """
    
    def SetFeatureImage(self, image):
        """Set the feature image."""
    
    def SetPropagationScaling(self, scaling):
        """Set propagation scaling."""
    
    def SetCurvatureScaling(self, scaling):
        """Set curvature scaling."""
    
    def SetNumberOfIterations(self, iterations):
        """Set number of iterations."""

Threshold Level Set

class ThresholdSegmentationLevelSetImageFilter:
    """
    Threshold-based level set segmentation.
    
    Template parameters:
    - input_image_type: Input image type
    - feature_image_type: Feature image type
    """
    
    def SetFeatureImage(self, image):
        """Set the feature image."""
    
    def SetUpperThreshold(self, threshold):
        """Set upper intensity threshold."""
    
    def SetLowerThreshold(self, threshold):
        """Set lower intensity threshold."""
    
    def SetCurvatureScaling(self, scaling):
        """Set curvature scaling."""
    
    def SetPropagationScaling(self, scaling):
        """Set propagation scaling."""
    
    def SetNumberOfIterations(self, iterations):
        """Set number of iterations."""

Canny Segmentation Level Set

class CannySegmentationLevelSetImageFilter:
    """
    Canny edge-based level set segmentation.
    
    Template parameters:
    - input_image_type: Input image type
    - feature_image_type: Feature image type
    """
    
    def SetFeatureImage(self, image):
        """Set the feature image."""
    
    def SetThreshold(self, threshold):
        """Set Canny edge threshold."""
    
    def SetVariance(self, variance):
        """Set Gaussian smoothing variance."""
    
    def SetCurvatureScaling(self, scaling):
        """Set curvature scaling."""
    
    def SetPropagationScaling(self, scaling):
        """Set propagation scaling."""

Usage Examples

Geodesic Active Contours

import itk

# Load image
image = itk.imread('input.png', itk.F)

# Compute edge potential (feature image)
gradient = itk.gradient_magnitude_recursive_gaussian_image_filter(image, sigma=1.0)
sigmoid = itk.sigmoid_image_filter(gradient, alpha=-1.0, beta=128.0, output_minimum=0.0, output_maximum=1.0)

# Create initial level set (e.g., from seeds)
initial = itk.imread('initial_contour.png', itk.F)

# Set up level set filter
ImageType = itk.Image[itk.F, 2]
level_set = itk.GeodesicActiveContourLevelSetImageFilter[ImageType, ImageType].New()
level_set.SetInput(initial)
level_set.SetFeatureImage(sigmoid)
level_set.SetPropagationScaling(1.0)
level_set.SetCurvatureScaling(1.0)
level_set.SetAdvectionScaling(1.0)
level_set.SetNumberOfIterations(100)
level_set.SetMaximumRMSError(0.02)

level_set.Update()
result = level_set.GetOutput()

# Threshold level set to get binary result
binary = itk.binary_threshold_image_filter(result, lower_threshold=0.0, inside_value=255, outside_value=0)
itk.imwrite(binary, 'segmented.png')

Install with Tessl CLI

npx tessl i tessl/pypi-itk@5.4.1

docs

index.md

tile.json