# sitk.ComposeImageFilter with list of images (python)

**URL:** https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824
**Category:** Beginner Questions
**Tags:** python, simpleitk
**Created:** [April 3, 2018, 10:28pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824 "2018-04-03T22:28:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Diego\_C](https://discourse.itk.org/user_avatar/discourse.itk.org/diego_c/32/279_2.png) [@Diego\_C](https://discourse.itk.org/u/Diego_C)
#### Post date: [April 3, 2018, 10:28pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/1 "2018-04-03T22:28:09Z")

</div>

Hello!

I am trying to use the ComposeImageFilter to combine three grayscale volumes into an RGB volume. All my images have the same metadata in regards of origin, spacing, dimensions,etc…

This is what I am doing:

```auto
def compose_image(image_list):
    filter = sitk.ComposeImageFilter(image_list)
    return filter.Execute()
```

From the ITK documentation I get this is possible since the Execute method is overloaded and one of the versions receives a vector:

 ![image](https://discourse.itk.org/uploads/default/original/1X/ab3a1a3a9299b2e9229e8015afcde26aa017413f.png)

What am I doing wrong?

Thanks,

Diego

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [April 3, 2018, 11:15pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/2 "2018-04-03T23:15:02Z")

</div>

You are passing the arguments for the execute method to the constructor. Are you wanting to use the procedural or the object oriented interface?

---

<div class="post-metadata">

### Author: ![Diego\_C](https://discourse.itk.org/user_avatar/discourse.itk.org/diego_c/32/279_2.png) [@Diego\_C](https://discourse.itk.org/u/Diego_C)
#### Post date: [April 3, 2018, 11:24pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/3 "2018-04-03T23:24:08Z")

</div>

I saw that! sorry! I tried to delete this post but I don’t have that option.

---

<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 4, 2018, 3:20pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/4 "2018-04-04T15:20:52Z")

</div>

I reverted your edit. @matt.mccormick and @fbudin can probably delete the post, but I see no reason for that. You should not be ashamed for asking questions!

---

<div class="post-metadata">

### Author: ![Diego\_C](https://discourse.itk.org/user_avatar/discourse.itk.org/diego_c/32/279_2.png) [@Diego\_C](https://discourse.itk.org/u/Diego_C)
#### Post date: [April 6, 2018, 12:31am UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/5 "2018-04-06T00:31:29Z")

</div>

Hi Dženan! I am not worried about asking, it is just that it was silly because I passed the list of images to the constructor instead of passing it to the execute method (this is what happens when you code past midnight lol). I noticed and I tried to delete the question but it was too late… 🤦🏽‍♂️ and I had a DUH! moment.

---

<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 6, 2018, 1:12pm UTC](https://discourse.itk.org/t/sitk-composeimagefilter-with-list-of-images-python/824/6 "2018-04-06T13:12:27Z")

</div>

Other people might make the same late night mistake. Having an explanation of what they should have done is helpful. Thanks for asking the question!
