import 3D volume from itk to vtk

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