import 3D volume from itk to vtk

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:

@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.

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

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

3 Likes

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?

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})

I have the same problem.
Enabled Module_ITKVtkGlue.
Can include and use QuickView, so ITKVtkGlue is ON (with it off it doesn’t import)
I am using ITK 4.13.2.

But can’t import “itkViewImage.h”.

EDIT: I added manually the itkViewImage.h and itkViewImage.hxx from github to the source, rebuild, and got it working ( as sugested by @phcerdan in other post, thanks )

3 Likes

@Ujhik glad you got it working. :+1:

Another option is to use a newer version of ITK.

2 Likes