Title: ITK Architecture
1ITKArchitecture
Kitware Inc.
2ITK Basics
- C Generic Programming
- Data Pipeline
- Multi-threading
- Streaming
- Exceptions
- Events / Observers
- Tcl, Python and Java wrapping
3Generic Programming
Example STL Standard Template Library
Abstraction of Types and Behaviors
stdvectorlt T gt
stdvectorlt int gt stdvectorlt double
gt stdvectorlt char gt stdvectorlt Point
gt stdvectorlt Image gt
4itkImage
itkImagelt PixelType , Dimension gt
itkImagelt char , 2 gt itkImagelt char , 3 gt
itkImagelt char , 4 gt itkImagelt float , 2 gt
itkImagelt RGB , 3 gt itkImagelt unsigned short
, 2 gt itkImagelt itkVectorltfloat,2gt , 2 gt
5namespaces
Avoid naming collisions
itk itkStatistics itkfem itkfemitpac
k itkbio
6Your favorite keyword
typedef
typedef itkImagelt char , 2 gt
ImageType typedef itkImageFilterlt ImageType ,
ImageType gt FilterType
otherwise... itkImageFilterlt Imagelt char , 2 gt
, Imagelt char , 2 gt gt
FilterType
7Smart Pointers
Object
counter0
counter1
counter2
counter3
Self - Delete
8SmartPointers
typedef itkImagelt char , 2 gt
ImageType typedef itkImageFilterlt ImageType ,
ImageType gt FilterType
FilterTypePointer filter FilterTypeNew() I
mageTypePointer image filter-gtGetOutput()
Pointer notation filter-gtUpdate()
NO NEED FOR filter-gtDelete()
9Const Correctness
Knowing constancy is Insight. Not knowing
constancy leads to disaster.
Tao Te Ching, XVI. Lao Tsu
10Const Smart Pointers
typedef itkImagelt char , 2 gt
ImageType typedef itkImageFilterlt ImageType ,
ImageType gt FilterType
FilterTypePointer filter FilterTypeNew() I
mageTypeConstPointer image filter-gtGetOutput()
Can only invoke const methods image-gtGetSpacing
()
Compiler error for non-const methods image-gtSetS
pacing ( spacing )
11Creating an Image
typedef itkImagelt char , 3 gt
ImageType ImageTypePointer image
ImageTypeNew() ImageTypeSizeType
size size 0 512 // x direction size 1
512 // y direction size 2 50 // z
direction ImageTypeIndexType start start 0
0 // x direction start 1 0 // y
direction start 2 0 // z direction
12Creating an Image
ImageTypeRegionType region region.SetSize(
size ) region.SetIndex( start ) image-gtSetRegio
ns( region ) image-gtAllocate() image-gtFillBuffer
( 0 ) ImageTypeSpacingType spacing spacing
0 0.83 // x direction spacing 1 0.83
// y direction spacing 2 2.15 // z
direction image-gtSetSpacing( spacing )
13Exercise 3
14Streaming
Processing Large Images
Output Image
Input Image
Filter
15Image Regions
16Data Pipeline
17Simple Image IO
18Simple Image IO
Loadable Factories
19Simple Image IO
include itkImage.h include itkImageFileReader
.h include itkImageFileWriter.h typedef
itkImagelt char , 2 gt ImageType typedef
itkImageFileReaderlt ImageType gt
ReaderType typedef itkImageFileWriterlt
ImageType gt WriterType ReaderTypePointer
reader ReaderTypeNew() WriterTypePointer
writer WriterTypeNew() reader-gtSetFileName
( inputImage.dcm ) // DICOM writer-gtSetFi
leName( outputImage.hdr ) //
Analyze writer-gtSetInput( reader-gtGetOutput()
) writer-gtUpdate()
20Exceptions
Error Management
Application Layer
ITK Layer
21Exceptions
try filter-gtUpdate()
catch( itkExceptionObject exp )
stdcerr ltlt exp ltlt stdendl
22Exercise 4
23Events and Observers
ItkObject
24Events and Observers
Common Events AnyEvent() StartEvent() EndEvent
() ProgressEvent() IterationEvent()
25Events and Observers
Execute()
26Events and Observers
27Exercise 5
ProgressEvent()
StartEvent()
EndEvent()
Execute()
28GUI Communication
GUI Layer
ITK Layer
29Enjoy ITK !