Difference between revisions of "ITK/Scripting"

From KitwarePublic
< ITK
Jump to navigationJump to search
(Created from antonym)
 
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
ITK itself is written in C++, however a tool called CableSwig can be used to generate bindings for other languages.  This allows you to use the same runtime (running in optimised C++ code) but develop in a scripting language (and take advantage of all the attendant benefits).
This page needs to be updated for WrapITK, which is now the wrapping method.


The following languages are supported via the bindings:
{{ITK/Template/Footer}}
 
* '''Tcl''' : http://www.tcl.tk/ (see TclLanguage)
* '''Python''' : http://www.python.org/ (see PythonLanguage)
* '''Java''' : http://java.sun.com/ (see JavaLanguage)
 
In order to build the bindings, you will need to:
 
# Build and install CableSwig ([http://www.itk.org/HTML/CableSwig.html more info])
# Ensure you have installed both the runtime '''and''' the development versions of your chosen language
# Build ITK using the appropriate settings for your platform, and enable the CABLE_* option for your language
# Install ITK as per normal
# Test!
 
== Tcl Bindings ==
 
Tcl (Tool Command Language) is a very simple language for writing scripts.
 
== Python Bindings ==
 
Python is a very elegant and powerful language.
 
Here is some example Python code for ITK (taken from `Insight/Examples/Filtering`):
 
#!/usr/bin/env python
&nbsp;
# BinaryThresholdImageFilter.py
&nbsp;
from InsightToolkit import *
&nbsp;
from sys import argv
&nbsp;
reader = itkImageFileReaderUS2_New()
writer = itkImageFileWriterUS2_New()
&nbsp;
filter  = itkBinaryThresholdImageFilterUS2US2_New()
&nbsp;
filter.SetInput( reader.GetOutput() )
writer.SetInput( filter.GetOutput() )
&nbsp;
reader.SetFileName( argv[1] )
writer.SetFileName( argv[2] )
&nbsp;
filter.SetLowerThreshold( eval( argv[3] )  )
filter.SetUpperThreshold( eval( argv[4] )  )
filter.SetOutsideValue(  eval( argv[5] )  )
filter.SetInsideValue(    eval( argv[6] )  )
&nbsp;
writer.Update()
 
== Java Bindings ==
 
Java is a modern object-oriented language.

Latest revision as of 17:00, 11 February 2012

This page needs to be updated for WrapITK, which is now the wrapping method.



ITK: [Welcome | Site Map]