Medical image analysis toolkit providing algorithms for segmentation, registration, and processing of medical images
—
ITK provides an extensive collection of image processing filters organized in a hierarchical framework. All filters follow a pipeline architecture with lazy evaluation, supporting both basic pixel operations and advanced image analysis algorithms.
Base class for filters that process images and produce images.
template<typename TInputImage, typename TOutputImage>
class ImageToImageFilter : public ImageSource<TOutputImage>
{
public:
typedef ImageToImageFilter Self;
typedef ImageSource<TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Input handling
using Superclass::SetInput;
virtual void SetInput(const TInputImage *image);
virtual void SetInput(unsigned int, const TInputImage *image);
const TInputImage * GetInput() const;
const TInputImage * GetInput(unsigned int idx) const;
// Pipeline management
virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
virtual void GenerateOutputInformation() ITK_OVERRIDE;
protected:
virtual void GenerateData() ITK_OVERRIDE;
virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
ThreadIdType threadId);
};Base class for pixel-wise operations using function objects.
template<typename TInputImage, typename TOutputImage, typename TFunction>
class UnaryFunctorImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef UnaryFunctorImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Functor access
FunctionType & GetFunctor();
const FunctionType & GetFunctor() const;
void SetFunctor(const FunctionType & functor);
protected:
virtual void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
ThreadIdType threadId) ITK_OVERRIDE;
};Base class for two-input pixel-wise operations.
template<typename TInputImage1, typename TInputImage2, typename TOutputImage, typename TFunction>
class BinaryFunctorImageFilter : public ImageToImageFilter<TInputImage1, TOutputImage>
{
public:
typedef BinaryFunctorImageFilter Self;
typedef ImageToImageFilter<TInputImage1, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Second input handling
void SetInput1(const TInputImage1 * image);
void SetInput2(const TInputImage2 * image);
const TInputImage1 * GetInput1();
const TInputImage2 * GetInput2();
// Functor access
FunctionType & GetFunctor();
const FunctionType & GetFunctor() const;
void SetFunctor(const FunctionType & functor);
};Casts input pixels to output pixel type for converting between different pixel types.
template<typename TInputImage, typename TOutputImage>
class CastImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
{
public:
typedef CastImageFilter Self;
typedef InPlaceImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Creation
static Pointer New();
// Type definitions
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputImageType::PixelType OutputPixelType;
};Applies a linear transformation to rescale intensity values to a desired output range.
template<typename TInputImage, typename TOutputImage>
class RescaleIntensityImageFilter : public UnaryFunctorImageFilter<TInputImage, TOutputImage,
Functor::IntensityLinearTransform<
typename TInputImage::PixelType,
typename TOutputImage::PixelType>>
{
public:
typedef RescaleIntensityImageFilter Self;
typedef UnaryFunctorImageFilter<TInputImage, TOutputImage,
Functor::IntensityLinearTransform<
typename TInputImage::PixelType,
typename TOutputImage::PixelType>> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Creation
static Pointer New();
// Type definitions
typedef typename TOutputImage::PixelType OutputPixelType;
typedef typename TInputImage::PixelType InputPixelType;
// Intensity range control
void SetOutputMinimum(OutputPixelType min);
void SetOutputMaximum(OutputPixelType max);
OutputPixelType GetOutputMinimum() const;
OutputPixelType GetOutputMaximum() const;
// Input range computation
InputPixelType GetInputMinimum() const;
InputPixelType GetInputMaximum() const;
void SetInputMinimum(InputPixelType min);
void SetInputMaximum(InputPixelType max);
// Scale and shift access
double GetScale() const;
double GetShift() const;
};Gaussian smoothing with discrete kernel approximation.
template<typename TInputImage, typename TOutputImage>
class DiscreteGaussianImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef DiscreteGaussianImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Variance control
void SetVariance(const ArrayType & variance);
void SetVariance(const double variance);
void SetVariance(const double* variance);
itkGetConstMacro(Variance, ArrayType);
// Maximum error control
void SetMaximumError(const ArrayType & error);
void SetMaximumError(const double error);
void SetMaximumError(const double* error);
itkGetConstMacro(MaximumError, ArrayType);
// Kernel size limits
void SetMaximumKernelWidth(unsigned int n);
itkGetConstMacro(MaximumKernelWidth, unsigned int);
// Boundary handling
void SetUseImageSpacingOn();
void SetUseImageSpacingOff();
itkGetConstMacro(UseImageSpacing, bool);
};Recursive Gaussian smoothing for efficient large-kernel operations.
template<typename TInputImage, typename TOutputImage>
class SmoothingRecursiveGaussianImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef SmoothingRecursiveGaussianImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Sigma control (standard deviation)
void SetSigma(ScalarRealType sigma);
ScalarRealType GetSigma() const;
void SetSigmaArray(const SigmaArrayType & sigmas);
SigmaArrayType GetSigmaArray() const;
// Normalization control
void SetNormalizeAcrossScale(bool normalizeInScaleSpace);
itkGetConstMacro(NormalizeAcrossScale, bool);
};Edge-preserving bilateral smoothing.
template<typename TInputImage, typename TOutputImage>
class BilateralImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef BilateralImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Filter parameters
void SetDomainSigma(const double domainSigma);
itkGetConstMacro(DomainSigma, double);
void SetRangeSigma(const double rangeSigma);
itkGetConstMacro(RangeSigma, double);
// Automatic parameter selection
void SetAutomaticKernelSize(bool automaticKernelSize);
itkGetConstMacro(AutomaticKernelSize, bool);
// Manual kernel size
void SetRadius(const RadiusType & radius);
itkGetConstMacro(Radius, RadiusType);
};Binary segmentation based on intensity thresholds.
template<typename TInputImage, typename TOutputImage>
class BinaryThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef BinaryThresholdImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Threshold values
void SetLowerThreshold(const InputPixelType & threshold);
void SetUpperThreshold(const InputPixelType & threshold);
itkGetConstMacro(LowerThreshold, InputPixelType);
itkGetConstMacro(UpperThreshold, InputPixelType);
// Output values
void SetOutsideValue(const OutputPixelType & value);
void SetInsideValue(const OutputPixelType & value);
itkGetConstMacro(OutsideValue, OutputPixelType);
itkGetConstMacro(InsideValue, OutputPixelType);
};Automatic threshold selection using Otsu's method.
template<typename TInputImage, typename TOutputImage>
class OtsuThresholdImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef OtsuThresholdImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Computed threshold
itkGetConstMacro(Threshold, InputPixelType);
// Output values
void SetOutsideValue(const OutputPixelType & value);
void SetInsideValue(const OutputPixelType & value);
itkGetConstMacro(OutsideValue, OutputPixelType);
itkGetConstMacro(InsideValue, OutputPixelType);
// Histogram parameters
void SetNumberOfHistogramBins(SizeValueType numberOfBins);
itkGetConstMacro(NumberOfHistogramBins, SizeValueType);
};Binary erosion operation.
template<typename TInputImage, typename TOutputImage, typename TKernel>
class BinaryErodeImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef BinaryErodeImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Structuring element
void SetKernel(const KernelType & kernel);
itkGetConstReferenceMacro(Kernel, KernelType);
// Foreground/background values
void SetForegroundValue(const InputPixelType & value);
void SetBackgroundValue(const InputPixelType & value);
itkGetConstMacro(ForegroundValue, InputPixelType);
itkGetConstMacro(BackgroundValue, InputPixelType);
// Boundary handling
void SetBoundaryToForeground(bool boundaryToForeground);
itkGetConstMacro(BoundaryToForeground, bool);
};Binary dilation operation.
template<typename TInputImage, typename TOutputImage, typename TKernel>
class BinaryDilateImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef BinaryDilateImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Structuring element
void SetKernel(const KernelType & kernel);
itkGetConstReferenceMacro(Kernel, KernelType);
// Foreground/background values
void SetForegroundValue(const InputPixelType & value);
void SetBackgroundValue(const InputPixelType & value);
itkGetConstMacro(ForegroundValue, InputPixelType);
itkGetConstMacro(BackgroundValue, InputPixelType);
};Grayscale erosion operation.
template<typename TInputImage, typename TOutputImage, typename TKernel>
class GrayscaleErodeImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef GrayscaleErodeImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Structuring element
void SetKernel(const KernelType & kernel);
itkGetConstReferenceMacro(Kernel, KernelType);
// Algorithm selection
void SetAlgorithm(AlgorithmType algorithm);
itkGetConstMacro(Algorithm, AlgorithmType);
};Canny edge detection with hysteresis thresholding.
template<typename TInputImage, typename TOutputImage>
class CannyEdgeDetectionImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef CannyEdgeDetectionImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Gaussian parameters
void SetVariance(const ArrayType & variance);
void SetVariance(const double variance);
itkGetConstMacro(Variance, ArrayType);
void SetMaximumError(const ArrayType & maximumError);
void SetMaximumError(const double maximumError);
itkGetConstMacro(MaximumError, ArrayType);
// Threshold parameters
void SetUpperThreshold(const OutputImagePixelType upperThreshold);
void SetLowerThreshold(const OutputImagePixelType lowerThreshold);
itkGetConstMacro(UpperThreshold, OutputImagePixelType);
itkGetConstMacro(LowerThreshold, OutputImagePixelType);
};Laplacian edge enhancement.
template<typename TInputImage, typename TOutputImage>
class LaplacianImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef LaplacianImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Scaling control
void SetUseImageSpacingOn();
void SetUseImageSpacingOff();
itkGetConstMacro(UseImageSpacing, bool);
};Computes gradient magnitude of an image.
template<typename TInputImage, typename TOutputImage>
class GradientMagnitudeImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef GradientMagnitudeImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Spacing consideration
void SetUseImageSpacingOn();
void SetUseImageSpacingOff();
itkGetConstMacro(UseImageSpacing, bool);
};Computes gradient vector field of an image.
template<typename TInputImage, typename TOperatorValueType, typename TOutputValueType>
class GradientImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef GradientImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Spacing consideration
void SetUseImageSpacingOn();
void SetUseImageSpacingOff();
itkGetConstMacro(UseImageSpacing, bool);
// Direction control
void SetUseImageDirection(bool useImageDirection);
itkGetConstMacro(UseImageDirection, bool);
};Resamples an image using arbitrary geometric transforms.
template<typename TInputImage, typename TOutputImage, typename TInterpolatorPrecisionType>
class ResampleImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
{
public:
typedef ResampleImageFilter Self;
typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Transform specification
void SetTransform(const TransformType * transform);
itkGetConstObjectMacro(Transform, TransformType);
// Interpolator specification
void SetInterpolator(InterpolatorType * interpolator);
itkGetConstObjectMacro(Interpolator, InterpolatorType);
// Output image geometry
void SetSize(const SizeType & size);
itkGetConstReferenceMacro(Size, SizeType);
void SetOutputOrigin(const OriginPointType & origin);
itkGetConstReferenceMacro(OutputOrigin, OriginPointType);
void SetOutputSpacing(const SpacingType & spacing);
itkGetConstReferenceMacro(OutputSpacing, SpacingType);
void SetOutputDirection(const DirectionType & direction);
itkGetConstReferenceMacro(OutputDirection, DirectionType);
// Default pixel value
void SetDefaultPixelValue(const PixelType & pixel);
itkGetConstReferenceMacro(DefaultPixelValue, PixelType);
};Anisotropic diffusion for noise reduction.
template<typename TInputImage, typename TOutputImage>
class CurvatureFlowImageFilter : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
{
public:
typedef CurvatureFlowImageFilter Self;
typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
static Pointer New();
// Time step control
void SetTimeStep(const TimeStepType & timeStep);
itkGetConstMacro(TimeStep, TimeStepType);
// Iteration control
void SetNumberOfIterations(unsigned int numberOfIterations);
itkGetConstMacro(NumberOfIterations, unsigned int);
};Base class for anisotropic diffusion filters.
template<typename TInputImage, typename TOutputImage>
class AnisotropicDiffusionImageFilter : public FiniteDifferenceImageFilter<TInputImage, TOutputImage>
{
public:
typedef AnisotropicDiffusionImageFilter Self;
typedef FiniteDifferenceImageFilter<TInputImage, TOutputImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
// Conductance parameter
void SetConductanceParameter(double conductance);
itkGetConstMacro(ConductanceParameter, double);
// Time step
void SetTimeStep(const TimeStepType & timeStep);
itkGetConstMacro(TimeStep, TimeStepType);
// Iterations
void SetNumberOfIterations(unsigned int numberOfIterations);
itkGetConstMacro(NumberOfIterations, unsigned int);
};// Common filter instantiations
typedef BinaryThresholdImageFilter<Image<short,2>, Image<unsigned char,2>> BinaryThreshold2DFilter;
typedef BinaryThresholdImageFilter<Image<short,3>, Image<unsigned char,3>> BinaryThreshold3DFilter;
typedef DiscreteGaussianImageFilter<Image<float,2>, Image<float,2>> GaussianFilter2D;
typedef DiscreteGaussianImageFilter<Image<float,3>, Image<float,3>> GaussianFilter3D;
typedef GradientMagnitudeImageFilter<Image<float,2>, Image<float,2>> GradientMagnitude2D;
typedef GradientMagnitudeImageFilter<Image<float,3>, Image<float,3>> GradientMagnitude3D;
// Array types for multi-dimensional parameters
typedef FixedArray<double, 2> Array2D;
typedef FixedArray<double, 3> Array3D;
typedef FixedArray<unsigned int, 2> UIntArray2D;
typedef FixedArray<unsigned int, 3> UIntArray3D;
// Kernel types for morphological operations
typedef BinaryBallStructuringElement<PixelType, 2> Ball2D;
typedef BinaryBallStructuringElement<PixelType, 3> Ball3D;
typedef BinaryCrossStructuringElement<PixelType, 2> Cross2D;
typedef BinaryCrossStructuringElement<PixelType, 3> Cross3D;ITK's image processing framework provides a comprehensive suite of filters for medical image analysis, from basic pixel operations to advanced feature detection and noise reduction algorithms.
Install with Tessl CLI
npx tessl i tessl/cmake-itk