# convert .nii to a mesh

**URL:** https://discourse.vtk.org/t/convert-nii-to-a-mesh/10677
**Category:** Support
**Tags:** python, code, file-formats
**Created:** [February 14, 2023, 3:36pm UTC](https://discourse.vtk.org/t/convert-nii-to-a-mesh/10677 "2023-02-14T15:36:54Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 14, 2023, 10:08pm UTC](https://discourse.vtk.org/t/convert-nii-to-a-mesh/10677/2 "2023-02-14T22:08:40Z")

</div>

Hello,

VTK has the `vtkOBJExporter` class ([https://vtk.org/doc/nightly/html/classvtkOBJExporter.html](https://vtk.org/doc/nightly/html/classvtkOBJExporter.html)) that saves the entire **scene** contained in a `vtkRenderWindow` as a `.OBJ` file. As far as I know, there is no data object-to-obj direct conversion. In other words, it exports the scene as rendered and not as data. I mean, if your volume is being rendered as a slice, there will be only a flat panel with a texture applied to it in the OBJ file (`vtkOBJExporter` also generates a complimentary `.mtl` file with material description when necessary). There is a small Python example on how to use `vtkOBJExporter` here: [https://discourse.vtk.org/t/how-can-i-export-tubes-to-obj/6015/12](https://discourse.vtk.org/t/how-can-i-export-tubes-to-obj/6015/12)

Now, if you aim at converting all the voxels of the input volume into grid cells of a mesh described as OBJ format, I believe you need to study the OBJ file format and write the code to generate the file explicitly.

take care,

Paulo

---

_[View the full topic](https://discourse.vtk.org/t/convert-nii-to-a-mesh/10677)._
