ITK  5.4.0
Insight Toolkit
itkComposeImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkComposeImageFilter_h
19#define itkComposeImageFilter_h
20
22#include "itkVectorImage.h"
24#include <vector>
25
26namespace itk
27{
60template <typename TInputImage,
62class ITK_TEMPLATE_EXPORT ComposeImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
63{
64public:
65 ITK_DISALLOW_COPY_AND_MOVE(ComposeImageFilter);
71 itkNewMacro(Self);
72 itkOverrideGetNameOfClassMacro(ComposeImageFilter);
74 static constexpr unsigned int Dimension = TInputImage::ImageDimension;
76 using InputImageType = TInputImage;
77 using OutputImageType = TOutputImage;
78 using InputPixelType = typename InputImageType::PixelType;
79 using OutputPixelType = typename OutputImageType::PixelType;
81
82 void
83 SetInput1(const InputImageType * image1);
84 void
85 SetInput2(const InputImageType * image2);
86 void
87 SetInput3(const InputImageType * image3);
88
89#ifdef ITK_USE_CONCEPT_CHECKING
90 // Begin concept checking
91 itkConceptMacro(InputCovertibleToOutputCheck,
93 // End concept checking
94#endif
95
96protected:
98
99 void
100 GenerateOutputInformation() override;
101
102 void
103 BeforeThreadedGenerateData() override;
104
105 void
106 DynamicThreadedGenerateData(const RegionType & outputRegionForThread) override;
107
108
109private:
110 // we have to specialize the code for complex, because it provides no operator[]
111 // method
113 using InputIteratorContainerType = std::vector<InputIteratorType>;
114
115 template <typename T>
116 void
117 ComputeOutputPixel(std::complex<T> & pix, InputIteratorContainerType & inputItContainer)
118 {
119 pix = std::complex<T>(inputItContainer[0].Get(), inputItContainer[1].Get());
120 ++(inputItContainer[0]);
121 ++(inputItContainer[1]);
122 }
123 template <typename TPixel>
124 void
125 ComputeOutputPixel(TPixel & pix, InputIteratorContainerType & inputItContainer)
126 {
127 for (unsigned int i = 0; i < this->GetNumberOfInputs(); ++i)
128 {
129 pix[i] = static_cast<typename NumericTraits<OutputPixelType>::ValueType>(inputItContainer[i].Get());
130 ++(inputItContainer[i]);
131 }
132 }
133};
134} // namespace itk
135
136#ifndef ITK_MANUAL_INSTANTIATION
137# include "itkComposeImageFilter.hxx"
138#endif
139
140#endif
ComposeImageFilter combine several scalar images into a multicomponent image.
typename InputImageType::RegionType RegionType
std::vector< InputIteratorType > InputIteratorContainerType
typename InputImageType::PixelType InputPixelType
typename OutputImageType::PixelType OutputPixelType
A multi-dimensional iterator templated over image type that walks a region of pixels.
Base class for filters that take an image as input and produce an image as output.
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Templated n-dimensional vector image class.
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....