[vtkusers] ITK libraries in a VTK Project

Kevin H. Hobbs hobbsk at ohiou.edu
Mon Mar 10 12:08:26 EDT 2008


On Sun, 2008-03-09 at 18:56 +0200, polys_poly at hotmail.com wrote:
> How can I include the ITK libraries into my current VTK project and
> use the classes that ITK offers through the same project?

Both VTK and ITK have import image(volume) import and export classes.

	#include "vtkImageExport.h"
	#include "vtkImageImport.h"
	#include "itkVTKImageImport.h"
	#include "itkVTKImageExport.h"

CMake needs to find ITK so add the following to your CMakeLists.txt :
	FIND_PACKAGE ( ITK )
	IF ( ITK_FOUND )
		INCLUDE( ${USE_ITK_FILE} )
	ENDIF( ITK_FOUND )

Insight Applications has a very useful file,
InsightApplications/vtkITK/Common/vtkITKUtility.h for connection VTK and
ITK importers and exporters. I tell CMake where to find it in the
CMakeLists.txt
	
	INCLUDE_DIRECTORIES(
		${whatever_project_SOURCE_DIR}
		/home/kevin/kitware/InsightApplications/vtkITK/Common
		)

Then you can do things like:
	// VTK Export
	vtkImageExport * vtk_export = vtkImageExport::New();
	vtk_export->SetInputConnection( cast->GetOutputPort() );

	// ITK Import
	typedef itk::VTKImageImport< F_ImageType > ITKImportType;
	ITKImportType::Pointer itk_import = ITKImportType::New();
	ConnectPipelines( vtk_export, itk_import );

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080310/cc4e46f3/attachment.pgp>


More information about the vtkusers mailing list