Convert scalar image into image of vectors

Hello,

Is there a filter or pipeline of filters that I can use to convert a scalar image into an image of vectors, each vector having just one component?

For example, I want to convert itk::Image<unsigned char, 3> to itk::Image<itk::Vector<unsigned char, 1>, 3>. Asking because I want to run the itk::ImageKmeansModelEstimator filter on a scalar image, but this filter only accepts an image of vectors if I’m not mistaken. I do see the itk::ComposeImageFilter filter, but it produces itk::VectorImage and not image of vectors. I can always use iterators and indexing to do the conversion, but want to check if a filter is available first.

Thanks,
–Fijoy

Hello!

The ComposeImageFilter can be used to create any image of a vector like type. Here is an example for an Image of CovariantVector pixel type, which should be very similar to what you are looking for:

https://itk.org/Doxygen/html/WikiExamples_2ImageProcessing_2Compose3DCovariantVectorImageFilter_8cxx-example.html#_a1

2 Likes