ITK Architecture Kitware Inc ITK Basics C Generic
ITK Architecture Kitware Inc.
ITK Basics C++ Generic Programming Data Pipeline Multi-threading Streaming Exceptions Events Tcl, / Observers 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< Pixel. Type , 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: : Statistics: : itk: : fem: : itpack itk: : bio
Your favorite keyword typedef itk: : Image< char , 2 > Image. Type typedef itk: : Image. Filter< Image. Type , Image. Type > Filter. Type otherwise. . . itk: : Image. Filter< Image< char , 2 > , Image< char , 2 > > Filter. Type
Smart Pointers Smart Pointer Object counter=3 counter=2 counter=1 counter=0 Self - Delete Smart Pointer
Smart. Pointers typedef itk: : Image< char , 2 > Image. Type typedef itk: : Image. Filter< Image. Type , Image. Type > Filter. Type: : Pointer filter = Filter. Type: : New(); Image. Type: : Pointer image = filter->Get. Output(); 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 > Image. Type typedef itk: : Image. Filter< Image. Type , Image. Type > Filter. Type: : Pointer filter = Filter. Type: : New(); Image. Type: : Const. Pointer image = filter->Get. Output(); Can only invoke “const” methods image->Get. Spacing (); Compiler error for “non-const” methods image->Set. Spacing ( spacing );
Creating an Image typedef itk: : Image< char , 3 > Image. Type: : Pointer image = Image. Type: : New(); Image. Type: : Size. Type size; size[ 0 ] = 512; // x direction size[ 1 ] = 512; // y direction size[ 2 ] = 50; // z direction Image. Type: : Index. Type start; start[ 0 ] = 0; // x direction start[ 1 ] = 0; // y direction start[ 2 ] = 0; // z direction
Creating an Image. Type: : Region. Type region; region. Set. Size( size ); region. Set. Index( start ); image->Set. Regions( region ); image->Allocate(); image->Fill. Buffer( 0 ); Image. Type: : Spacing. Type spacing; spacing[ 0 ] = 0. 83; // x direction spacing[ 1 ] = 0. 83; // y direction spacing[ 2 ] = 2. 15; // z direction image->Set. Spacing( spacing );
Exercise 3
Streaming Processing Large Images Input Image Filter Output Image
Image Regions Largest. Possible. Region Buffered. Region Requested. Region
Data Pipeline Image Filter Image
Simple Image IO Image File Image. File. Reader Image Filter Image File Image. File. Writer Image
Simple Image IO Image File PNGImage. IO Image. File. Reader Meta. Image. IO GIPLImage. IO Custom. Image. IO VTKImage. IO Image Analyze. Image. IO DICOMImage. IO Loadable Factories
Simple Image IO #include “itk. Image. h” #include “itk. Image. File. Reader. h” #include “itk. Image. File. Writer. h” typedef itk: : Image< char , 2 > Image. Type; typedef itk: : Image. File. Reader< Image. Type > Reader. Type; typedef itk: : Image. File. Writer< Image. Type > Writer. Type; Reader. Type: : Pointer reader = Reader. Type: : New(); Writer. Type: : Pointer writer = Writer. Type: : New(); reader->Set. File. Name( “input. Image. dcm” ); writer->Set. File. Name( “output. Image. hdr” ); writer->Set. Input( reader->Get. Output() ); writer->Update(); // DICOM // Analyze
Exceptions Error Management Application Layer ITK Layer
Exceptions try { filter->Update(); } catch( itk: : Exception. Object & exp ) { std: : cerr << exp << std: : endl; }
Exercise 4 Image File Caster Image. File. Reader Image. File. Writer Filter Image File
Events and Observers Itk: : Command Itk: : Object Event itk: : Command Event itk: : Command
Events and Observers Common Events Any. Event() Start. Event() End. Event() Progress. Event() Iteration. Event()
Events and Observers Itk: : Object Itk: : Process. Object Itk: : Filter. XY Itk: : Command My. Command Execute() Any. Event Add. Observer( ) My. Event
Events and Observers Itk: : Command Itk: : Object Itk: : Simple. Member. Command Itk: : Process. Object Any. Event My. Event Itk: : Filter. XY Add. Observer( ) My. Class Method. X()
Exercise 5 Image File Image. File. Reader Filter Progress. Event() Start. Event() End. Event() Image. File. Writer Command. Observer Image File Execute()
GUI Communication GUI Layer Widget Command Callback ITK Layer Filter. X Observer
Enjoy ITK !
- Slides: 29