# add alpha channel to an image in simpleitk

**URL:** <https://discourse.itk.org/t/add-alpha-channel-to-an-image-in-simpleitk/2665>\
**Category:** Beginner Questions\
**Tags:** simpleitk\
**Created:** [January 31, 2020, 3:42am UTC](https://discourse.itk.org/t/add-alpha-channel-to-an-image-in-simpleitk/2665 "2020-01-31T03:42:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)\
**Post date:** [January 31, 2020, 2:09pm UTC](https://discourse.itk.org/t/add-alpha-channel-to-an-image-in-simpleitk/2665/2 "2020-01-31T14:09:13Z")

</div>

You can use the VectorIndexSelectionCast function to split an RGB image into separate components. Then create an alpha image of matching dimensions and use the Compose function to combine all four channels into an RGBA image.

Here’s an example

```
rgb = sitk.Image(100,100,sitk.sitkVectorUInt8)

r = sitk.VectorIndexSelectionCast(rgb, 0)
g = sitk.VectorIndexSelectionCast(rgb, 1)
b = sitk.VectorIndexSelectionCast(rgb, 2)

a = sitk.Image(100,100,sitk.sitkUInt8)

rgba = sitk.Compose(r, g, b, a)
```

---

_[View the full topic](https://discourse.itk.org/t/add-alpha-channel-to-an-image-in-simpleitk/2665)._
