ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkComposeImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
57 template< typename TInputImage, typename TOutputImage=VectorImage<typename TInputImage::PixelType, TInputImage::ImageDimension> >
58 class ITK_TEMPLATE_EXPORT ComposeImageFilter:
59  public ImageToImageFilter< TInputImage, TOutputImage >
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_ASSIGN(ComposeImageFilter);
63 
68  itkNewMacro(Self);
70 
71  static constexpr unsigned int Dimension = TInputImage::ImageDimension;
72 
73  using InputImageType = TInputImage;
74  using OutputImageType = TOutputImage;
75  using InputPixelType = typename InputImageType::PixelType;
76  using OutputPixelType = typename OutputImageType::PixelType;
78 
79  void SetInput1(const InputImageType *image1);
80  void SetInput2(const InputImageType *image2);
81  void SetInput3(const InputImageType *image3);
82 
83 #ifdef ITK_USE_CONCEPT_CHECKING
84  // Begin concept checking
85  itkConceptMacro( InputCovertibleToOutputCheck,
87  // End concept checking
88 #endif
89 
90 protected:
92 
93  void GenerateOutputInformation() override;
94 
95  void BeforeThreadedGenerateData() override;
96 
97  void DynamicThreadedGenerateData(const RegionType & outputRegionForThread) override;
98 
99 
100 private:
101 
102  // we have to specialize the code for complex, because it provides no operator[]
103  // method
105  using InputIteratorContainerType = std::vector< InputIteratorType >;
106 
107  template<typename T>
108  void ComputeOutputPixel(std::complex<T> & pix, InputIteratorContainerType & inputItContainer )
109  {
110  pix = std::complex<T>(inputItContainer[0].Get(), inputItContainer[1].Get());
111  ++( inputItContainer[0] );
112  ++( inputItContainer[1] );
113  }
114  template<typename TPixel>
115  void ComputeOutputPixel(TPixel & pix, InputIteratorContainerType & inputItContainer)
116  {
117  for ( unsigned int i = 0; i < this->GetNumberOfInputs(); i++ )
118  {
119  pix[i] = static_cast<typename NumericTraits<OutputPixelType>::ValueType >(inputItContainer[i].Get());
120  ++( inputItContainer[i] );
121  }
122  }
123 };
124 }
125 
126 #ifndef ITK_MANUAL_INSTANTIATION
127 #include "itkComposeImageFilter.hxx"
128 #endif
129 
130 #endif
void ComputeOutputPixel(TPixel &pix, InputIteratorContainerType &inputItContainer)
void ComputeOutputPixel(std::complex< T > &pix, InputIteratorContainerType &inputItContainer)
Define numeric traits for std::vector.
typename InputImageType::RegionType RegionType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename OutputImageType::PixelType OutputPixelType
Base class for all process objects that output image data.
ComposeImageFilter combine several scalar images into a multicomponent image.
std::vector< InputIteratorType > InputIteratorContainerType
A multi-dimensional iterator templated over image type that walks a region of pixels.
TOutputImage OutputImageType
Base class for filters that take an image as input and produce an image as output.
typename InputImageType::PixelType InputPixelType
#define itkConceptMacro(name, concept)