ITK/Examples

From KitwarePublic
Jump to navigationJump to search

These are fully independent, compilable examples. There is significant overlap in the examples, but they are each intended to illustrate a different concept and be fully stand alone compilable. Please add examples in your areas of expertise!

About the Examples

Simple Operations

Example Name ITK Classes Demonstrated Description
Catch an ITK exception Try/Catch blocks
Get the points on a Bresenham line between two points BresenhamLine
Add an offset to a pixel index Offset
Distance between two points Point
Create a vector Vector
Create a covariant vector CovariantVector
Get the name/type/class of an object GetNameOfClass()
An object which holds the index of a pixel Index
An object which holds the size of an image Size
An object which holds the index (start) and size of a region of an image ImageRegion
Make part of an image transparent RGBAPixel Transparency, RGBA, alpha
Determine if one region is fully inside another region ImageRegion Region intersection
Determine the overlap of two regions ImageRegion Region intersection
Duplicate an image ImageDuplicator
Produce an image of noise RandomImageSource
Create a vector image VectorImage An image with an ND vector at each pixel
Set specified pixels to specified values Image

Input/Output (IO)

Example Name ITK Classes Demonstrated Description
Convert a C-style array to an itkImage ImportImageFilter
Read an image file without knowing its type before hand ImageFileReader
Write an image ImageFileWriter
Read an image ImageFileReader
Write a TIFF image TIFFImageIO This is a general demonstration of how to use a specific writer rather than relying on the ImageFileWriter to choose for you.
Display an ITK image ImageToVTKImageFilter

Image Processing

Example Name ITK Classes Demonstrated Description
Compute the squared difference of corresponding pixels in two images SquaredDifferenceImageFilter
Add a constant to every pixel without duplicating the image in memory (an accessor) AddPixelAccessor
RegionalMaximaImageFilter RegionalMaximaImageFilter
ValuedRegionalMaximaImageFilter ValuedRegionalMaximaImageFilter
Pixel wise compare two input images and set the output pixel to their max MaximumImageFilter
Pixel wise compare two input images and set the output pixel to their min MinimumImageFilter
Binary AND two images AndImageFilter
Invert an image using the Binary Not operation BinaryNotImageFilter
Compose a vector image (with 3 compoennts) from three scalar images Compose3DCovariantVectorImageFilter
Extract a component of a vector image NthElementImageAdaptor
Process the nth component/element of a vector image NthElementImageAdaptor
Extract a component of a vector image ImageAdaptorExtractVectorComponent
Label binary regions in an image and get their properties BinaryImageToShapeLabelMapFilter Region bounding box, etc.
Convolve an image with a kernel ConvolutionImageFilter Convolution.
Assign contiguous labels to connected regions of an image RelabelComponentImageFilter
Crop an image CropImageFilter
Compute the absolute value of an image AbsImageFilter
Invert an image InvertIntensityImageFilter
Apply a mask to an image MaskImageFilter
Pass image pixels through a sigmoid function SigmoidImageFilter The qualitative description of how Alpha and Beta affect the function from the ITK Software Guide and the associated images would be nice to add to the doxygen.
Threshold an image ThresholdImageFilter The result is the original image but with the values below (or above) the threshold "clamped" to an output value.
Threshold an image BinaryThresholdImageFilter The result is a binary image (inside the threshold region or outside the threshold region).
Apply a custom operation to each pixel in an image UnaryFunctorImageFilter Rotate the vectors in an image.
Find the minimum and maximum value (and the position of the value) in an image MinimumMaximumImageCalculator
Add two images together AddImageFilter
Subtract two images SubtractImageFilter
Paste a part of one image into another image PasteImageFilter
Multiply two images together MultiplyImageFilter
Extract a portion of an image (region of interest) RegionOfInterestImageFilter
Rescale the intensity values of an image to a specified range RescaleIntensityImageFilter
Label connected components in a binary image ConnectedComponentImageFilter
Normalize an image NormalizeImageFilter
Cast an image from one type to another CastImageFilter
Switch the axes of an image PermuteAxesImageFilter
Linearly interpolate a position in an image LinearInterpolateImageFunction

Iterating Over (Traversing) An Image

Example Name ITK Classes Demonstrated Description
Iterate over a line through an image LineConstIterator Walks a Bresenham line through an image
Iterate over the central region (non-boundary) separately from the face-regions (boundary) ImageBoundaryFacesCalculator
Iterate over a region of an image with a neighborhood (with write access) NeighborhoodIterator
Iterate over a region of an image with a neighborhood (without write access) ConstNeighborhoodIterator
Iterate over a region of an image (with write access) ImageRegionIterator
Iterate over a region of an image (without write access) ImageRegionConstIterator
Make out of bounds pixels return a constant value ConstantBoundaryCondition
Iterate over a region of an image with efficient access to the current index (with write access) ImageRegionIteratorWithIndex
Iterate over a region of an image with efficient access to the current index (without write access) ImageRegionConstIteratorWithIndex

Image Edges, Gradients, and Derivatives

Example Name ITK Classes Demonstrated Description
Compute the derivative of an image in a particular direction DerivativeImageFilter
Find the gradient magnitude of the image first smoothed with a Gaussian kernel GradientMagnitudeRecursiveGaussianImageFilter
Find higher derivatives of an image RecursiveGaussianImageFilter
Extract the boundaries of connected regions in a binary image BinaryContourImageFilter
Extract the inner and outer boundaries of blobs in a binary image BinaryContourImageFilter
Compute the gradient magnitude image GradientMagnitudeImageFilter
Compute the Laplacian of an image LaplacianRecursiveGaussianImageFilter

Smoothing

Example Name ITK Classes Demonstrated Description
Anti alias a binary image AntiAliasBinaryImageFilter
Mean filter an image MeanImageFilter Replace each pixel by the mean of its neighborhood
Median filter an image MedianImageFilter Replace each pixel by the median of its neighborhood
Smooth an image with a discrete Gaussian filter DiscreteGaussianImageFilter
Blur an image BinomialBlurImageFilter
Bilateral filter an image BilateralImageFilter Edge preserving smoothing.
Smooth an image using curvature flow CurvatureFlowImageFilterType
Gaussian smoothing that works with image adaptors SmoothingRecursiveGaussianImageFilter

Morphology

Example Name ITK Classes Demonstrated Description
Erode a binary image BinaryErodeImageFilter
Dilate a binary image BinaryDilateImageFilter
Dilate a grayscale image GrayscaleDilateImageFilter
Erode a grayscale image GrayscaleErodeImageFilter
Erode a binary image using a flat (box) structuring element FlatStructuringElement


Spectral Analysis

Example Name ITK Classes Demonstrated Description
Compute the FFT of an image VnlFFTRealToComplexConjugateImageFilter
Compute the cross-correlation of two images in the Fourier domain VnlFFTRealToComplexConjugateImageFilterVnlFFTComplexConjugateToRealImageFilter

Utilities

Example Name ITK Classes Demonstrated Description
Monitor a filter SimpleFilterWatcher See debug style information.
Time probe TimeProbe Compute the time between points in code.

Statistics

Example Name ITK Classes Demonstrated Description
Create a Gaussian distribution GaussianDistribution
Create a histogram from a list of sample measurements SampleToHistogramFilter
Create a list of sample measurements ListSample
Create a list of samples from an image without duplicating the data ImageToListSampleAdaptor
Create a list of samples with associated class IDs MembershipSample
2D Gaussian Mixture Model Expectation Maximization ExpectationMaximizationMixtureModelEstimator EM
1D KMeans Clustering KdTreeBasedKMeansClustering
3D KMeans Clustering KdTreeBasedKMeansClustering
Cluster the pixels in a greyscale image ScalarImageKmeansImageFilter

Spatial Objects

Example Name ITK Classes Demonstrated Description
Convert a spatial object to an image SpatialObjectToImageFilter
Ellipse EllipseSpatialObject

Inspection

Example Name ITK Classes Demonstrated Description
Combine two images by alternating blocks of a checkerboard pattern CheckerBoardImageFilter

Image Registration

Example Name ITK Classes Demonstrated Description
A basic global registration of two images ImageRegistrationMethod, TranslationTransform Translation only transform.
A global registration of two images ImageRegistrationMethod, AffineTransform Full affine transform.
A global registration of two images ImageRegistrationMethod, BSplineDeformableTransform BSpline transform.
Mutual Information MutualInformationImageToImageMetric, TranslationTransform Global registration by maximizing the mutual information and using a translation only transform
Mutual Information Affine MutualInformationImageToImageMetric, AffineTransform Global registration by maximizing the mutual information and using an affine transform

Image Segmentation

Example Name ITK Classes Demonstrated Description
Mean shift clustering
KMeans Clustering
Multiphase Chan And Vese Sparse Field Level Set Segmentation itkScalarChanAndVeseSparseLevelSetImageFilter, itkScalarChanAndVeseLevelSetFunction

Meshes

Example Name ITK Classes Demonstrated Description
Decimation
Add points and edges
Compute normals of a mesh QuadEdgeMeshNormalFilter

Wish List

Example Name ITK Classes Demonstrated Description
IntensityWindowingImageFilter IntensityWindowingImageFilter
Store non-pixel associated data in an image MetaDataDictionary
Level Sets
Region Growing
Mesh subdivision
Separate foreground and background using Otsu's method OtsuThresholdImageFilter
Extract contours SimpleContourExtractorImageFilter
Present an image of RGBPixel pixels as an image of vectors RGBToVectorImageAdaptor

Included in the ITK Repository

Example Name ITK Classes Demonstrated Description
Image registration

Matlab

Example Name ITK Classes Demonstrated Description
Write data from Matlab in a format readable by ITK
Write data from ITK in a format readable by Matlab

Developer Examples

Example Name ITK Classes Demonstrated Description
Produce an image programmatically. ImageSource Nothing in, image out.
Filter an image ImageToImageFilter Image in, same type of image out.
Write a filter with multiple inputs of the same type. ImageToImageFilter Two images in (same type), same type of image out.
Write a filter with multiple inputs of different types. ImageToImageFilter Two images in (different type), image (same type as first input) out.
Write a filter with multiple outputs of the same type. ImageToImageFilter Images in, two images out (same type as first input).

Problems

Small Problems

Example Name ITK Classes Demonstrated Description
Compute the gradient of a vector image GradientImageFilter How to do this?
Compute the Laplacian of an image GaussianMixtureModelComponent Input image type must be double or float (probably should smooth before this anyway, so do this type conversion in the smoothing filter?
Compute distributions of image pixels using GMM EM GaussianMixtureModelComponent
Compute distributions of image pixels using GMM EM ExpectationMaximizationMixtureModelEstimator
Compute distributions of samples using GMM EM ExpectationMaximizationMixtureModelEstimator Someone please confirm that this outputs the mean and the variance (i.e. I used a standard deviation of 30 to create the samples and the second estimated parameter is near 1000 (~30^2) . Is this correct?)
Find edges in an image CannyEdgeDetectionImageFilter How to set a reasonable Threshold for the output edges?
Variable length vector VariableLengthVector main() works properly, but neither conversion seems to work.
Compute the histogram of an image ImageToHistogramFilter The last entry of the red histogram should contain several values, but it is 0?
Classifying pixels using KMeans KmeansModelEstimator How to apply the labels of the filter to the input image?
Basic region growing RegionGrowImageFilter Just getting started with demo...
Find connected components in an image ConnectedThresholdImageFilter Just need to finish it.
Convert an image from one type to another ConvertPixelBuffer
Apply a function to every pixel with access to its neighborhood NeighborhoodOperatorImageFilter
Apply a function to every pixel with access to its neighborhood NeighborhoodOperatorImageFunction
In-place filtering of an image InPlaceImageFilter This only works for filters which derive from itkInPlaceImageFilter
Pad an image with a constant value ConstantPadImageFilter Not sure how to specify the final output size/extent. The documentation should be improved.
Pad an image MirrorPadImageFilter Not sure how to specify the final output size/extent. The documentation should be improved.
Pad an image by wrapping WrapPadImageFilter Not sure how to specify the final output size/extent. The documentation should be improved.
Shrink an image ShrinkImageFilter Image doesn't seem to be shrunk?
Flip an image over specified axes FlipImageFilter The axes specification is not quite right - warning: address of axes always evaluates true
Convert a VTK image to an ITK image VTKImageToImageFilter Seems to expect an input image with only 1 component? (i.e. greyscale)
Normalized correlation NormalizedCorrelationImageFilter Output is all black?
Iterate over a region of an image with a shaped neighborhood ShapedNeighborhoodIterator Crashes when initializing the iterator loop?

Big Problems

Example Name ITK Classes Demonstrated Description
Join images, stacking their components JoinImageFilter How to convert the vector image produced by the joinFilter to a standard image?
Find the best position of the moving image in the fixed image. MeanSquaresImageToImageMetric Output (0,0) is incorrect.
Translate an image TranslationTransform, ResampleImageFilter This example currently freezes.
Compute and display the gradient of an image GradientImageFilter Blank output.