# how to get the 0-th component for vector image

**URL:** <https://discourse.itk.org/t/how-to-get-the-0-th-component-for-vector-image/2759>\
**Category:** Beginner Questions\
**Created:** [February 24, 2020, 9:30am UTC](https://discourse.itk.org/t/how-to-get-the-0-th-component-for-vector-image/2759 "2020-02-24T09:30:56Z")\
**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:** [February 24, 2020, 2:05pm UTC](https://discourse.itk.org/t/how-to-get-the-0-th-component-for-vector-image/2759/2 "2020-02-24T14:05:09Z")

</div>

You could use VectorIndexSelectionCastImageFilter to split the multicomponent image into separate images. Then you could multiply each component image by whatever factor you’d like. Finally you’d use the ComposeImageFilter to combine the separated component images back together into one vector image.

Here are the docs of the two filters:  
[https://itk.org/Doxygen/html/classitk\_1\_1VectorIndexSelectionCastImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1VectorIndexSelectionCastImageFilter.html)  
[https://itk.org/Doxygen/html/classitk\_1\_1ComposeImageFilter.html](https://itk.org/Doxygen/html/classitk_1_1ComposeImageFilter.html)

A similar question came up earlier (except using SimpleITK and Python). You can see my example reply here:

> [@add alpha channel to an image in simpleitk](https://discourse.itk.org/t/add-alpha-channel-to-an-image-in-simpleitk/2665/2):
>
> 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/how-to-get-the-0-th-component-for-vector-image/2759)._
