# Recommended API for iterating over a whole image or its subset

**URL:** https://discourse.paraview.org/t/recommended-api-for-iterating-over-a-whole-image-or-its-subset/3751
**Category:** Development
**Tags:** vtk
**Created:** [March 5, 2020, 9:17am UTC](https://discourse.paraview.org/t/recommended-api-for-iterating-over-a-whole-image-or-its-subset/3751 "2020-03-05T09:17:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yohanlty\_total](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yohanlty\_total](https://discourse.paraview.org/u/yohanlty_total)
#### Post date: [March 5, 2020, 9:17am UTC](https://discourse.paraview.org/t/recommended-api-for-iterating-over-a-whole-image-or-its-subset/3751/1 "2020-03-05T09:17:37Z")

</div>

Hello,

I am writing a ParaView plugin where I encounter the following 2 cases:  
1- for the 1rst I need to iterate over the surrounding adjacents points of a vtkImageData;  
2- for the other one, I have to do a whole sweep merging 2 Images + and 2 optionals mask (1 as a 2D image, the second a regular 3D one).

As the 3D image may be large (~300MB for the smallest representative unit test, in float), I was wondering which API is now recommended.

I saw on the not up-to-date VTK reference book at p. 404 that you may use _vtkImageIterator_ and I am wondering if this is still the recommended practice before diving into learning them.  
With it I can go into multithreading, but may encounter some issue like this one ([https://gitlab.kitware.com/paraview/paraview/issues/14236](https://gitlab.kitware.com/paraview/paraview/issues/14236)) under the road.

I also saw this tutorial about DataArray ([https://vtk.org/Wiki/VTK/Tutorials/DataArrays](https://vtk.org/Wiki/VTK/Tutorials/DataArrays)), and it seemed to me that the _dispatcher_ is the new way to go.

Which one should I be learning and using for each case ?  
If it is the _dispatcher_ do you have a link explaining it ?

Best regards,

PS: The data would always be «float» with only 1 component.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 5, 2020, 2:48pm UTC](https://discourse.paraview.org/t/recommended-api-for-iterating-over-a-whole-image-or-its-subset/3751/2 "2020-03-05T14:48:37Z")

</div>

Hi Yohan,

Your question is quite vtk-centric.  
You may have more luck for help in our VTK discourse :  
[https://discourse.vtk.org/](https://discourse.vtk.org/)

---

<div class="post-metadata">

### Author: ![yohanlty\_total](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/y/ecd19e/32.png) [@yohanlty\_total](https://discourse.paraview.org/u/yohanlty_total)
#### Post date: [March 5, 2020, 3:06pm UTC](https://discourse.paraview.org/t/recommended-api-for-iterating-over-a-whole-image-or-its-subset/3751/3 "2020-03-05T15:06:08Z")

</div>

Thank you Mathieu for the answer, I didn’t know that vtk had also its discourse.  
Have a nice day
