DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Interactions between ITK and DGtal using ITKImage

Table of Contents

Author:
David Coeurjolly

This part of the manual describe the interactions between DGTal and InsightToolkit ITK library (http://www.itk.org).

itk-logo.png
See also:
testITKImage.cpp
Note:
The features detailed below require to have built DGtal with the ITK dependency. Furthermore, since it is on-going work, the features has been declared in the DGtal::experimental namespace.

The junction point between DGtal and ITK is implemented via a specific image container: experimental::ImageContainterByITKImage.

For short, if you create an instance of this image type (using StdDefs shortcuts):

typedef experimental::ImageContainerByITKImage<Z2i::Domain, Z2i::Integer> Image;
Z2i::Point a ( 0,0 );
Z2i::Point b ( 128, 128 );
Image myImage ( a, b );

Since ImageContainerByITKImage is a model of the CImageContainer concept, all DGtal tools working on valid image containers are also compatible with the ITK container.

ITK pipeline in DGtal

In the following example, we use ITK methods and ITK pipeline to process an image within DGtal (simple image thresholding):

//We construct a simple ITK pipeline
typedef itk::BinaryThresholdImageFilter< Image::ITKImage, Image::ITKImage> Filter;
Filter::Pointer filter = Filter::New();
filter->SetInput( myImage.getImagePointer() );
filter->SetOutsideValue( 0 );
filter->SetInsideValue( 10 );
filter->SetLowerThreshold( 34 );;
filter->SetUpperThreshold( 400 );;
filter->Update();
//We create a DGtal::Image from a pointer to the pipeline output
Image::ITKImagePointer handleOut = filter->GetOutput();
Image myImageOut ( a, b, handleOut );

Based on this example, we can see that:

DGtal methods in ITK

Using a similar approach, DGtal methods can be used in a ITK pipeline with the help of a kind of wrapper filter. Indeed, ITK is based on a pipeline with filters connected by SetInput() and GetOutput() methods.

DGtal is not based on the same stream process. Hence, if you would like to use DGtal data and methods in ITK, you will have to create a simple ITK filter satisfying the stream mechanism API and whose internal computation method will instantiate DGtal objects and use DGtal methods.