|
|
Line 1: |
Line 1: |
| ==Compose3DCovariantVectorImageFilter.cxx== | | {{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. |
| <source lang="cpp">
| | }} |
| #include "itkImageAdaptor.h"
| |
| #include "itkImageRegionIterator.h"
| |
| #if ITK_VERSION_MAJOR < 4
| |
| #include "itkCompose3DCovariantVectorImageFilter.h"
| |
| #else
| |
| #include "itkComposeImageFilter.h"
| |
| #endif
| |
| | |
| typedef itk::Image<itk::CovariantVector< float, 3>, 2> VectorImageType;
| |
| typedef itk::Image<float, 2> ScalarImageType;
| |
| | |
| static void CreateImage(ScalarImageType::Pointer image);
| |
| | |
| int main(int, char *[])
| |
| {
| |
| ScalarImageType::Pointer image = ScalarImageType::New();
| |
| CreateImage(image);
| |
| | |
| #if ITK_VERSION_MAJOR < 4
| |
| typedef itk::Compose3DCovariantVectorImageFilter<ScalarImageType,
| |
| VectorImageType> ComposeCovariantVectorImageFilterType;
| |
| #else
| |
| typedef itk::ComposeImageFilter<ScalarImageType,
| |
| VectorImageType> ComposeCovariantVectorImageFilterType;
| |
| #endif
| |
| ComposeCovariantVectorImageFilterType::Pointer composeFilter = ComposeCovariantVectorImageFilterType::New();
| |
| | |
| composeFilter->SetInput1(image);
| |
| composeFilter->SetInput2(image);
| |
| composeFilter->SetInput3(image);
| |
| composeFilter->Update();
| |
|
| |
| itk::Index<2> index;
| |
| index.Fill(0);
| |
| | |
| std::cout << image->GetPixel(index) << std::endl;
| |
| | |
| std::cout << composeFilter->GetOutput()->GetPixel(index) << std::endl;
| |
| | |
| return EXIT_SUCCESS;
| |
| }
| |
| | |
| void CreateImage(ScalarImageType::Pointer image)
| |
| {
| |
| ScalarImageType::IndexType start;
| |
| start.Fill(0);
| |
| | |
| ScalarImageType::SizeType size; | |
| size.Fill(2);
| |
| | |
| ScalarImageType::RegionType region;
| |
| region.SetSize(size);
| |
| region.SetIndex(start);
| |
| | |
| image->SetRegions(region);
| |
| image->Allocate();
| |
| | |
| itk::ImageRegionIterator<ScalarImageType> imageIterator(image,image->GetLargestPossibleRegion());
| |
| | |
| while(!imageIterator.IsAtEnd())
| |
| {
| |
| imageIterator.Set(1.2);
| |
| | |
| ++imageIterator;
| |
| }
| |
| }
| |
| </source>
| |
| {{ITKCMakeLists|{{SUBPAGENAME}}}}
| |