Getting Started with ITK in Python Language I
































- Slides: 32

Getting Started with ITK in Python Language I. Introduction to ITK, Python Wrapping and VTK-ITK Connection

Outline n ITK Overview (most slides are adopted from Documents in Insight Toolkit 1. 2 CD) n Python Wrapping n Installations n Examples Filter n Registration n ITK-VTK connection n n Where to get help?

What is ITK Open Source C++ Toolkit Medical Image Processing Registration Segmentation

ITK Overview n Core design concepts n Generic programming (e. g. temper late, containers, iterators. ) n Smart pointers for memory management n Object factories for adaptable object instantiation n Command/observer design paradigm for event management n Multithreading support n Cross-platform (CMake)

The Big Picture Common Basic Filters ITK Algorithms Numerics

Common Multi. Threader System Common Exceptions Data Basic Mutex Pipeline Point. Set Image Process. Object Vector. Container Data. Object Vector Map. Container Matrix Events Size Point Observer Transforms Index Mesh Histogram List. Features

Numerics Eigen SVD Matrix Classifiers Membership Functions Histogram methods Evolutionary Gradient Algorithms Descent List methods Vector Optimizers Element Linear Algebra VNL Statistics Node Numerics Solver Load Material FEM

Basic Filters Arithmetic Trigonometric Intensity Transf Morpho. Math Median Pixel. Wise Basic Filters Neighborhood Derivative IO Global Laplacian Edge. Detection Distance. Map Haussdorf. Distance PNG Meta VTK DICOM Anisotropic Connected Diffusion Components

Algorithms Interpolators Transforms Metrics Optimizers Fast Marching Narrow Band Multi Resolution Shape Detection Geodesic Contours Watershed Registration Markov RF Level Sets PDE Algorithms Connectedness Deformable Models Demons Curvature. Flow Fuzzy Hard Simple. Fuzzy Balloon Force

Pipeline Architecture n Data Flow n Data Objects Image n Mesh n n Process Objects (Algorithms) Segmentation n Registration n Image Processing n n Streaming capable

Pipeline Architecture Image Filter 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 n Level Set Framework for segmentation n FEM Framework A subsystem for solving general FEM problems, in particular non-rigid registration n IO Framework Use a flexible object factory mechanism to support a variety of file formats

Why Python Wrapping ? n Interpreted Language n Interactive n Simplifies teaching and learning n Facilitates rapid prototyping n Large python-vtk user base in our Labs

How Does It Work? n ITK Core is implemented in C++ n Tcl and Python bindings are generated automatically using a combination of gccxml -- a modified version of gcc n Cable -- processes XML info from gccxml and generates input for CSWIG n CSWIG -- modified version of SWIG that produces Python (or Tcl ) binding n n 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> Image. US 2 Image<ushort, 3> Image. US 3 Image<float, 2> Image. F 2 Image<float, 3> Image. F 3

How does it work ? ITK Filters are Templated over Image Type Gaussian. Image. Filter< Input. Image, Output. Image > Gaussian. Image. Filter< Image. U 2 , Image. U 2 > Gaussian. Image. Filter< Image. F 2 , Image. F 2 > Gaussian. Image. Filter< Image. U 2 , Image. F 2 > Gaussian. Image. Filter< Image. F 2 , Image. U 2 > Gaussian. Image. Filter< Image. F 3 , Image. U 3 >

How does it work? Python wrapper for filters should define type combinations C++ Python Gaussian. Image. Filter<Image. US 2, Image. US 2> Gaussian. Filter. US 2 Gaussian. Image. Filter<Image. F 2, Image. F 2> Gaussian. Filter. F 2 F 2 Gaussian. Image. Filter<Image. US 2, Image. F 2> Gaussian. Filter. US 2 F 2 Gaussian. Image. Filter<Image. F 2, Image. US 2> Gaussian. Filter. F 2 US 2 Gaussian. Image. Filter<Image. F 3, Image. US 3> Gaussian. Filter. F 3 US 3

VTK-ITK Connection in Python n Implemented as an module Connect. VTKITK in Insight. Application repository n Connect the pipeline with Import and Export classed in VTK and ITK VTK exporter ITK importer n ITK exporter VTK importer n n Use ITK for image processing, registration, segmentation and VTK for visualization n Status: Under active development

Installation n What do I need? n C++ Compiler -- gcc 2. 95 to 3. 3, Visual C++ 6 -7. 1 ) n CMake (1. 67 or cvs checkout) n Python (2. 1, 2. 2, or 2. 3) n VTK (4. 2. 2 or cvs checkout) n Insight (cvs checkout) n Insight. Applications n 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 n Linux comes with python and tcl/tk n Windows: python 2. 2, tcl/tk 8. 3 n Numpy (Numeric Python) n Scientific Python (Install Net. CDF library first for Net. CDF and MINC support)

Step 2 CMake Download the latest (1. 67) binary for your platform from www. cmake. org

Step 3 Install VTK n Install VTK 4. 2. 2 from source distribution. Turn on the following flags VTK_USE_HYBRID n VTK_USE_PATENTED n VTK_WRAP_PYTHON n VTK_USE_ANSI_STDLIB n

Step 4 Install Insight n Get the source cvs n Build with CMake CSWIG_WRAP_PYTHON n USE_VTK n

Step 5 Install Insight. Applications n CVS checkout n CMake n CONNECT_VTK_ITK

Step 6 Environment Variables n Linux/Unix n PYTHONPATH n LD_LIBRARY_PATY n Windows n PATH n PYTHONPATH

Examples n Curvature. Anisotropic. Diffusion. Image. Filter. py

Examples n Image. Registration 3. py

Examples : VTK-ITK Connection n Canny. Edge. Detection. Image. Filter. Connect. VTKITK. py

Where to get help? n www. itk. org n ITK Software Guild : PDF document (Over 500 pages) n Doxygen generated manual pages n Insight-users Mailing Lists n Image Labs coders mailing lists: http: //www. imaging. robarts. ca/coders