# Store Images in a Vector and then Average it

**URL:** <https://discourse.itk.org/t/store-images-in-a-vector-and-then-average-it/3027>\
**Category:** Engineering\
**Tags:** average-images, vector\
**Created:** [May 4, 2020, 7:10pm UTC](https://discourse.itk.org/t/store-images-in-a-vector-and-then-average-it/3027 "2020-05-04T19:10:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![machadoL](https://discourse.itk.org/user_avatar/discourse.itk.org/machadol/32/662_2.png) [@machadoL](https://discourse.itk.org/u/machadoL)\
**Post date:** [May 4, 2020, 7:10pm UTC](https://discourse.itk.org/t/store-images-in-a-vector-and-then-average-it/3027/1 "2020-05-04T19:10:08Z")

</div>

Hey Guys,

I am generating vector images (3 images) iteratively and I would like to know how I can store those images into a vector, or array, of images, and average those 3 images to save only the final averaged one.  
Thanks for now!

---

<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:** [May 4, 2020, 8:39pm UTC](https://discourse.itk.org/t/store-images-in-a-vector-and-then-average-it/3027/2 "2020-05-04T20:39:30Z")

</div>

Storing into a vector is easy:

```cpp
std::vector<ImageType::Pointer> images;
for (...) {images.push_back(image);}

```

As for averaging, take a look at the suggestion [here](https://itk.org/pipermail/insight-users/2012-August/045669.html).

---

<div class="post-metadata">

**Author:** ![machadoL](https://discourse.itk.org/user_avatar/discourse.itk.org/machadol/32/662_2.png) [@machadoL](https://discourse.itk.org/u/machadoL)\
**Post date:** [May 4, 2020, 8:50pm UTC](https://discourse.itk.org/t/store-images-in-a-vector-and-then-average-it/3027/3 "2020-05-04T20:50:50Z")

</div>

Great… that was I was looking for.  
Thanks, man.
