import 3D volume from itk to vtk


(Marco Festugato) #1

Hi guys! I’ve managed to read 200 DICOM files and use them to compose a volume…how can i pass this volume to VTK in order to actually see it?
Thank u all for your answer :slight_smile:


(Jon Haitz Legarreta Gorroño) #2

@Marco_Festugato Dženan has kindly answered the very same question posted to the (deprecated) insight-users mailing list, and I’ve just added that VTK has recently transitioned to discourse as well:
https://discourse.vtk.org

Since yours is a question related to VTK, please post your question at the VTK discourse forum.


(Marco Festugato) #3

ty for your answer! I posted my question there :slight_smile:


(Pablo Hernandez-Cerdan) #4

ITK in the module ITKVtkGlue provides a simple viewer for 2D and 3D ITK images using VTK.

Read more about it and see examples in this ITK discourse post: Display 3D image using ITK and VTK

See an example here: https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Bridge/VtkGlue/test/runViewImage.cxx

and the MWE would be:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkViewImage.h"
int main(int argc, char *argv[])
{
  using PixelType = float;
  constexpr unsigned int Dimension = 3;
  using ImageType = itk::Image<PixelType, Dimension>;
  using ReaderType = itk::ImageFileReader<ImageType>;
  auto reader = ReaderType::New();
  reader->SetFileName("MR-head.nrrd");
  reader->Update();
  itk::ViewImage<ImageType>::View(reader->GetOutput());
}

MR-headVIEW

Hope it helps


(Marco Festugato) #5

Hi Pablo and thank u for your kind answer. I’ve tried to use your example and adapt it to mine, but i cant find the class references of itkViewImage and when building with VS 2015 i received a fatal error (class not identified)…i obviously use the include…
Can’t i use a class already implemented in itk/vtk to ‘transfer’ my volume?


(Pablo Hernandez-Cerdan) #6

Did you enable the ITKVtkGlue module when configuring/building ITK? Configure ITK with Module_ITKVtkGlue switched ON and try again.

This is the CMakeLists.txt with the minimum set of ITK components required for the example.

cmake_minimum_required(VERSION 3.8)
project(viewimage_MWE)

find_package(ITK REQUIRED COMPONENTS
  ITKCommon
  ITKImageIO
  ITKVtkGlue
  )
include(${ITK_USE_FILE})
add_executable(minimum_viewimage minimum_viewimage.cpp)
target_link_libraries(minimum_viewimage ${ITK_LIBRARIES})