SimpleITK is a simplified interface to the Insight Toolkit (ITK) for image registration and segmentation
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Fast Fourier Transform operations, frequency domain filtering, and deconvolution methods for image restoration. FFT-based convolution is efficient for large kernels, and deconvolution reverses blur from known point spread functions.
class ForwardFFTImageFilter:
"""Compute forward FFT of real image."""
def Execute(self, image):
"""
Forward FFT.
Args:
image: Real input image
Returns:
Complex FFT image
"""
def ForwardFFT(image):
"""Procedural: forward FFT."""
class InverseFFTImageFilter:
"""Compute inverse FFT."""
def Execute(self, complexImage):
"""
Inverse FFT.
Args:
complexImage: Complex FFT image
Returns:
Real image
"""
def InverseFFT(complexImage):
"""Procedural: inverse FFT."""
class FFTShiftImageFilter:
"""Shift zero-frequency to center of image."""
def SetInverse(self, inverse: bool) -> None:
"""Set inverse shift (center to corner)."""
def Execute(self, image):
"""Returns: shifted FFT image"""
def FFTShift(image, inverse: bool = False):
"""Procedural: FFT shift."""class RealAndImaginaryToComplexImageFilter:
"""Combine real and imaginary images into complex image."""
def Execute(self, realImage, imaginaryImage):
"""
Create complex image.
Args:
realImage: Real part
imaginaryImage: Imaginary part
Returns:
Complex image
"""
def RealAndImaginaryToComplex(realImage, imaginaryImage):
"""Procedural: combine to complex."""
class ComplexToRealImageFilter:
"""Extract real part of complex image."""
def Execute(self, complexImage):
"""Returns: real part"""
def ComplexToReal(complexImage):
"""Procedural: extract real."""
class ComplexToImaginaryImageFilter:
"""Extract imaginary part."""
def Execute(self, complexImage):
"""Returns: imaginary part"""
def ComplexToImaginary(complexImage):
"""Procedural: extract imaginary."""
class ComplexToModulusImageFilter:
"""Compute magnitude of complex image."""
def Execute(self, complexImage):
"""Returns: magnitude (abs value)"""
def ComplexToModulus(complexImage):
"""Procedural: compute magnitude."""
class ComplexToPhaseImageFilter:
"""Compute phase of complex image."""
def Execute(self, complexImage):
"""Returns: phase angle"""
def ComplexToPhase(complexImage):
"""Procedural: compute phase."""class FFTConvolutionImageFilter:
"""Convolution via FFT (efficient for large kernels)."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize output by kernel sum."""
def SetBoundaryCondition(self, condition: int) -> None:
"""Set boundary condition."""
def Execute(self, image, kernelImage):
"""
Convolve via FFT.
Args:
image: Input image
kernelImage: Convolution kernel
Returns:
Convolved image
"""
def FFTConvolution(image, kernelImage, normalize: bool = False):
"""Procedural: FFT convolution."""
class FFTNormalizedCorrelationImageFilter:
"""Normalized cross-correlation via FFT."""
def Execute(self, image, templateImage):
"""
Compute normalized correlation.
Args:
image: Input image
templateImage: Template to match
Returns:
Correlation map
"""
def FFTNormalizedCorrelation(image, templateImage):
"""Procedural: FFT normalized correlation."""
class MaskedFFTNormalizedCorrelationImageFilter:
"""Masked normalized correlation via FFT."""
def Execute(self, image, maskImage, templateImage, templateMaskImage):
"""
Masked correlation.
Args:
image: Input image
maskImage: Input mask
templateImage: Template
templateMaskImage: Template mask
Returns:
Correlation map
"""class RichardsonLucyDeconvolutionImageFilter:
"""Richardson-Lucy iterative deconvolution."""
def SetNumberOfIterations(self, iterations: int) -> None:
"""Set number of iterations."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize by kernel sum."""
def Execute(self, image, kernelImage):
"""
Richardson-Lucy deconvolution.
Args:
image: Blurred image
kernelImage: Point spread function (PSF)
Returns:
Deconvolved image
"""
def RichardsonLucyDeconvolution(image, kernelImage, numberOfIterations: int = 5,
normalize: bool = False):
"""Procedural: Richardson-Lucy deconvolution."""
class WienerDeconvolutionImageFilter:
"""Wiener deconvolution (frequency domain)."""
def SetNoiseVariance(self, variance: float) -> None:
"""Set noise variance for regularization."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize by kernel sum."""
def Execute(self, image, kernelImage):
"""
Wiener deconvolution.
Args:
image: Blurred image
kernelImage: PSF
Returns:
Deconvolved image
"""
def WienerDeconvolution(image, kernelImage, noiseVariance: float = 0.0,
normalize: bool = False):
"""Procedural: Wiener deconvolution."""
class LandweberDeconvolutionImageFilter:
"""Landweber iterative deconvolution."""
def SetNumberOfIterations(self, iterations: int) -> None:
"""Set iterations."""
def SetAlpha(self, alpha: float) -> None:
"""Set relaxation parameter."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize by kernel."""
def Execute(self, image, kernelImage):
"""
Landweber deconvolution.
Returns:
Deconvolved image
"""
def LandweberDeconvolution(image, kernelImage, alpha: float = 0.1,
numberOfIterations: int = 1, normalize: bool = False):
"""Procedural: Landweber deconvolution."""
class TikhonovDeconvolutionImageFilter:
"""Tikhonov regularized deconvolution."""
def SetRegularizationConstant(self, constant: float) -> None:
"""Set regularization constant."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize by kernel."""
def Execute(self, image, kernelImage):
"""
Tikhonov deconvolution.
Returns:
Deconvolved image
"""
def TikhonovDeconvolution(image, kernelImage, regularizationConstant: float = 0.0,
normalize: bool = False):
"""Procedural: Tikhonov deconvolution."""
class InverseDeconvolutionImageFilter:
"""Inverse (direct) deconvolution."""
def SetKernelZeroMagnitudeThreshold(self, threshold: float) -> None:
"""Set threshold for zero kernel values."""
def SetNormalize(self, normalize: bool) -> None:
"""Normalize by kernel."""
def Execute(self, image, kernelImage):
"""
Inverse deconvolution.
Returns:
Deconvolved image
"""
def InverseDeconvolution(image, kernelImage, kernelZeroMagnitudeThreshold: float = 1e-4,
normalize: bool = False):
"""Procedural: inverse deconvolution."""import SimpleITK as sitk
import numpy as np
# Create Gaussian kernel
kernel_size = 15
sigma = 2.0
kernel = sitk.GaussianImageSource()
kernel.SetSize([kernel_size] * 3)
kernel.SetSigma([sigma] * 3)
kernel_image = kernel.Execute()
# Convolve via FFT (efficient for large kernels)
convolved = sitk.FFTConvolution(image, kernel_image, normalize=True)import SimpleITK as sitk
# Known PSF (e.g., Gaussian blur)
psf = sitk.GaussianImageSource()
psf.SetSize([15, 15, 15])
psf.SetSigma([2.0, 2.0, 2.0])
psf_image = psf.Execute()
# Richardson-Lucy deconvolution
deblurred = sitk.RichardsonLucyDeconvolution(
blurred_image,
psf_image,
numberOfIterations=20
)import SimpleITK as sitk
# Find template in image
correlation_map = sitk.FFTNormalizedCorrelation(image, template)
# Find maximum correlation location
stats = sitk.StatisticsImageFilter()
stats.Execute(correlation_map)
max_value = stats.GetMaximum()Install with Tessl CLI
npx tessl i tessl/pypi-simpleitk