# Reading an image with five components

**URL:** https://discourse.itk.org/t/reading-an-image-with-five-components/815
**Category:** Engineering
**Created:** [March 30, 2018, 2:10pm UTC](https://discourse.itk.org/t/reading-an-image-with-five-components/815 "2018-03-30T14:10:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cyril.mory](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@cyril.mory](https://discourse.itk.org/u/cyril.mory)
#### Post date: [March 30, 2018, 2:10pm UTC](https://discourse.itk.org/t/reading-an-image-with-five-components/815/1 "2018-03-30T14:10:21Z")

</div>

Hi everyone,  
I’m trying to read an image with 5 components with itk::ImageFileReader, but it crashes with the following message:  
terminate called after throwing an instance of ‘itk::ExceptionObject’  
what(): /home/mory/sources/itk/ITK/Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx:171:  
itk::ERROR: No conversion available from 5 components to: 5 components

It works fine with 3 components, but crashes with 5. Is it the expected behaviour ? I’m using ITK v4.13.0, but I would see no problem in upgrading to a newer version if necessary.

Here is the code I use:

#include \<itkImage.h\>  
#include \<itkVector.h\>  
#include \<itkImageFileReader.h\>  
#include \<itkImageFileWriter.h\>

int main(){  
typedef itk::Image\<itk::Vector\<float, 5\>, 3\> ImageOfVectorsType;

typedef itk::ImageFileReader ReaderType;  
ReaderType::Pointer reader = ReaderType::New();  
reader-\>SetFileName("/home/mory/ThreeDimensionsFiveComponents.mha");  
reader-\>Update();

return EXIT\_SUCCESS;  
}

---

<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: [March 30, 2018, 2:26pm UTC](https://discourse.itk.org/t/reading-an-image-with-five-components/815/2 "2018-03-30T14:26:07Z")

</div>

Have you tried [this](https://itk.org/ITKExamples/src/Core/Common/ReadWriteVectorImage/Documentation.html) example? Does this one work? If yes, what are the main differences to your example?

---

<div class="post-metadata">

### Author: ![cyril.mory](https://discourse.itk.org/letter_avatar_proxy/v4/letter/c/71c47a/32.png) [@cyril.mory](https://discourse.itk.org/u/cyril.mory)
#### Post date: [March 30, 2018, 2:30pm UTC](https://discourse.itk.org/t/reading-an-image-with-five-components/815/3 "2018-03-30T14:30:57Z")

</div>

With the help of a colleague, we found the source of the problem: my image /home/mory/ThreeDimensionsFiveComponents.mha contains vectors of doubles, not of floats, and in that case the itk::ImageFileReader fails to perform the conversion.
