ITK  5.2.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  * http://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 
21 #include "itkImageToImageFilter.h"
22 #include "itkVectorImage.h"
24 #include <vector>
25 
26 namespace itk
27 {
59 
60 template <typename TInputImage,
61  typename TOutputImage = VectorImage<typename TInputImage::PixelType, TInputImage::ImageDimension>>
62 class ITK_TEMPLATE_EXPORT ComposeImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_MOVE(ComposeImageFilter);
66 
71  itkNewMacro(Self);
73 
74  static constexpr unsigned int Dimension = TInputImage::ImageDimension;
75 
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 
96 protected:
98 
99  void
100  GenerateOutputInformation() override;
101 
102  void
103  BeforeThreadedGenerateData() override;
104 
105  void
106  DynamicThreadedGenerateData(const RegionType & outputRegionForThread) override;
107 
108 
109 private:
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
itk::ComposeImageFilter::InputIteratorContainerType
std::vector< InputIteratorType > InputIteratorContainerType
Definition: itkComposeImageFilter.h:113
itk::ComposeImageFilter::ComputeOutputPixel
void ComputeOutputPixel(std::complex< T > &pix, InputIteratorContainerType &inputItContainer)
Definition: itkComposeImageFilter.h:117
itk::ComposeImageFilter::ComputeOutputPixel
void ComputeOutputPixel(TPixel &pix, InputIteratorContainerType &inputItContainer)
Definition: itkComposeImageFilter.h:125
itk::ComposeImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkComposeImageFilter.h:79
itk::SmartPointer< Self >
itk::ComposeImageFilter::RegionType
typename InputImageType::RegionType RegionType
Definition: itkComposeImageFilter.h:80
itkImageRegionConstIterator.h
itkVectorImage.h
itk::ComposeImageFilter::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkComposeImageFilter.h:78
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ComposeImageFilter
ComposeImageFilter combine several scalar images into a multicomponent image.
Definition: itkComposeImageFilter.h:62
itk::Concept::Convertible
Definition: itkConceptChecking.h:216
itk::ImageRegionConstIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionConstIterator.h:109
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90