# ImageRegionIterator object in python

**URL:** https://discourse.itk.org/t/imageregioniterator-object-in-python/818
**Category:** Beginner Questions
**Tags:** module, python
**Created:** [April 1, 2018, 1:48pm UTC](https://discourse.itk.org/t/imageregioniterator-object-in-python/818 "2018-04-01T13:48:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lwyyy](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@lwyyy](https://discourse.itk.org/u/lwyyy)
#### Post date: [April 1, 2018, 1:48pm UTC](https://discourse.itk.org/t/imageregioniterator-object-in-python/818/1 "2018-04-01T13:48:05Z")

</div>

Hi,

I installed ITK on mac python 2.7 using command “python -m pip install itk”, and when I wanted to create an ImageRegionIterator object, it had an error – “AttributeError: ‘LazyITKModule’ object has no attribute ‘ImageRegionIterator’”. I had read the source code and found that there isn’t any file containing ImageRegionIterator.  
I need to use the ImageRegionIterator and ImageRegionConstIterator in python. How can I create an ImageRegionIterator object in python script?

Thanks a lot!

Wanyu

---

<div class="post-metadata">

### Author: ![fbudin](https://discourse.itk.org/user_avatar/discourse.itk.org/fbudin/32/14_2.png) [@fbudin](https://discourse.itk.org/u/fbudin)
#### Post date: [April 2, 2018, 4:39pm UTC](https://discourse.itk.org/t/imageregioniterator-object-in-python/818/2 "2018-04-02T16:39:37Z")

</div>

Iterators are not wrapped in Python. Iterators are not efficient when wrapped. If you want to loop over the image you can either do it the slow way, with loops, or use NumPy arrays and NumPy features which will be more optimized.

---

<div class="post-metadata">

### Author: ![lwyyy](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/94ad74/32.png) [@lwyyy](https://discourse.itk.org/u/lwyyy)
#### Post date: [April 4, 2018, 9:52am UTC](https://discourse.itk.org/t/imageregioniterator-object-in-python/818/4 "2018-04-04T09:52:05Z")

</div>

I will replace iterators with Numpy array. It’s very helpful.  
Thanks a lot!

Wanyu
