From Ohm

Hello ITK

As the first ITK example we simply compile an ITK demo application:

For that we copy the HelloWorld.cxx and CMakeLists.txt from the Examples/Installation directory into a newly created directory.

In that directory, we set ITK_DIR to the directory where ITK was built by using the cmake curses gui and compile the usual way with “cmake . && make”. Just like so:

export ITK_DIR="path_to_ITK-build_directory"
cd "path_to_ITK-example"
cmake . && make

The ITK Hello World example simply shows a message on the console. It also silently defines a new type for an 3D image, that is a volume:

#include "itkImage.h"

typedef itk::Image< unsigned short, 3 > Image3DType;

Then it creates a new empty volume:

Image3DType::Pointer image = Image3DType::New();

The latter pointer is a so called reference-counted pointer, meaning that the number of references to a particular volume are kept track of. If the number of references (pointers pointing to a volume) is zero, because the last pointer goes out of scope, the unreferenced volume is automatically released.

That’s all for the moment.

Retrieved from

Page last modified on November 16, 2020, at 04:04 PM