Getting Started with ITK in
Python Language
I. Introduction to ITK, Python Wrapping
and VTK-ITK Connection
Outline
 ITK Overview (most slides are adopted from
Documents in Insight Toolkit 1.2 CD)
 Python Wrapping
 Installations
 Examples



Filter
Registration
ITK-VTK connection
 Where to get help?
What is ITK
Open Source C++ Toolkit
Medical Image
Processing
Registration
Segmentation
ITK Overview
 Core design concepts
 Generic programming (e.g. temper late,
containers, iterators.)
 Smart pointers for memory management
 Object factories for adaptable object
instantiation
 Command/observer design paradigm for event
management
 Multithreading support
 Cross-platform (CMake)
The Big Picture
Common
Basic Filters
ITK
Algorithms
Numerics
Common
MultiThreader
System
Common
Exceptions
Data
Basic
Mutex
Pipeline
PointSet
Image
ProcessObject
VectorContainer
DataObject
Vector
MapContainer
Matrix
Events
Size
Point
Observer
Transforms Index
Mesh
Histogram
ListFeatures
Numerics
Eigen
SVD
Matrix
Classifiers
Membership
Functions
Histogram
methods
Evolutionary
Gradient Algorithms
Descent
List
methods
Vector
Optimizers
Optimizers
Element
Linear
Algebra
VNL
Statistics
Node
Numerics
Solver
Load
Material
FEM
Basic Filters
Arithmetic
Trigonometric
Intensity Transf
MorphoMath
PixelWise
Basic Filters
Neighborhood
Median
Derivative
IO
Global
Laplacian
EdgeDetection
DistanceMap
HaussdorfDistance
PNG
Meta
VTK
DICOM
Anisotropic Connected
Diffusion
Components
Algorithms
Interpolators
Transforms
Optimizers
Metrics
Fast
Marching
Narrow
Band
Multi
Resolution
Shape
Detection
Geodesic
Contours
Watershed
Registration
Markov RF
Level Sets
PDE
Algorithms
Connectedness
Demons
CurvatureFlow
Fuzzy
Hard
Deformable
Models
SimpleFuzzy
Balloon Force
Pipeline Architecture
 Data Flow

Data Objects
Image
 Mesh


Process Objects (Algorithms)
Segmentation
 Registration
 Image Processing


Streaming capable
Pipeline Architecture
Image
Filter
Image
Filter
Image
Filter
Image
Image
Architecture
Streaming – Processing Large Images
Input
Image
Filter
Output
Image
Registration Framework
Multi
Resolution
Registration
Framework
Image
Registration
Framework
Components
PDE
Based
Registration
FEM
Based
Registration
Registration Components
Registration Method
Fixed
Image
Metric
Interpolator
Moving
Image
Transform
Optimizer
Other Frameworks
 Level Set Framework for segmentation
 FEM Framework
A subsystem for solving general FEM problems,
in particular non-rigid registration
 IO Framework
Use a flexible object factory mechanism to
support a variety of file formats
Why Python Wrapping ?
 Interpreted Language
 Interactive
 Simplifies teaching and learning
 Facilitates rapid prototyping
 Large python-vtk user base in our Labs
How Does It Work?
 ITK Core is implemented in C++
 Tcl and Python bindings are generated
automatically using a combination of



gccxml -- a modified version of gcc
Cable -- processes XML info from gccxml and
generates input for CSWIG
CSWIG -- modified version of SWIG that
produces Python (or Tcl ) binding
 Under active development, no binary
installation package yet.
How does it work ?
Python wrapping requires fully specified C++ types
Image<T,N>
C++
Python
Image<ushort,2>
ImageUS2
Image<ushort,3>
ImageUS3
Image<float,2>
ImageF2
Image<float,3>
ImageF3
How does it work ?
ITK Filters are Templated over Image Type
GaussianImageFilter< InputImage, OutputImage >
GaussianImageFilter< ImageU2 , ImageU2 >
GaussianImageFilter< ImageF2 , ImageF2 >
GaussianImageFilter< ImageU2 , ImageF2 >
GaussianImageFilter< ImageF2 , ImageU2 >
GaussianImageFilter< ImageF3 , ImageU3 >
How does it work?
Python wrapper for filters should define type combinations
C++
Python
GaussianImageFilter<ImageUS2,ImageUS2>
GaussianFilterUS2US2
GaussianImageFilter<ImageF2,ImageF2>
GaussianFilterF2F2
GaussianImageFilter<ImageUS2,ImageF2>
GaussianFilterUS2F2
GaussianImageFilter<ImageF2,ImageUS2>
GaussianFilterF2US2
GaussianImageFilter<ImageF3,ImageUS3>
GaussianFilterF3US3
VTK-ITK Connection in Python
 Implemented as an module ConnectVTKITK
in InsightApplication repository
 Connect the pipeline with Import and Export
classed in VTK and ITK


VTK exporter  ITK importer
ITK exporter  VTK importer
 Use ITK for image processing, registration,
segmentation and VTK for visualization
 Status: Under active development
Installation
 What do I need?
 C++ Compiler -- gcc 2.95 to 3.3, Visual C++ 6 -7.1 )
 CMake (1.67 or cvs checkout)
 Python (2.1, 2.2, or 2.3)
 VTK (4.2.2 or cvs checkout)
 Insight (cvs checkout)
 InsightApplications
 Installation for Python-VTK-ITK is not straight forward
right now, no binary distribution. A step by step
instruction will be posted on Image Lab coders’ web
page.
Step 1 Python and modules
 Linux comes with python and tcl/tk
 Windows: python 2.2, tcl/tk 8.3
 Numpy (Numeric Python)
 Scientific Python (Install NetCDF library first
for NetCDF and MINC support)
Step 2 CMake
Download the latest (1.67) binary for your
platform from www.cmake.org
Step 3 Install VTK
 Install VTK 4.2.2 from source distribution .
Turn on the following flags




VTK_USE_HYBRID
VTK_USE_PATENTED
VTK_WRAP_PYTHON
VTK_USE_ANSI_STDLIB
Step 4 Install Insight
 Get the source
cvs
 Build with CMake


CSWIG_WRAP_PYTHON
USE_VTK
Step 5 Install InsightApplications
 CVS checkout
 CMake

CONNECT_VTK_ITK
Step 6 Environment Variables
 Linux/Unix


PYTHONPATH
LD_LIBRARY_PATY
 Windows


PATH
PYTHONPATH
Examples
 CurvatureAnisotropicDiffusionImageFilter.py
Examples
 ImageRegistration3.py
Examples : VTK-ITK Connection
 CannyEdgeDetectionImageFilterConnectVTKITK.py
Where to get help?
 www.itk.org



ITK Software Guild : PDF document (Over 500
pages)
Doxygen generated manual pages
Insight-users Mailing Lists
 Image Labs coders mailing lists:
http://www.imaging.robarts.ca/coders
Descargar

ITK, VTK and Python