or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

filters.mdimage-operations.mdindex.mdio-operations.mdregistration.mdtransforms.md
tile.json

tessl/cmake-simpleitk

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

Workspace
tessl
Visibility
Public
Created
Last updated
Describes

pkg:cmake/simpleitk@1.2.x

To install, run

npx @tessl/cli install tessl/cmake-simpleitk@1.2.0

index.mddocs/

SimpleITK

SimpleITK 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.

Package Information

  • Package Name: SimpleITK
  • Package Type: CMake/C++ library with multi-language bindings
  • Version: 1.2.4
  • Language: C++ with multi-language bindings
  • License: Apache License 2.0
  • Repository: https://github.com/SimpleITK/SimpleITK
  • Documentation: http://simpleitk.readthedocs.io/
  • Installation:
    • Python: pip install SimpleITK
    • R: install.packages("SimpleITK")
    • Java: Available through Maven Central org.itk.simple:simpleitk
    • C#: Available through NuGet SimpleITK
    • Lua: Build from source with Lua bindings enabled
    • TCL: Build from source with TCL bindings enabled
    • Ruby: Build from source with Ruby bindings enabled
  • Supported Languages: C++, Python, R, Java, C#, Lua, TCL, Ruby
  • Supported Platforms: Windows, macOS, Linux
  • Dependencies: ITK (Insight Toolkit), SWIG (for language bindings)

Core Imports

Python:

import SimpleITK as sitk

R:

library(SimpleITK)

Java:

import org.itk.simple.*;

C#:

using itk.simple;

Basic Usage

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
)

Architecture

SimpleITK's design centers around these key components:

  • Image: Core data structure representing 2D/3D/4D images with various pixel types
  • Filters: 291+ image processing operations organized as both classes and procedural functions
  • Transforms: Geometric transformation classes for image registration and spatial manipulation
  • I/O System: Automatic format detection for reading/writing medical and scientific image formats
  • Registration Framework: Complete toolkit for image alignment and correspondence

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.

Capabilities

Image Operations

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: ...

Image Operations

I/O Operations

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): ...

I/O Operations

Transforms

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): ...

Transforms

Image Processing Filters

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: ...

Image Processing Filters

Registration

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: ...

Registration

Common Pixel Types

# 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 Methods

# Interpolation constants
sitkNearestNeighbor = 1
sitkLinear = 2
sitkBSpline = 3
sitkGaussian = 4
sitkLabelGaussian = 5
sitkHammingWindowedSinc = 6
sitkCosineWindowedSinc = 7
sitkWelchWindowedSinc = 8
sitkLanczosWindowedSinc = 9
sitkBlackmanWindowedSinc = 10