ITK  5.0.0
Insight Segmentation and Registration Toolkit
WikiExamples/VectorImages/ImageToVectorImageFilter.cxx
#include "itkImage.h"
#include "itkVectorImage.h"
namespace
{
using VectorImageType = itk::VectorImage<unsigned char, 2>;
using ScalarImageType = itk::Image<unsigned char, 2>;
}
static void CreateImage(ScalarImageType::Pointer image);
int main(int, char *[])
{
ScalarImageType::Pointer image0 = ScalarImageType::New();
CreateImage(image0);
ScalarImageType::Pointer image1 = ScalarImageType::New();
CreateImage(image1);
ScalarImageType::Pointer image2 = ScalarImageType::New();
CreateImage(image2);
using ImageToVectorImageFilterType = itk::ComposeImageFilter<ScalarImageType>;
ImageToVectorImageFilterType::Pointer imageToVectorImageFilter = ImageToVectorImageFilterType::New();
imageToVectorImageFilter->SetInput(0, image0);
imageToVectorImageFilter->SetInput(1, image1);
imageToVectorImageFilter->SetInput(2, image2);
imageToVectorImageFilter->Update();
VectorImageType::Pointer vectorImage = imageToVectorImageFilter->GetOutput();
return EXIT_SUCCESS;
}
void CreateImage(ScalarImageType::Pointer image)
{
start.Fill(0);
size.Fill(100);
ScalarImageType::RegionType region(start,size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
}