CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/cmake-simpleitk

SimpleITK is a simplified interface to the Insight Toolkit (ITK) for image registration and segmentation

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

filters.mddocs/

Image Processing Filters

SimpleITK provides 291 image processing filters covering mathematical operations, morphological operations, smoothing, edge detection, thresholding, segmentation, frequency domain processing, and statistical analysis. All filters are available as both classes and procedural functions for convenient usage.

Filter Usage Patterns

All filters follow consistent patterns:

# Procedural interface (recommended for simple usage)
def FilterName(input_image: Image, parameter1: type, parameter2: type, ...) -> Image:
    """Filter description"""

# Class interface (for advanced parameter control)
class FilterNameImageFilter:
    def __init__(self): ...
    def SetParameter1(self, value: type): ...
    def GetParameter1(self) -> type: ...
    def Execute(self, input_image: Image) -> Image: ...

Capabilities

Mathematical Operations

Pixel-wise mathematical operations between images or with scalar values.

# Binary operations
def Add(image1: Image, image2: Image) -> Image:
    """Add two images pixel-wise"""

def Subtract(image1: Image, image2: Image) -> Image:
    """Subtract second image from first pixel-wise"""

def Multiply(image1: Image, image2: Image) -> Image:
    """Multiply two images pixel-wise"""

def Divide(image1: Image, image2: Image) -> Image:
    """Divide first image by second pixel-wise"""

def Maximum(image1: Image, image2: Image) -> Image:
    """Pixel-wise maximum of two images"""

def Minimum(image1: Image, image2: Image) -> Image:
    """Pixel-wise minimum of two images"""

def SquaredDifference(image1: Image, image2: Image) -> Image:
    """Squared difference between images"""

def AbsoluteValueDifference(image1: Image, image2: Image) -> Image:
    """Absolute value of difference between images"""

# Unary operations
def Abs(image: Image) -> Image:
    """Absolute value of each pixel"""

def Square(image: Image) -> Image:
    """Square each pixel value"""

def Sqrt(image: Image) -> Image:
    """Square root of each pixel value"""

def Exp(image: Image) -> Image:
    """Exponential of each pixel value"""

def ExpNegative(image: Image) -> Image:
    """Exponential of negative pixel values"""

def Log(image: Image) -> Image:
    """Natural logarithm of each pixel value"""

def Log10(image: Image) -> Image:
    """Base-10 logarithm of each pixel value"""

def UnaryMinus(image: Image) -> Image:
    """Negate each pixel value"""

def BoundedReciprocal(image: Image) -> Image:
    """Bounded reciprocal (1/x) with overflow protection"""

# Trigonometric functions
def Sin(image: Image) -> Image:
    """Sine of each pixel value"""

def Cos(image: Image) -> Image:
    """Cosine of each pixel value"""

def Tan(image: Image) -> Image:
    """Tangent of each pixel value"""

def Asin(image: Image) -> Image:
    """Arcsine of each pixel value"""

def Acos(image: Image) -> Image:
    """Arccosine of each pixel value"""

def Atan(image: Image) -> Image:
    """Arctangent of each pixel value"""

def Atan2(image1: Image, image2: Image) -> Image:
    """Two-argument arctangent"""

# Power and modulus
def Pow(image: Image, exponent: float) -> Image:
    """Raise pixels to power"""

def Modulus(image1: Image, image2: Image) -> Image:
    """Modulus operation between images"""

# N-ary operations
def NaryAdd(*images: Image) -> Image:
    """Add multiple images together"""

def NaryMaximum(*images: Image) -> Image:
    """Element-wise maximum across multiple images"""

Comparison Operations

Pixel-wise comparison operations producing binary images.

def Equal(image1: Image, image2: Image) -> Image:
    """Test pixel-wise equality"""

def NotEqual(image1: Image, image2: Image) -> Image:
    """Test pixel-wise inequality"""

def Greater(image1: Image, image2: Image) -> Image:
    """Test if first image pixels are greater than second"""

def GreaterEqual(image1: Image, image2: Image) -> Image:
    """Test if first image pixels are greater than or equal to second"""

def Less(image1: Image, image2: Image) -> Image:
    """Test if first image pixels are less than second"""

def LessEqual(image1: Image, image2: Image) -> Image:
    """Test if first image pixels are less than or equal to second"""

Logical Operations

Pixel-wise logical operations for binary images.

def And(image1: Image, image2: Image) -> Image:
    """Logical AND of two binary images"""

def Or(image1: Image, image2: Image) -> Image:
    """Logical OR of two binary images"""

def Xor(image1: Image, image2: Image) -> Image:
    """Logical XOR of two binary images"""

def Not(image: Image) -> Image:
    """Logical NOT of binary image"""

def BitwiseNot(image: Image) -> Image:
    """Bitwise NOT operation"""

Smoothing and Denoising Filters

Filters for noise reduction and image smoothing while preserving important features.

def SmoothingRecursiveGaussian(image: Image, sigma: float) -> Image:
    """
    Efficient recursive Gaussian smoothing.
    
    Args:
        image: Input image
        sigma: Standard deviation of Gaussian kernel
    """

def DiscreteGaussian(image: Image, variance: float, maximumKernelWidth: int = 32) -> Image:
    """
    Discrete Gaussian smoothing with finite kernel.
    
    Args:
        image: Input image
        variance: Gaussian variance
        maximumKernelWidth: Maximum kernel size
    """

def BilateralFilter(image: Image, domainSigma: float, rangeSigma: float) -> Image:
    """
    Edge-preserving bilateral filtering.
    
    Args:
        image: Input image
        domainSigma: Spatial smoothing parameter
        rangeSigma: Intensity smoothing parameter
    """

def MedianFilter(image: Image, radius: int = 1) -> Image:
    """
    Median filtering for noise reduction.
    
    Args:
        image: Input image  
        radius: Neighborhood radius
    """

def MeanFilter(image: Image, radius: int = 1) -> Image:
    """
    Mean filtering (box filter).
    
    Args:
        image: Input image
        radius: Neighborhood radius
    """

def CurvatureAnisotropicDiffusion(image: Image, timeStep: float = 0.0625, 
                                 numberOfIterations: int = 5, 
                                 conductanceParameter: float = 3.0) -> Image:
    """
    Curvature-driven anisotropic diffusion for edge-preserving smoothing.
    
    Args:
        image: Input image
        timeStep: Time step for diffusion
        numberOfIterations: Number of diffusion iterations
        conductanceParameter: Controls edge preservation
    """

def GradientAnisotropicDiffusion(image: Image, timeStep: float = 0.0625,
                                numberOfIterations: int = 5,
                                conductanceParameter: float = 1.0) -> Image:
    """Gradient-based anisotropic diffusion"""

def PatchBasedDenoising(image: Image, kernelBandwidthSigma: float = 400.0,
                       patchRadius: int = 4, numberOfIterations: int = 1) -> Image:
    """
    Patch-based denoising using non-local means approach.
    
    Args:
        image: Input image
        kernelBandwidthSigma: Controls similarity weighting
        patchRadius: Patch size radius  
        numberOfIterations: Number of denoising iterations
    """

def BinomialBlur(image: Image, repetitions: int = 1) -> Image:
    """Binomial blurring (approximates Gaussian)"""

def RecursiveGaussian(image: Image, sigma: float, direction: int = 0) -> Image:
    """Recursive Gaussian filtering along specific direction"""

Thresholding Filters

Convert grayscale images to binary images using various thresholding methods.

def BinaryThreshold(image: Image, lowerThreshold: float, upperThreshold: float,
                   insideValue: int = 1, outsideValue: int = 0) -> Image:
    """
    Binary thresholding with specified range.
    
    Args:
        image: Input image
        lowerThreshold: Lower threshold value
        upperThreshold: Upper threshold value  
        insideValue: Value for pixels in range
        outsideValue: Value for pixels outside range
    """

def Threshold(image: Image, lower: float, upper: float, outsideValue: float) -> Image:
    """Threshold with clamping outside values"""

def OtsuThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0,
                 numberOfHistogramBins: int = 128) -> Image:
    """
    Otsu's automatic thresholding method.
    
    Args:
        image: Input image
        insideValue: Value for foreground pixels
        outsideValue: Value for background pixels
        numberOfHistogramBins: Histogram bins for threshold computation
    """

def OtsuMultipleThresholds(image: Image, numberOfThresholds: int = 1,
                          numberOfHistogramBins: int = 128) -> Image:
    """Multi-level Otsu thresholding"""

def TriangleThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Triangle method automatic thresholding"""

def YenThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Yen's automatic thresholding method"""

def HuangThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Huang's fuzzy thresholding method"""

def IntermodesThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Intermodes thresholding (assumes bimodal histogram)"""

def IsoDataThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """IsoData iterative thresholding"""

def KittlerIllingworthThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Kittler-Illingworth minimum error thresholding"""

def LiThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Li's iterative selection method"""

def MaximumEntropyThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Maximum entropy thresholding"""

def MomentsThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Moments-based thresholding"""

def RenyiEntropyThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Renyi entropy thresholding"""

def ShanbhagThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image:
    """Shanbhag's thresholding method"""

def DoubleThreshold(image: Image, threshold1: float, threshold2: float) -> Image:
    """Double thresholding with three output levels"""

Morphological Operations

Shape-based operations for binary and grayscale images.

# Binary morphological operations
def BinaryDilate(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """
    Binary dilation operation.
    
    Args:
        image: Binary input image
        radius: Structuring element radius
        kernelType: Kernel shape (1=ball, 2=box, 3=cross)
    """

def BinaryErode(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Binary erosion operation"""

def BinaryMorphologicalOpening(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Binary morphological opening (erosion followed by dilation)"""

def BinaryMorphologicalClosing(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Binary morphological closing (dilation followed by erosion)"""

def BinaryFillhole(image: Image) -> Image:
    """Fill holes in binary objects"""

def BinaryGrindPeak(image: Image) -> Image:
    """Remove peaks in binary image"""

def BinaryThinning(image: Image) -> Image:
    """Thinning of binary objects to skeleton"""

# Grayscale morphological operations  
def GrayscaleDilate(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Grayscale dilation"""

def GrayscaleErode(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Grayscale erosion"""

def GrayscaleMorphologicalOpening(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Grayscale morphological opening"""

def GrayscaleMorphologicalClosing(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Grayscale morphological closing"""

def GrayscaleFillhole(image: Image) -> Image:
    """Fill holes in grayscale image"""

def GrayscaleGrindPeak(image: Image) -> Image:
    """Remove peaks in grayscale image"""

# Top-hat transforms
def WhiteTopHat(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """White top-hat transform (original - opening)"""

def BlackTopHat(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Black top-hat transform (closing - original)"""

def MorphologicalGradient(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Morphological gradient (dilation - erosion)"""

# Reconstruction operations
def ReconstructionByDilation(image: Image, mask: Image) -> Image:
    """Morphological reconstruction by dilation"""

def ReconstructionByErosion(image: Image, mask: Image) -> Image:
    """Morphological reconstruction by erosion"""

def OpeningByReconstruction(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Opening by reconstruction"""

def ClosingByReconstruction(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Closing by reconstruction"""

def BinaryOpeningByReconstruction(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Binary opening by reconstruction"""

def BinaryClosingByReconstruction(image: Image, radius: int = 1, kernelType: int = 1) -> Image:
    """Binary closing by reconstruction"""

def BinaryReconstructionByDilation(image: Image, mask: Image) -> Image:
    """Binary reconstruction by dilation"""

def BinaryReconstructionByErosion(image: Image, mask: Image) -> Image:
    """Binary reconstruction by erosion"""

# H-transforms for peak/valley detection
def HMaxima(image: Image, height: float) -> Image:
    """H-maxima transform (suppress maxima below height)"""

def HMinima(image: Image, height: float) -> Image:
    """H-minima transform (suppress minima above height)"""

def HConvex(image: Image, height: float) -> Image:
    """H-convex transform"""

def HConcave(image: Image, height: float) -> Image:
    """H-concave transform"""

Image Grid Operations

Fundamental image manipulation operations including resampling, cropping, padding, and geometric transformations.

def ResampleImageFilter(image: Image, transform: Transform = None, 
                       interpolator: int = None, size: tuple = None,
                       outputSpacing: tuple = None, outputOrigin: tuple = None,
                       outputDirection: tuple = None, defaultPixelValue: float = 0.0) -> Image:
    """
    Resample image to new grid with optional transformation.
    
    Args:
        image: Input image to resample
        transform: Optional geometric transformation
        interpolator: Interpolation method (sitkLinear, sitkNearestNeighbor, etc.)
        size: Output image size tuple
        outputSpacing: Output pixel spacing tuple
        outputOrigin: Output image origin tuple
        outputDirection: Output image direction matrix
        defaultPixelValue: Fill value for pixels outside input
    """

def CropImageFilter(image: Image, lowerBoundaryCropSize: tuple, 
                   upperBoundaryCropSize: tuple) -> Image:
    """
    Crop image by removing pixels from boundaries.
    
    Args:
        image: Input image
        lowerBoundaryCropSize: Pixels to remove from lower boundaries (x,y,z)
        upperBoundaryCropSize: Pixels to remove from upper boundaries (x,y,z)
    """

def BinShrinkImageFilter(image: Image, shrinkFactors: tuple) -> Image:
    """
    Shrink image by averaging pixels in local neighborhoods.
    
    Args:
        image: Input image
        shrinkFactors: Shrinkage factor for each dimension
    """

def ShrinkImageFilter(image: Image, shrinkFactors: tuple) -> Image:
    """
    Shrink image by subsampling (no averaging).
    
    Args:
        image: Input image  
        shrinkFactors: Shrinkage factor for each dimension
    """

def FlipImageFilter(image: Image, flipAxes: tuple) -> Image:
    """
    Flip image along specified axes.
    
    Args:
        image: Input image
        flipAxes: Boolean tuple indicating which axes to flip
    """

def WarpImageFilter(image: Image, displacementField: Image, interpolator: int = None,
                   outputSpacing: tuple = None, outputOrigin: tuple = None, 
                   outputDirection: tuple = None, edgePaddingValue: float = 0.0) -> Image:
    """
    Warp image using displacement field.
    
    Args:
        image: Input image to warp
        displacementField: Vector image defining displacement at each pixel
        interpolator: Interpolation method
        outputSpacing: Output pixel spacing
        outputOrigin: Output image origin
        outputDirection: Output image direction
        edgePaddingValue: Fill value for warped regions
    """

def RegionOfInterestImageFilter(image: Image, size: tuple, index: tuple) -> Image:
    """
    Extract rectangular region of interest.
    
    Args:
        image: Input image
        size: Size of ROI in each dimension
        index: Starting index of ROI
    """

def PermuteAxesImageFilter(image: Image, order: tuple) -> Image:
    """
    Reorder image axes by permuting dimensions.
    
    Args:
        image: Input image
        order: New order of axes (e.g., (2,0,1) for z,x,y)
    """

def TileImageFilter(images: list, layout: tuple) -> Image:
    """
    Tile multiple images into single image.
    
    Args:
        images: List of input images to tile
        layout: Layout specification (rows, columns, slices)
    """

def PasteImageFilter(destinationImage: Image, sourceImage: Image, 
                    sourceSize: tuple, sourceIndex: tuple, 
                    destinationIndex: tuple) -> Image:
    """
    Paste source image region into destination image.
    
    Args:
        destinationImage: Target image
        sourceImage: Source image to paste from
        sourceSize: Size of region to paste
        sourceIndex: Starting index in source image
        destinationIndex: Target location in destination image
    """

def CyclicShiftImageFilter(image: Image, shift: tuple) -> Image:
    """
    Cyclically shift image by specified offset.
    
    Args:
        image: Input image
        shift: Shift amount for each dimension
    """

def ZeroFluxNeumannPadImageFilter(image: Image, padUpperBound: tuple, 
                                padLowerBound: tuple) -> Image:
    """
    Pad image using Neumann boundary conditions (zero flux).
    
    Args:
        image: Input image
        padUpperBound: Padding size for upper boundaries
        padLowerBound: Padding size for lower boundaries
    """

def WrapPadImageFilter(image: Image, padUpperBound: tuple, 
                      padLowerBound: tuple) -> Image:
    """
    Pad image using wrap-around boundary conditions.
    
    Args:
        image: Input image
        padUpperBound: Padding size for upper boundaries
        padLowerBound: Padding size for lower boundaries
    """

Edge Detection

Filters for detecting edges and boundaries in images.

def CannyEdgeDetection(image: Image, lowerThreshold: float, upperThreshold: float,
                      variance: list = [1.0], maximumKernelWidth: int = 32) -> Image:
    """
    Canny edge detection with hysteresis thresholding.
    
    Args:
        image: Input image
        lowerThreshold: Lower threshold for edge linking
        upperThreshold: Upper threshold for edge detection
        variance: Gaussian smoothing variance per dimension
        maximumKernelWidth: Maximum Gaussian kernel width
    """

def SobelEdgeDetection(image: Image) -> Image:
    """Sobel edge detection using gradient magnitude"""

def ZeroCrossingBasedEdgeDetection(image: Image, variance: float = 1.0,
                                  foregroundValue: int = 1, backgroundValue: int = 0) -> Image:
    """Zero-crossing edge detection using Laplacian of Gaussian"""

def LaplacianImageFilter(image: Image) -> Image:
    """Laplacian edge detection filter"""

def LaplacianRecursiveGaussian(image: Image, sigma: float = 1.0) -> Image:
    """Laplacian of Gaussian edge detection"""

def LaplacianSharpeningImageFilter(image: Image) -> Image:
    """Laplacian sharpening filter"""

def GradientMagnitude(image: Image) -> Image:
    """Gradient magnitude for edge strength"""

def GradientMagnitudeRecursiveGaussian(image: Image, sigma: float = 1.0) -> Image:
    """Gradient magnitude using recursive Gaussian derivatives"""

def Gradient(image: Image) -> Image:
    """Gradient vector image"""

def GradientRecursiveGaussian(image: Image, sigma: float = 1.0) -> Image:
    """Gradient using recursive Gaussian derivatives"""

def Derivative(image: Image, direction: int = 0, order: int = 1) -> Image:
    """Directional derivative along specified axis"""

def DiscreteGaussianDerivative(image: Image, order: int = 1, variance: float = 1.0,
                              direction: int = 0, maximumKernelWidth: int = 32) -> Image:
    """Discrete Gaussian derivative"""

Segmentation Filters

Region growing and level set methods for image segmentation.

def ConnectedThreshold(image: Image, seedList: list, lower: float, upper: float,
                      replaceValue: int = 1) -> Image:
    """
    Connected component segmentation using intensity thresholds.
    
    Args:
        image: Input image
        seedList: List of seed points as [(x,y[,z]), ...]
        lower: Lower intensity threshold
        upper: Upper intensity threshold
        replaceValue: Value for segmented region
    """

def ConfidenceConnected(image: Image, seedList: list, numberOfIterations: int = 1,
                       multiplier: float = 2.5, initialNeighborhoodRadius: int = 1,
                       replaceValue: int = 1) -> Image:
    """
    Confidence connected region growing based on statistics.
    
    Args:
        image: Input image
        seedList: List of seed points
        numberOfIterations: Number of iterations
        multiplier: Confidence interval multiplier
        initialNeighborhoodRadius: Initial neighborhood radius
        replaceValue: Value for segmented region
    """

def NeighborhoodConnected(image: Image, seedList: list, lower: float, upper: float,
                         radius: int = 1, replaceValue: int = 1) -> Image:
    """Neighborhood-based connected component segmentation"""

def IsolatedConnected(image: Image, seed1: list, seed2: list, lower: float, upper: float,
                     replaceValue: int = 1) -> Image:
    """
    Isolated connected segmentation between two seed regions.
    
    Args:
        image: Input image
        seed1: Seed points for first region
        seed2: Seed points for second region  
        lower: Lower threshold
        upper: Upper threshold
        replaceValue: Value for segmented region
    """

def VectorConfidenceConnected(image: Image, seedList: list, numberOfIterations: int = 1,
                             multiplier: float = 2.5, initialNeighborhoodRadius: int = 1) -> Image:
    """Confidence connected for vector images"""

# Level set segmentation
def GeodesicActiveContourLevelSet(image: Image, featureImage: Image,
                                 maximumRMSError: float = 0.02, numberOfIterations: int = 1000,
                                 curvatureScaling: float = 1.0, advectionScaling: float = 1.0,
                                 propagationScaling: float = 1.0) -> Image:
    """
    Geodesic active contour level set segmentation.
    
    Args:
        image: Initial level set image
        featureImage: Feature image (edge potential)
        maximumRMSError: Convergence criteria
        numberOfIterations: Maximum iterations
        curvatureScaling: Curvature term weight
        advectionScaling: Advection term weight
        propagationScaling: Propagation term weight
    """

def ShapeDetectionLevelSet(image: Image, featureImage: Image,
                          maximumRMSError: float = 0.02, numberOfIterations: int = 1000,
                          curvatureScaling: float = 1.0, propagationScaling: float = 1.0) -> Image:
    """Shape detection level set method"""

def ThresholdSegmentationLevelSet(image: Image, featureImage: Image,
                                 lowerThreshold: float, upperThreshold: float,
                                 maximumRMSError: float = 0.02, numberOfIterations: int = 1000,
                                 curvatureScaling: float = 1.0, propagationScaling: float = 1.0) -> Image:
    """Threshold-based level set segmentation"""

def LaplacianSegmentationLevelSet(image: Image, featureImage: Image,
                                 maximumRMSError: float = 0.02, numberOfIterations: int = 1000,
                                 curvatureScaling: float = 1.0, propagationScaling: float = 1.0) -> Image:
    """Laplacian level set segmentation"""

def ScalarChanAndVeseDenseLevelSet(image: Image, maximumRMSError: float = 0.02,
                                  numberOfIterations: int = 1000, lambda1: float = 1.0,
                                  lambda2: float = 1.0, mu: float = 0.1, nu: float = 0.0,
                                  epsilon: float = 1.0, heavisideStepFunction: int = 1) -> Image:
    """Chan-Vese level set segmentation for scalar images"""

# Watershed segmentation
def MorphologicalWatershed(image: Image, level: float = 0.0, markWatershedLine: bool = True,
                          fullyConnected: bool = False) -> Image:
    """
    Morphological watershed segmentation.
    
    Args:
        image: Input image (typically gradient magnitude)
        level: Water level for flooding
        markWatershedLine: Mark watershed boundaries
        fullyConnected: Use full connectivity
    """

def MorphologicalWatershedFromMarkers(image: Image, markerImage: Image,
                                     markWatershedLine: bool = True,
                                     fullyConnected: bool = False) -> Image:
    """Watershed segmentation with pre-defined markers"""

def IsolatedWatershed(image: Image, seed1: list, seed2: list, threshold: float = 0.0,
                     isolatedValueTolerance: float = 0.001, upperValueLimit: float = 1.0,
                     replaceValue1: int = 1, replaceValue2: int = 2) -> Image:
    """Isolated watershed between two seed regions"""

# Other segmentation methods
def CollidingFronts(image: Image, seed1: list, seed2: list) -> Image:
    """Colliding fronts segmentation method"""

def FastMarching(image: Image, trialPoints: list, stoppingValue: float = 1e38) -> Image:
    """
    Fast marching method for front propagation.
    
    Args:
        image: Speed image
        trialPoints: Initial front points with travel times
        stoppingValue: Stop when front reaches this value
    """

def FastMarchingUpwindGradient(image: Image, trialPoints: list, stoppingValue: float = 1e38) -> Image:
    """Fast marching with upwind gradient computation"""

Connected Component Analysis

Analyze connected regions in binary and labeled images.

def ConnectedComponent(image: Image, fullyConnected: bool = False) -> Image:
    """
    Label connected components in binary image.
    
    Args:
        image: Binary input image
        fullyConnected: Use 8-connectivity (2D) or 26-connectivity (3D)
        
    Returns:
        Labeled image with unique labels for each component
    """

def ScalarConnectedComponent(image: Image, fullyConnected: bool = False) -> Image:
    """Connected components for scalar images (same intensity)"""

def VectorConnectedComponent(image: Image, distanceThreshold: float = 0.0,
                           fullyConnected: bool = False) -> Image:
    """Connected components for vector images"""

def RelabelComponent(image: Image, minimumObjectSize: int = 0,
                    sortByObjectSize: bool = True) -> Image:
    """
    Relabel connected components by size.
    
    Args:
        image: Labeled input image
        minimumObjectSize: Remove components smaller than this
        sortByObjectSize: Sort labels by component size
    """

def BinaryImageToLabelMap(image: Image, fullyConnected: bool = False,
                         inputForegroundValue: int = 1, outputBackgroundValue: int = 0) -> Image:
    """Convert binary image to label map"""

def LabelImageToLabelMap(image: Image, backgroundValue: int = 0) -> Image:
    """Convert labeled image to label map format"""

def LabelMapToBinary(image: Image, backgroundValue: int = 0) -> Image:
    """Convert label map to binary image"""

def LabelMapToLabel(image: Image, backgroundValue: int = 0) -> Image:
    """Convert label map to labeled image"""

Statistical and Measurement Filters

Compute statistics and measurements on images and regions.

def StatisticsImageFilter(image: Image) -> dict:
    """
    Compute basic image statistics.
    
    Returns:
        Dictionary with 'Mean', 'Variance', 'Sigma', 'Minimum', 'Maximum', 'Sum'
    """

def MinimumMaximum(image: Image) -> tuple:
    """
    Find minimum and maximum pixel values.
    
    Returns:
        Tuple of (minimum, maximum)
    """

def LabelStatistics(image: Image, labelImage: Image) -> dict:
    """
    Compute statistics for each labeled region.
    
    Args:
        image: Intensity image
        labelImage: Label image defining regions
        
    Returns:
        Dictionary with statistics per label
    """

def LabelIntensityStatistics(image: Image, labelImage: Image) -> dict:
    """Intensity statistics for labeled regions"""

def LabelShapeStatistics(image: Image) -> dict:
    """
    Compute shape statistics for labeled regions.
    
    Returns:
        Dictionary with shape measurements per label
    """

def HistogramMatching(image: Image, referenceImage: Image, numberOfHistogramLevels: int = 256,
                     numberOfMatchPoints: int = 1, thresholdAtMeanIntensity: bool = True) -> Image:
    """
    Match histogram of image to reference image.
    
    Args:
        image: Image to modify
        referenceImage: Target histogram image
        numberOfHistogramLevels: Histogram bins
        numberOfMatchPoints: Match points for transformation
        thresholdAtMeanIntensity: Use mean as threshold
    """

def NormalizeImageFilter(image: Image) -> Image:
    """Normalize image to [0,1] range"""

def NormalizeToConstant(image: Image, constant: float = 1.0) -> Image:
    """Normalize image so sum equals constant"""

def RescaleIntensity(image: Image, outputMinimum: float = 0.0, outputMaximum: float = 255.0) -> Image:
    """
    Rescale intensities to specified range.
    
    Args:
        image: Input image
        outputMinimum: Minimum output value
        outputMaximum: Maximum output value
    """

def IntensityWindowing(image: Image, windowMinimum: float, windowMaximum: float,
                      outputMinimum: float = 0.0, outputMaximum: float = 255.0) -> Image:
    """
    Window intensity values to specified range.
    
    Args:
        image: Input image
        windowMinimum: Input window minimum
        windowMaximum: Input window maximum
        outputMinimum: Output minimum
        outputMaximum: Output maximum
    """

def ShiftScale(image: Image, shift: float = 0.0, scale: float = 1.0) -> Image:
    """Apply linear transformation: output = (input + shift) * scale"""

def Clamp(image: Image, lowerBound: float = 0.0, upperBound: float = 255.0) -> Image:
    """Clamp pixel values to specified range"""

def Sigmoid(image: Image, alpha: float = 1.0, beta: float = 0.0,
           outputMinimum: float = 0.0, outputMaximum: float = 1.0) -> Image:
    """
    Sigmoid intensity transformation.
    
    Args:
        image: Input image
        alpha: Controls sigmoid slope
        beta: Controls sigmoid center
        outputMinimum: Minimum output value
        outputMaximum: Maximum output value
    """

Noise Addition Filters

Add various types of noise to images for testing and simulation.

def AdditiveGaussianNoise(image: Image, mean: float = 0.0, standardDeviation: float = 1.0) -> Image:
    """
    Add Gaussian noise to image.
    
    Args:
        image: Input image
        mean: Noise mean
        standardDeviation: Noise standard deviation
    """

def SaltAndPepperNoise(image: Image, probability: float = 0.01, saltValue: float = 1.0) -> Image:
    """Add salt and pepper noise"""

def ShotNoise(image: Image, scale: float = 1.0) -> Image:
    """Add Poisson (shot) noise"""

def SpeckleNoise(image: Image, standardDeviation: float = 1.0) -> Image:
    """Add speckle (multiplicative) noise"""

def NoiseImageFilter(image: Image) -> Image:
    """Add uniform random noise"""

Usage Examples

Basic Filter Usage

import SimpleITK as sitk

# Read image
image = sitk.ReadImage('input.dcm')

# Apply Gaussian smoothing (procedural interface)
smoothed = sitk.SmoothingRecursiveGaussian(image, 2.0)

# Apply thresholding
binary = sitk.BinaryThreshold(smoothed, 100, 255, 255, 0)

# Chain multiple operations
result = sitk.BinaryMorphologicalClosing(
    sitk.BinaryMorphologicalOpening(binary, 3), 
    3
)

Class-based Filter Control

import SimpleITK as sitk

# Create filter object for detailed parameter control
gaussian_filter = sitk.SmoothingRecursiveGaussianImageFilter()
gaussian_filter.SetSigma(2.5)
gaussian_filter.SetNormalizeAcrossScale(True)

# Apply filter
smoothed = gaussian_filter.Execute(image)

# Check filter properties
print(f"Sigma: {gaussian_filter.GetSigma()}")
print(f"Normalize: {gaussian_filter.GetNormalizeAcrossScale()}")

Segmentation Pipeline

import SimpleITK as sitk

# Load image
image = sitk.ReadImage('medical_scan.dcm')

# Preprocessing
smoothed = sitk.SmoothingRecursiveGaussian(image, 1.0)
grad_mag = sitk.GradientMagnitude(smoothed)

# Seed-based segmentation
seeds = [(100, 150, 75), (120, 140, 80)]  # Example seed points
segmented = sitk.ConnectedThreshold(smoothed, seeds, 50, 200, 255)

# Post-processing
cleaned = sitk.BinaryMorphologicalClosing(segmented, 2)
filled = sitk.BinaryFillhole(cleaned)

# Save result
sitk.WriteImage(filled, 'segmentation_result.png')

Statistical Analysis

import SimpleITK as sitk

# Load images
image = sitk.ReadImage('data.nii')
labels = sitk.ReadImage('labels.nii')

# Compute basic statistics
stats_filter = sitk.StatisticsImageFilter()
stats_filter.Execute(image)

print(f"Mean: {stats_filter.GetMean()}")
print(f"Std Dev: {stats_filter.GetSigma()}")
print(f"Min: {stats_filter.GetMinimum()}")
print(f"Max: {stats_filter.GetMaximum()}")

# Statistics per labeled region
label_stats_filter = sitk.LabelStatisticsImageFilter()
label_stats_filter.Execute(image, labels)

labels_list = label_stats_filter.GetLabels()
for label in labels_list:
    print(f"Label {label}:")
    print(f"  Mean: {label_stats_filter.GetMean(label)}")
    print(f"  Volume: {label_stats_filter.GetCount(label)}")

Install with Tessl CLI

npx tessl i tessl/cmake-simpleitk@1.2.2

docs

filters.md

image-operations.md

index.md

io-operations.md

registration.md

transforms.md

tile.json