# How to get the desired voxel index for region growing algorithms by using VTK voxel index?

**URL:** <https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016>\
**Category:** Algorithms\
**Created:** [April 7, 2021, 7:59am UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016 "2021-04-07T07:59:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![happyITK](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/779978/32.png) [@happyITK](https://discourse.itk.org/u/happyITK)\
**Post date:** [April 7, 2021, 7:59am UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/1 "2021-04-07T07:59:36Z")

</div>

Hi everyone!  
I’m a beginner of ITK and VTK.Now I want to use the 3D region growing algorithms to segment specific tissues.But I’m confused how to get the voxel index.  
I have finished the vulume rendering and could get the voxel index in VTK.But somebody said the voxel index of VTK could not be used in ITK because they have different origins.So how can I convert the index of VTK to the index in ITK?

P.S. My dicom files’ physical distance between volxels are not 1, 1, 1(mm).

Thanks, Yangfan

 ![voxel](https://discourse.itk.org/uploads/default/original/2X/3/38928d51b72b4051adc72169343cb2e21bafc049.jpeg)

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [April 7, 2021, 1:44pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/2 "2021-04-07T13:44:28Z")

</div>

Get the [world coordinates from VTK](https://discourse.vtk.org/t/mapping-between-coordinate-position-x-y-z-and-voxel-index/5357/4?u=dzenanz), then pass them to `itk::Image`'s method [`TransformPhysicalPointToIndex()`](https://itk.org/Doxygen/html/classitk_1_1ImageBase.html#ae46118e0a604c11e6f1170da7c478f81). That method will compute an `itk::Index` of the voxel in question.

Significant difference between `itk::Image` and `vtkImageData`: VTK’s image does not have orientation, whereas ITK’s does.

A bit deeper discussion is in [[SOLVED]TransformIndexToPhysicalPoint manually](https://discourse.itk.org/t/solved-transformindextophysicalpoint-manually/1031).

---

<div class="post-metadata">

**Author:** ![happyITK](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/779978/32.png) [@happyITK](https://discourse.itk.org/u/happyITK)\
**Post date:** [April 7, 2021, 1:51pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/3 "2021-04-07T13:51:26Z")

</div>

Thank you very much

---

<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:** [April 7, 2021, 2:04pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/4 "2021-04-07T14:04:11Z")

</div>

> [@dzenanz](#):
>
> Significant difference between `itk::Image` and `vtkImageData`: VTK’s image does not have orientation, whereas ITK’s does.

`vtkImageData` supports orientation since [this commit](https://github.com/Kitware/VTK/commit/60c71d2ded11aeea9b160cfa239e55c9cb9a08eb) of vtk9.0

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [April 7, 2021, 2:07pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/5 "2021-04-07T14:07:54Z")

</div>

I stand corrected. VTK now does support oriented images, but most filters ignore that and the hard work is updating them.

I also forgot to mention that ITK’s voxel coordinates are that of the center, and VTK’s are that of a corner. The above suggested couple of transformations should take care of that difference.

---

<div class="post-metadata">

**Author:** ![happyITK](https://discourse.itk.org/letter_avatar_proxy/v4/letter/h/779978/32.png) [@happyITK](https://discourse.itk.org/u/happyITK)\
**Post date:** [April 7, 2021, 2:07pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/6 "2021-04-07T14:07:59Z")

</div>

Thanks

---

<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:** [April 7, 2021, 2:18pm UTC](https://discourse.itk.org/t/how-to-get-the-desired-voxel-index-for-region-growing-algorithms-by-using-vtk-voxel-index/4016/7 "2021-04-07T14:18:44Z")

</div>

> [@dzenanz](#):
>
> but most filters ignore that and the hard work is updating them.

It would be good to know that list of filters that ignore orientation. I remember reading in VTK forums or in a git commit, saying there were not too many, but I cannot find the source ☹
