# How to wrap a \`std::vector\<ImagePointer\>\` in swig with ITKWrap

**URL:** <https://discourse.itk.org/t/how-to-wrap-a-std-vector-imagepointer-in-swig-with-itkwrap/227>\
**Category:** Community\
**Tags:** python\
**Created:** [September 27, 2017, 5:38am UTC](https://discourse.itk.org/t/how-to-wrap-a-std-vector-imagepointer-in-swig-with-itkwrap/227 "2017-09-27T05:38:17Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [September 27, 2017, 5:38am UTC](https://discourse.itk.org/t/how-to-wrap-a-std-vector-imagepointer-in-swig-with-itkwrap/227/1 "2017-09-27T05:38:17Z")

</div>

I have a couple of helper functions [here](https://github.com/phcerdan/ITKIsotropicWavelets/blob/master/include/itkWaveletFrequencyInverse.h#L120) and [here](https://github.com/phcerdan/ITKIsotropicWavelets/blob/master/include/itkWaveletFrequencyForward.h#L69), which deal with `std::vector<itk::Image<X,Dim>::Pointer>`, as input argument in the first case, and as an output for the later.

I have an usable python module (`pip install itk-isotropicwavelets`), but is not fully wrapping the [external module](https://github.com/phcerdan/ITKIsotropicWavelets). When using those classes I get a few issues involving this unwrapped vector:

1. `swig/python detected a memory leak of type 'std::vector< itkImageCF2_Pointer,std::allocator< itkImageCF2_Pointer > > *', no destructor found.` when using the first case with `waveletForward.GetOutputs()`

2. The swig objects are [non-mutable](https://stackoverflow.com/questions/37328310/swig-c-vector-access-in-python) from python.

3. I cannot generate a new swig-object from python to use it as input for `waveletInverse.GetInputs(a_vector_of_image_pointers)`

I have no much knowledge about `swig`, but I have seen there are different types in `itk.vector`, such as `itk.vector.itkStatisticalLabelObjectUL2`, and they seem generated in [Wrapping/WrapITKTypes](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Wrapping/WrapITKTypes.cmake).

Is it possible to modify or append types from an external module? Is there an existing wrapped type for std::vector of ImagePointers?

Thanks!

---

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [October 2, 2017, 8:12pm UTC](https://discourse.itk.org/t/how-to-wrap-a-std-vector-imagepointer-in-swig-with-itkwrap/227/2 "2017-10-02T20:12:10Z")

</div>

Hi @phcerdan,

One option to address this issue is to use [itk::VectorContainer](https://itk.org/Doxygen/html/classitk_1_1VectorContainer.html), which is wrapped and has a `ModifiedTime` so it can be used in ITK pipelines.
