690 likes | 710 Views
Discover the history, features, and software engineering of ITK. Learn how ITK revolutionizes segmentation and registration algorithms with its modern, cross-platform design. Explore the scope of ITK and how it's supported and developed by various sponsors. Dive into the numbers and examples of ITK, and find out why it's a vital tool in medical imaging. Get started with useful code and resources to leverage ITK's powerful image processing capabilities in C++. ####
E N D
Topics • What Is ITK • History • Features • Software Engineering Methodology
ITK History • Sponsored by the National Library of Medicine as part of the Visible Human Project • Original Contract was Approximately $10 Million over 3 years • All dedicated to Implementing Existing Algorithms • Currently Only Maintenance Funding from NLM (mostly to Kitware) • Ongoing Development by User Community • ITK is a Major Part of the NA-MIC Kit
Why ITK • Provide a Standard Implementation of State of the Art Segmentation and Registration Algorithms • BSD Style Licensing • Compatible with Commercialization and Academic Research • Modern Object Oriented Design • Cross Platform • Windows, Mac, Linux, Irix, AIX, Solaris… • Run-Time Efficiency • Multi-threaded, Generic (Templated) • Carefully Engineered for Stability • Regression Testing • Documentation
ITK in Practice • ITK Only Recently Added Direction Cosine Information to Images • Supported in Most I/O • Not Supported in Most Filters or Registration • C++ Learning Curve Very Steep • Generic Programming Means Very Little Run Time Flexibility • Code is Compiled to Support Just One Data Type
Mr. ITK • Many of the following ITK slides were developed by Luis Ibanez of Kitware • Once you see Luis’ role in ITK, you’ll know that the following is more than appropriate Image courtesy Kitware, Inc.
Scope of ITK • Image Processing • Segmentation • Registration • No Graphical User Interface (GUI) • No Visualization
ITK Sponsors The National Institute for Dental and Craniofacial Research The National Science Foundation The National Institute of Neurological Disorders and Stroke
ITK Developers * indicates a subcontractor.
ITK by the Numbers • March 2000 • First code check-in • 1300 • # of nightly builds • 1062 • tests run nightly • 41 • # of platforms ( software + hardware ) • 700 • # of classes • 1600 • # of files with code
ITK by the Numbers • 400K • # of lines of code • 100K • # of lines of test code • 35K • # of lines of examples • 150K • # of lines of Applications • 240 • weekly t-cons • 50 • unique developers
ITK by the Numbers • 1032 • # of users subscribed to the mailing-list • 400 • # of emails posted monthly to the users-list • 819 • # of pages in the Software Guide PDF document • 1800 • # of monthly hits to the URL of the Software Guide PDF • 1900 • # of monthly hits to the URL of the Tutorial PDF • 2400 • # of monthly hits to the source code files (.zip + .tar.gz)
Example ITK Program #include "itkImage.h" #include "itkImageFileReader.h" #include "itkGradientMagnitudeImageFilter.h" int main( int argc, char **argv ) { typedef itk::Image<unsigned short,2> ImageType; typedef itk::ImageFileReader<ImageType> ReaderType; typedef itk::GradientMagnitudeImageFilter< ImageType,ImageType> FilterType; ReaderType::Pointer reader = ReaderType::New(); FilterType::Pointer filter = FilterType::New(); reader->SetFileName( argv[1] ); filter->SetInput( reader->GetOutput() ); filter->Update(); return 0; }
Documentation Resources • Follow the link Alphabetical List • Follow the link Groups • Post to the insight-users mailing list http://www.itk.org/ItkSoftwareGuide.pdf http://www.itk.org/Doxygen/html/index.html
The ITK Software Guide is freely available as a PDF document atwww.itk.org/ ItkSoftwareGuide.pdfIts paper version can be ordered from Amazon.com and from Kitware’s e-store.
Useful Code in ITK • Coding Infrastructure • I/O • Numerics • Based on VNL (Vision Numerics Library) • Image Processing • Convolutions, Non-Linear, Anisotropic… • Segmentation • Registration
ITK Basics • C++ Generic Programming • Data Pipeline • Multi-threading • Streaming • Exceptions • Events / Observers • Tcl, Python and Java wrapping
Generic Programming Example: STL Standard Template Library Abstraction of Types and Behaviors std::vector< T > std::vector< int > std::vector< double > std::vector< char * > std::vector< Point > std::vector< Image >
itk::Image itk::Image< PixelType , Dimension > itk::Image< char , 2 > itk::Image< char , 3 > itk::Image< char , 4 > itk::Image< float , 2 > itk::Image< RGB , 3 > itk::Image< unsigned short , 2 > itk::Image< itk::Vector<float,2> , 2 >
namespaces Avoid naming collisions itk:: itk::Statistics:: itk::fem:: itk::fem::itpack itk::bio
Your favorite keyword typedef typedef itk::Image< char , 2 > ImageType typedef itk::ImageFilter< ImageType , ImageType > FilterType otherwise... itk::ImageFilter< Image< char , 2 > ,Image< char , 2 >> FilterType
SmartPointer SmartPointer SmartPointer Smart Pointers Object counter=0 counter=1 counter=2 counter=3 Self - Delete
SmartPointers typedef itk::Image< char , 2 > ImageType typedef itk::ImageFilter< ImageType , ImageType > FilterType FilterType::Pointerfilter = FilterType::New(); ImageType::Pointerimage = filter->GetOutput(); Pointer notation filter->Update(); NO NEED FOR filter->Delete();
Const Correctness Knowing constancy is Insight. Not knowing constancy leads to disaster. Tao Te Ching, XVI. Lao Tsu
Const Smart Pointers typedef itk::Image< char , 2 > ImageType typedef itk::ImageFilter< ImageType , ImageType > FilterType FilterType::Pointerfilter = FilterType::New(); ImageType::ConstPointerimage = filter->GetOutput(); Can only invoke “const” methods image->GetSpacing (); Compiler error for “non-const” methods image->SetSpacing ( spacing );
Creating an Image typedef itk::Image< char , 3 > ImageType ImageType::Pointerimage = ImageType::New(); ImageType::SizeTypesize; size[ 0 ] = 512; // x direction size[ 1 ] = 512; // y direction size[ 2 ] = 50; // z direction ImageType::IndexTypestart; start[ 0 ] = 0; // x direction start[ 1 ] = 0; // y direction start[ 2 ] = 0; // z direction
Creating an Image ImageType::RegionTyperegion; region.SetSize( size ); region.SetIndex( start ); image->SetRegions( region ); image->Allocate(); image->FillBuffer( 0 ); ImageType::SpacingTypespacing; spacing[ 0 ] = 0.83; // x direction spacing[ 1 ] = 0.83; // y direction spacing[ 2 ] = 2.15; // z direction image->SetSpacing( spacing );
Streaming Processing Large Images Input Image Output Image Filter
LargestPossibleRegion BufferedRegion RequestedRegion Image Regions
Image Image Filter Image Filter Image Image Filter Data Pipeline
Image File Image File ImageFileReader ImageFileWriter Image Image Filter Simple Image IO
Image File ImageFileReader Image PNGImageIO MetaImageIO AnalyzeImageIO GIPLImageIO VTKImageIO DICOMImageIO CustomImageIO Simple Image IO Loadable Factories
Simple Image IO #include “itkImage.h” #include “itkImageFileReader.h” #include “itkImageFileWriter.h” typedef itk::Image<char , 2 > ImageType; typedef itk::ImageFileReader< ImageType> ReaderType; typedef itk::ImageFileWriter< ImageType> WriterType; ReaderType::Pointerreader = ReaderType::New(); WriterType::Pointerwriter = WriterType::New(); reader->SetFileName( “inputImage.dcm” ); // DICOM writer->SetFileName( “outputImage.hdr” ); // Analyze writer->SetInput( reader->GetOutput() ); writer->Update();
Segmentation Overview • Region Growing • ConfidenceConnected • ConnectedThreshold • IsolatedConnected • Watersheds • Level Sets • FastMarching • ShapeDetection • GeodesicActiveContours • ThresholdSegmentation • CannySegmentationLevelSet
Intensity Upper bound X Multiplier Standard Deviation Mean Lower bound Example: Confidence Connected Seed Point + Radius
/** /class ConfidenceConnectedImageFilter * /brief Segment pixels with similar statistics using connectivity * * This filter extracts a connected set of pixels whose pixel * intensities are consistent with the pixel statistics of a seed * point. The mean and variance across a neighborhood (8-connected, * 26-connected, etc.) are calculated for a seed point. Then * pixels connected to this seed point whose values are within * the confidence interval for the seed point are grouped. The * width of the confidence interval is controlled by the "Multiplier" * variable (the confidence interval is the mean plus or minus * the "Multiplier" times the standard deviation). If the intensity * variations across a segment were gaussian, a "Multiplier" setting * of 2.5 would define a confidence interval wide enough to capture * 99% of samples in the segment. * * After this initial segmentation is calculated, the mean and * variance are re-calculated. All the pixels in the previous * segmentation are used to calculate the mean the standard deviation * (as opposed to using the pixels in the neighborhood of the seed * point). The segmentation is then recalculted using these refined * estimates for the mean and variance of the pixel values. This * process is repeated for the specified number of iterations. * Setting the "NumberOfIterations" to zero stops the algorithm * after the initial segmentation from the seed point. * */
Confidence Connected typedef itk::Image< unsigned char , 2 > ImageType; typedef itk::ConfidenceConnectedImageFilter< ImageType, ImageType > FilterType; FilterType::Pointerfilter = FilterType::New(); filter->SetMultiplier( 1.5 ); filter->SetNumberOfIterations( 5 ); filter->SetInitialNeighborhoodRadius ( 2 ); filter->SetReplaceValue( 255 ); FilterType::IndexTypeindex; index[0] = 123; index[1] = 235; filter->SetSeed( index); filter->SetInput( reader->GetOutput() ); writer->SetInput( filter->GetOutput() ); writer->Update()
Registration Overview • Image Resampling • Registration Framework • Multi-Modality • Multi-Resolution • Deformable registration
Components Registration Method FixedImage Metric Optimizer Interpolator MovingImage Transform
Image Metrics • Mean Squares • Normalized Correlation • Mean Reciprocal Square Difference • Mutual Information- Viola-Wells- Mattes- Histogram based- Histogram normalized
Transforms • Translation • Scaling • Rotation • Rigid3D • Rigid2D • Affine • BSplines • Splines: TPS, EBS, VS
Optimizers • Gradient Descent • Regular Step Gradient Descent • Conjugate Gradient • Levenberg-Marquardt • One plus One Evolutionary Algorithm
Interpolators • Nearest Neighbor • Linear • BSpline
ITK Software Methodology • Based on “Best Practices” for Distributed Development • Built on Open Source Tools • Adopted by NA-MIC
NAMIC Software Process Dan Blezek Jim Miller Bill Lorensen