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
Filters for detecting edges, computing image gradients, and analyzing intensity transitions. These filters identify boundaries and intensity changes in images.
class CannyEdgeDetectionImageFilter:
"""Canny edge detector with hysteresis thresholding."""
def SetLowerThreshold(self, threshold: float) -> None:
"""Set lower threshold for hysteresis."""
def SetUpperThreshold(self, threshold: float) -> None:
"""Set upper threshold for hysteresis."""
def SetVariance(self, variance: float | tuple[float, ...]) -> None:
"""Set Gaussian smoothing variance."""
def SetMaximumError(self, error: float) -> None:
"""Set maximum error for Gaussian approximation."""
def Execute(self, image):
"""
Apply Canny edge detection.
Returns:
Binary edge map
"""
def CannyEdgeDetection(image, lowerThreshold: float = 0, upperThreshold: float = 0,
variance: float | tuple[float, ...] = 0, maximumError: float = 0.01):
"""Procedural: Canny edge detection."""
class SobelEdgeDetectionImageFilter:
"""Sobel edge detector using directional derivatives."""
def Execute(self, image):
"""
Apply Sobel edge detection.
Returns:
Edge magnitude image
"""
def SobelEdgeDetection(image):
"""Procedural: Sobel edge detection."""class LaplacianImageFilter:
"""Laplacian operator (second derivative)."""
def SetUseImageSpacing(self, useSpacing: bool) -> None:
"""Account for image spacing."""
def Execute(self, image):
"""
Compute Laplacian.
Returns:
Laplacian image (highlights edges and blobs)
"""
def Laplacian(image, useImageSpacing: bool = True):
"""Procedural: Laplacian."""
class LaplacianRecursiveGaussianImageFilter:
"""Laplacian of Gaussian using recursive filters."""
def SetSigma(self, sigma: float) -> None:
"""Set Gaussian sigma."""
def SetNormalizeAcrossScale(self, normalize: bool) -> None:
"""Enable scale normalization."""
def Execute(self, image):
"""
Compute Laplacian of Gaussian.
Returns:
LoG filtered image (blob detector)
"""
def LaplacianRecursiveGaussian(image, sigma: float = 1.0,
normalizeAcrossScale: bool = False):
"""Procedural: Laplacian of Gaussian."""class ZeroCrossingImageFilter:
"""Find zero crossings in image (typically after Laplacian)."""
def SetForegroundValue(self, value: float) -> None:
"""Set foreground value for zero crossings."""
def SetBackgroundValue(self, value: float) -> None:
"""Set background value."""
def Execute(self, image):
"""
Detect zero crossings.
Returns:
Binary image with zero crossings marked
"""
def ZeroCrossing(image, foregroundValue: float = 1.0, backgroundValue: float = 0.0):
"""Procedural: zero crossing detection."""class GradientImageFilter:
"""Compute gradient vector field using finite differences."""
def SetUseImageSpacing(self, useSpacing: bool) -> None:
"""Account for image spacing."""
def Execute(self, image):
"""
Compute gradient.
Returns:
Vector image with gradient at each pixel
"""
def Gradient(image, useImageSpacing: bool = True):
"""Procedural: compute gradient."""
class GradientMagnitudeImageFilter:
"""Compute gradient magnitude using finite differences."""
def SetUseImageSpacing(self, useSpacing: bool) -> None:
"""Account for image spacing."""
def Execute(self, image):
"""
Compute gradient magnitude.
Returns:
Gradient magnitude image
"""
def GradientMagnitude(image, useImageSpacing: bool = True):
"""Procedural: gradient magnitude."""
class GradientRecursiveGaussianImageFilter:
"""Compute gradient using recursive Gaussian derivatives."""
def SetSigma(self, sigma: float) -> None:
"""Set Gaussian sigma for smoothing."""
def SetNormalizeAcrossScale(self, normalize: bool) -> None:
"""Enable scale normalization."""
def Execute(self, image):
"""
Compute smoothed gradient.
Returns:
Vector gradient image
"""
def GradientRecursiveGaussian(image, sigma: float = 1.0,
normalizeAcrossScale: bool = False):
"""Procedural: recursive Gaussian gradient."""
class GradientMagnitudeRecursiveGaussianImageFilter:
"""Compute gradient magnitude using recursive Gaussian derivatives."""
def SetSigma(self, sigma: float) -> None:
"""Set Gaussian sigma."""
def SetNormalizeAcrossScale(self, normalize: bool) -> None:
"""Enable scale normalization."""
def Execute(self, image):
"""
Compute smoothed gradient magnitude.
Returns:
Gradient magnitude image
"""
def GradientMagnitudeRecursiveGaussian(image, sigma: float = 1.0,
normalizeAcrossScale: bool = False):
"""Procedural: recursive Gaussian gradient magnitude."""class DerivativeImageFilter:
"""Compute directional derivative."""
def SetDirection(self, direction: int) -> None:
"""
Set derivative direction.
Args:
direction: Axis index (0=X, 1=Y, 2=Z)
"""
def SetOrder(self, order: int) -> None:
"""
Set derivative order.
Args:
order: Derivative order (1 or 2)
"""
def SetUseImageSpacing(self, useSpacing: bool) -> None:
"""Account for image spacing."""
def Execute(self, image):
"""
Compute derivative.
Returns:
Derivative image
"""
def Derivative(image, direction: int = 0, order: int = 1, useImageSpacing: bool = True):
"""Procedural: directional derivative."""import SimpleITK as sitk
# Fine-scale edges
edges_fine = sitk.CannyEdgeDetection(
image,
lowerThreshold=10,
upperThreshold=50,
variance=[0.5, 0.5, 0.5]
)
# Coarse-scale edges
edges_coarse = sitk.CannyEdgeDetection(
image,
lowerThreshold=10,
upperThreshold=50,
variance=[2.0, 2.0, 2.0]
)import SimpleITK as sitk
# Compute gradient magnitude
grad_mag = sitk.GradientMagnitude(image)
# Compute gradient direction
grad_vec = sitk.Gradient(image)
# Use gradient for segmentation
seeds = [(100, 100, 50)]
segmentation = sitk.GradientMagnitudeRecursiveGaussian(image, sigma=1.0)import SimpleITK as sitk
# Laplacian of Gaussian for blob detection
log_image = sitk.LaplacianRecursiveGaussian(image, sigma=2.0)
# Find zero crossings
blobs = sitk.ZeroCrossing(log_image)Install with Tessl CLI
npx tessl i tessl/pypi-simpleitk