SimpleITK is a simplified interface to the Insight Toolkit (ITK) for image registration and segmentation
pkg:cmake/simpleitk@1.2.x
npx @tessl/cli install tessl/cmake-simpleitk@1.2.0SimpleITK is a simplified interface to the Insight Toolkit (ITK) for image analysis tasks including filtering, segmentation, and registration. Built on top of ITK, it provides a streamlined API for general filtering operations, image segmentation, and registration while supporting 2D, 3D, and 4D spatio-temporal images with n-dimensional vector voxels.
pip install SimpleITKinstall.packages("SimpleITK")org.itk.simple:simpleitkSimpleITKPython:
import SimpleITK as sitkR:
library(SimpleITK)Java:
import org.itk.simple.*;C#:
using itk.simple;import SimpleITK as sitk
# Read an image
image = sitk.ReadImage('input.dcm')
# Apply Gaussian smoothing
smoothed = sitk.SmoothingRecursiveGaussian(image, 2.0)
# Apply thresholding
binary = sitk.BinaryThreshold(smoothed, 100, 255, 255, 0)
# Write result
sitk.WriteImage(binary, 'output.png')
# Chain operations for complex processing
result = sitk.BinaryThreshold(
sitk.MedianFilter(
sitk.SmoothingRecursiveGaussian(image, 1.5),
3
),
50, 200
)SimpleITK's design centers around these key components:
The library emphasizes ease of use while maintaining access to ITK's powerful capabilities, making medical and scientific image analysis accessible to domain experts without deep technical knowledge of image processing algorithms.
Core image data structure and fundamental operations including creation, pixel access, metadata handling, and format conversions. The Image class supports multiple pixel types and dimensions with comprehensive metadata preservation.
# Image class core methods
class Image:
def __init__(self, *args): ...
def GetSize(self) -> tuple: ...
def GetOrigin(self) -> tuple: ...
def GetSpacing(self) -> tuple: ...
def GetDirection(self) -> tuple: ...
def GetPixelID(self) -> int: ...
def GetNumberOfComponentsPerPixel(self) -> int: ...
def SetPixel(self, idx, value): ...
def GetPixel(self, idx): ...
def CopyInformation(self, other_image): ...
# NumPy integration (Python-specific)
def GetArrayFromImage(image) -> numpy.ndarray: ...
def GetImageFromArray(array, isVector=False) -> Image: ...Comprehensive input/output functionality for reading and writing images in various formats including DICOM, NIfTI, PNG, JPEG, TIFF, and many scientific formats. Supports both single images and image series with automatic format detection.
# Procedural I/O functions
def ReadImage(filename: str, pixelType=None) -> Image: ...
def WriteImage(image: Image, filename: str, useCompression=False): ...
# Class-based I/O
class ImageFileReader:
def SetFileName(self, filename: str): ...
def Execute(self) -> Image: ...
def ReadImageInformation(self): ...
def GetSize(self) -> tuple: ...
class ImageFileWriter:
def SetFileName(self, filename: str): ...
def SetUseCompression(self, compress: bool): ...
def Execute(self, image: Image): ...
class ImageSeriesReader:
def SetFileNames(self, filenames: list): ...
def Execute(self) -> Image: ...
# Display function
def Show(image: Image, title="", debugOn=False): ...Geometric transformation classes for image registration, spatial alignment, and coordinate system manipulation. Supports rigid, affine, deformable, and specialized transformations with parameter optimization.
# Base Transform class
class Transform:
def GetParameters(self) -> tuple: ...
def SetParameters(self, parameters: tuple): ...
def GetFixedParameters(self) -> tuple: ...
def TransformPoint(self, point: tuple) -> tuple: ...
def GetInverse(self) -> Transform: ...
# Specific transform types
class AffineTransform(Transform): ...
class Euler3DTransform(Transform): ...
class BSplineTransform(Transform): ...
class DisplacementFieldTransform(Transform): ...
# Transform utilities
def ReadTransform(filename: str) -> Transform: ...
def WriteTransform(transform: Transform, filename: str): ...291 image processing filters covering mathematical operations, morphological operations, smoothing, edge detection, thresholding, segmentation, frequency domain processing, and statistical analysis. Available as both classes and procedural functions.
# Mathematical operations
def Add(image1: Image, image2: Image) -> Image: ...
def Subtract(image1: Image, image2: Image) -> Image: ...
def Multiply(image1: Image, image2: Image) -> Image: ...
# Smoothing filters
def GaussianBlur(image: Image, sigma: float) -> Image: ...
def MedianFilter(image: Image, radius: int) -> Image: ...
def BilateralFilter(image: Image, domainSigma: float, rangeSigma: float) -> Image: ...
# Thresholding
def BinaryThreshold(image: Image, lowerThreshold: float, upperThreshold: float,
insideValue: int = 1, outsideValue: int = 0) -> Image: ...
def OtsuThreshold(image: Image, insideValue: int = 1, outsideValue: int = 0) -> Image: ...
# Edge detection
def CannyEdgeDetection(image: Image, lowerThreshold: float, upperThreshold: float,
variance: list = [1.0]) -> Image: ...
def SobelEdgeDetection(image: Image) -> Image: ...
# Morphological operations
def BinaryDilate(image: Image, radius: int = 1) -> Image: ...
def BinaryErode(image: Image, radius: int = 1) -> Image: ...Complete image registration framework for aligning images through optimization of similarity metrics. Supports multi-modal registration, transformation parameter estimation, and evaluation metrics.
class ImageRegistrationMethod:
def SetMetric(self, metric): ...
def SetOptimizer(self, optimizer): ...
def SetInitialTransform(self, transform: Transform): ...
def SetFixedImage(self, image: Image): ...
def SetMovingImage(self, image: Image): ...
def Execute(self) -> Transform: ...
def GetOptimizerIteration(self) -> int: ...
def GetMetricValue(self) -> float: ...
# Registration utilities
def ResampleImageFilter(image: Image, transform: Transform,
referenceImage: Image = None) -> Image: ...# Pixel type constants
sitkUInt8 = 1
sitkInt8 = 2
sitkUInt16 = 3
sitkInt16 = 4
sitkUInt32 = 5
sitkInt32 = 6
sitkUInt64 = 7
sitkInt64 = 8
sitkFloat32 = 9
sitkFloat64 = 10
sitkComplexFloat32 = 11
sitkComplexFloat64 = 12
sitkVectorUInt8 = 13
sitkVectorInt8 = 14
sitkVectorUInt16 = 15
sitkVectorInt16 = 16
sitkVectorUInt32 = 17
sitkVectorInt32 = 18
sitkVectorFloat32 = 19
sitkVectorFloat64 = 20# Interpolation constants
sitkNearestNeighbor = 1
sitkLinear = 2
sitkBSpline = 3
sitkGaussian = 4
sitkLabelGaussian = 5
sitkHammingWindowedSinc = 6
sitkCosineWindowedSinc = 7
sitkWelchWindowedSinc = 8
sitkLanczosWindowedSinc = 9
sitkBlackmanWindowedSinc = 10