|
|
(One intermediate revision by one other user not shown) |
Line 1: |
Line 1: |
| This example demonstrates how to compose a vector image from a collection of scalar images.
| | {{warning|1=The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions. |
| | | }} |
| ==ImageToVectorImageFilter.cxx==
| |
| <source lang="cpp">
| |
| #include "itkImage.h"
| |
| #include "itkComposeImageFilter.h"
| |
| #include "itkVectorImage.h"
| |
| | |
| typedef itk::VectorImage<unsigned char, 2> VectorImageType;
| |
| typedef itk::Image<unsigned char, 2> ScalarImageType;
| |
| | |
| static void CreateImage(ScalarImageType::Pointer image);
| |
| | |
| int main(int argc, char *argv[])
| |
| {
| |
| ScalarImageType::Pointer image0 = ScalarImageType::New();
| |
| CreateImage(image0);
| |
|
| |
| ScalarImageType::Pointer image1 = ScalarImageType::New();
| |
| CreateImage(image1);
| |
|
| |
| ScalarImageType::Pointer image2 = ScalarImageType::New();
| |
| CreateImage(image2);
| |
|
| |
| typedef itk::ComposeImageFilter<ScalarImageType> ImageToVectorImageFilterType;
| |
| 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)
| |
| {
| |
| ScalarImageType::IndexType start;
| |
| start.Fill(0);
| |
| | |
| ScalarImageType::SizeType size;
| |
| size.Fill(100);
| |
| | |
| ScalarImageType::RegionType region(start,size); | |
|
| |
| image->SetRegions(region);
| |
| image->Allocate();
| |
| image->FillBuffer(0);
| |
|
| |
| }
| |
| </source>
| |
| | |
| {{ITKCMakeLists|{{SUBPAGENAME}}}}
| |