# SimpleITK: Channel storage order?

**URL:** https://discourse.itk.org/t/simpleitk-channel-storage-order/1027
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [June 22, 2018, 5:26pm UTC](https://discourse.itk.org/t/simpleitk-channel-storage-order/1027 "2018-06-22T17:26:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![szhorvat](https://discourse.itk.org/user_avatar/discourse.itk.org/szhorvat/32/384_2.png) [@szhorvat](https://discourse.itk.org/u/szhorvat)
#### Post date: [June 22, 2018, 5:26pm UTC](https://discourse.itk.org/t/simpleitk-channel-storage-order/1027/1 "2018-06-22T17:26:46Z")

</div>

I am looking at the BufferImportExport example in SimpleITK: [https://itk.org/SimpleITKDoxygen/html/BufferImportExport\_8cxx-example.html](https://itk.org/SimpleITKDoxygen/html/BufferImportExport_8cxx-example.html)

I was wondering what channel storage order SimpleITK uses. Is it interleaved (i.e. `rgbrgbrgb...`) or not (`rrr...ggg...bbb...`), and is it configurable? This is relevant when using an existing image buffer to interface with another system.

I did do an experiment and it looks like SimpleITK interleaves channels by default. So the remaining question: is this configurable? The system I am interfacing with supports both orders and I cannot predict what kind of data I will receive. It would be easiest to tell ITK what I have. Does ITK support both orders? If not, can `ImportImageFilter` (or something similar) do the conversion for me or do I have to do it myself?

---

<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: [June 22, 2018, 5:56pm UTC](https://discourse.itk.org/t/simpleitk-channel-storage-order/1027/2 "2018-06-22T17:56:02Z")

</div>

We have some information on multi-channel images in SimpleITK here:  
[https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/fundamentalConcepts.html#channels](https://simpleitk.readthedocs.io/en/master/Documentation/docs/source/fundamentalConcepts.html#channels)

You are correct that SimpleITK stores RGB or vector images with the channels interleaved. If you have an image of [x,y,z,c], where the last channel is the color, this would be considered a 4D Image in SimpleITK. We have limited support for 4D Images, which includes reading, writing, and using the ExtractImageFilter( 4D-\>3D), and JoinSeries (3D-\>4D). If you find something missing to convert 4D images please let us know.

I recently had to convert a 4D image into a 3D vector image:

> [@Reading images via SCIFIO, handle 5-D images](https://discourse.itk.org/t/reading-images-via-scifio-handle-5-d-images/918/3):
>
> I have a patch for SimpleITK which I am working on to add support for this. Basically, it adds an ExtractImageFilter when an image is read to specify how to map the dimensions from the 5D file to the lower dimensional image by specifying starting indexes and sizes. If follows the ExtractImageFilter behavior and any dimension specified with a size of 0, is collapsed, so a 5D image could be reduced by specifying the size of the 4th and 5th dimensions as zero into a 3D image, and the channel c…
