ITK  4.4.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< class TInputImage, class TOutputImage=VectorImage<typename TInputImage::PixelType, TInputImage::ImageDimension> >
58 class ITK_EXPORT ComposeImageFilter:
59  public ImageToImageFilter< TInputImage, TOutputImage >
60 {
61 public:
62 
67  itkNewMacro(Self);
69 
70  itkStaticConstMacro(Dimension, unsigned int, TInputImage::ImageDimension);
71 
72  typedef TInputImage InputImageType;
73  typedef TOutputImage OutputImageType;
74  typedef typename InputImageType::PixelType InputPixelType;
75  typedef typename OutputImageType::PixelType OutputPixelType;
76  typedef typename InputImageType::RegionType RegionType;
77 
78  void SetInput1(const InputImageType *image1);
79  void SetInput2(const InputImageType *image2);
80  void SetInput3(const InputImageType *image3);
81 
82 #ifdef ITK_USE_CONCEPT_CHECKING
83 
84  itkConceptMacro( InputCovertibleToOutputCheck,
86 
88 #endif
89 
90 protected:
92 
93  virtual void GenerateOutputInformation(void);
94 
95  virtual void BeforeThreadedGenerateData();
96 
97  virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType);
98 
99 private:
100  ComposeImageFilter(const Self &); //purposely not implemented
101  void operator=(const Self &); //purposely not implemented
102 
103 
104  // we have to specialize the code for complex, because it provides no operator[]
105  // method
107  typedef std::vector< InputIteratorType > InputIteratorContainerType;
108 
109  template<class T>
110  void ComputeOutputPixel(std::complex<T> & pix, InputIteratorContainerType & inputItContainer )
111  {
112  pix = std::complex<T>(inputItContainer[0].Get(), inputItContainer[1].Get());
113  ++( inputItContainer[0] );
114  ++( inputItContainer[1] );
115  }
116  template<class TPixel>
117  void ComputeOutputPixel(TPixel & pix, InputIteratorContainerType & inputItContainer)
118  {
119  for ( unsigned int i = 0; i < this->GetNumberOfInputs(); i++ )
120  {
121  pix[i] = static_cast<typename NumericTraits<OutputPixelType>::ValueType >(inputItContainer[i].Get());
122  ++( inputItContainer[i] );
123  }
124  }
125 };
126 }
127 
128 #ifndef ITK_MANUAL_INSTANTIATION
129 #include "itkComposeImageFilter.hxx"
130 #endif
131 
132 #endif
133