# import 3D volume from itk to vtk

**URL:** https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673
**Category:** Beginner Questions
**Created:** [March 15, 2019, 5:11pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673 "2019-03-15T17:11:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [March 15, 2019, 5:11pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/1 "2019-03-15T17:11:14Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![jhlegarreta](https://discourse.itk.org/user_avatar/discourse.itk.org/jhlegarreta/32/476_2.png) [@jhlegarreta](https://discourse.itk.org/u/jhlegarreta)
#### Post date: [March 15, 2019, 5:55pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/2 "2019-03-15T17:55:57Z")

</div>

@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](https://discourse.vtk.org)

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

---

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [March 15, 2019, 6:26pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/3 "2019-03-15T18:26:03Z")

</div>

ty for your answer! I posted my question there 🙂

---

<div class="post-metadata">

### Author: ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)
#### Post date: [March 15, 2019, 6:30pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/4 "2019-03-15T18:30:09Z")

</div>

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](https://discourse.itk.org/t/display-3d-image-using-itk-and-vtk/897/10)

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

and the MWE would be:

```auto
#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](https://discourse.itk.org/uploads/default/original/1X/0a7b44a5ec79d2340f4d92bbdd7e401095e4c6ed.gif)

Hope it helps

---

<div class="post-metadata">

### Author: ![Marco\_Festugato](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_festugato/32/696_2.png) [@Marco\_Festugato](https://discourse.itk.org/u/Marco_Festugato)
#### Post date: [March 16, 2019, 9:22am UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/5 "2019-03-16T09:22:21Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)
#### Post date: [March 16, 2019, 2:45pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/6 "2019-03-16T14:45:58Z")

</div>

> [@Marco\_Festugato](#):
>
> I’ve tried to use your example and adapt it to mine, but i cant find the class references of itkViewImage.

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

```

---

<div class="post-metadata">

### Author: ![Ujhik](https://discourse.itk.org/user_avatar/discourse.itk.org/ujhik/32/703_2.png) [@Ujhik](https://discourse.itk.org/u/Ujhik)
#### Post date: [April 24, 2019, 3:04pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/7 "2019-04-24T15:04:07Z")

</div>

> [@phcerdan](#):
>
> 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 )

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [April 26, 2019, 6:30pm UTC](https://discourse.itk.org/t/import-3d-volume-from-itk-to-vtk/1673/8 "2019-04-26T18:30:55Z")

</div>

@Ujhik glad you got it working. 👍

Another option is to use a newer version of ITK.
