ITK  5.3.0
Insight Toolkit
SphinxExamples/src/Filtering/ImageCompose/CreateVectorImageFromScalarImages/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "itkImage.h"
#include "itkVectorImage.h"
namespace
{
using VectorImageType = itk::VectorImage<unsigned char, 2>;
using ScalarImageType = itk::Image<unsigned char, 2>;
} // namespace
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);
}
itk::VectorImage
Templated n-dimensional vector image class.
Definition: itkImageAlgorithm.h:29
itkComposeImageFilter.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkImage.h
itk::Index::Fill
void Fill(IndexValueType value)
Definition: itkIndex.h:271
itk::Size::Fill
void Fill(SizeValueType value)
Definition: itkSize.h:211
itkVectorImage.h
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ComposeImageFilter
ComposeImageFilter combine several scalar images into a multicomponent image.
Definition: itkComposeImageFilter.h:62
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88