ITK/Insight Applications

From KitwarePublic
Jump to navigationJump to search

The Insight Toolkit itself is an "engine", and has no dependencies or requirements on any particular GUI or visualisation libraries. (In fact ITK can easily be used to write both console and batch-mode applications.)

InsightApplications (CVS) (installation instructions) is a separate CVS repository that contains a wide variety of sample code, that demonstrate how to build complete applications with ITK.


Here is a small selection of the applications included:

  • SNAP : A complete segmentation tool
  • ... many more ...

Building Insight Applications

This section describes how to build the Insight Applications.


The following information is aimed at version 1.6 of the toolkit:

  • ITK version 1.6+
  • FLTK version 1.1.3 (FLTK 2.x is not supported)
  • Qt version 2.0+
  • VTK version 4.2
  • OpenGL/GLUT version 1.2+

The most commonly used GUI is FLTK, and many applications use VTK also. If you have these two libraries, you can build most of the applications.

FLTK installation

As of version 1.1.6 FLTK can now be configured using CMake. Otherwise, if not configured with CMake, make sure that you have an installed version of FLTK. The installation process actually create symbolic links to the correct headers.

Matching Version

Note that it is very important to match the version of InsightApplications with the version of ITK you are using. Thus, if you have version 1.6.0 of the toolkit installed, you should download the corresponding version 1.6.0 of InsightApplications here. If you have installed ITK from a CVS build, you should obtain a checkout of the applications from the same day. Further instructions can be found in BuildingFromCVS.

Build Instructions

Create a separate directory for the build, eg:

% cd ~/projects/InsightApplications-1.6.0
% mkdir Build
% cd Build

Run CMake, pointing it at the top-level of the source directory:

% ccmake ..

The first time CMake comes up, you just need to press 'c' to perform the first-time configure step. This should find your compiler and other libraries. You may get a warning telling you that it is setting the CXX compiler to `g++` to match that imported from ITK; you can safely ignore this with 'e' and continue.

You are then presented with the first round of settings. Make the changes as summarised in the next section.

CMake Build Settings

The following settings are recommended to change from the default:


Press 'c' again to configure this selection. If any of the libraries are not found in their default locations, you may get a warning, in which case you need to manually specify their locations. For example, on my system `VTK_DIR` comes up as `VTK_DIR-NOTFOUND` so I set it manually to `/usr/local/vtk/lib/vtk`.

Keep pressing 'c' to configure, and check any options that are highlighted with an asterisk '*'. Fill out any missing library locations, and eventually you will get the 'g' option enabled to generate the makefile.


Assuming all the libraries were found, and the makefiles were generated, you can now you can start the compile:

% make

This can take quite some time, depending on the speed of your machine.


TBC: currently the applications do not install themselves, so running `make install` will have no effect.


You can simply run the applications from where they have been compiled.

Note that it may be convenient to have certain commonly used applications (such as the `ImageViewer` available on your path.

A note about paths

Many applications use the common libraries found in `InsightApplications/Auxiliary`. These need to be found at runtime by the system, so you can either:

  • add the directory to your `PATH` (under Windows) or `LD_LIBRARY_PATH` (under *nix systems), or
  • under *nix, rely on the rpath option being set to hard-code in the executables the location of the extra libraries

Compiling FLTK-dependent components on Mac

MacPorts can be used to install the compatible version of FLTK on Mac (tested on Snow Leopard). This installs a 32-bit version of FLTK, since there seem to be known issues related to 64-bit install.

Because of this, ITK used in ITKApps also needs to be compiled in 32-bit mode. To do this, set the following flags before running cmake and configuring ITK, compile ITK, then use the same flags in ITKApps:


To compile ImageViewer, you need to enable FLTK and Auxiliary flags in CMake.

Finally, the png and jpeg libs installed by mac ports are not correctly resolved during linking ImageViewer. I pointed compiler explicitly to /opt/local/lib/lib{png|jpeg}.a to resolve this issue.

ITK: [Welcome | Site Map]