ITK  4.2.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 {
56 template< class TInputImage, class TOutputImage=VectorImage<typename TInputImage::PixelType, TInputImage::ImageDimension> >
57 class ITK_EXPORT ComposeImageFilter:
58  public ImageToImageFilter< TInputImage, TOutputImage >
59 {
60 public:
61 
66  itkNewMacro(Self);
68 
69  itkStaticConstMacro(Dimension, unsigned int, TInputImage::ImageDimension);
70 
71  typedef TInputImage InputImageType;
72  typedef TOutputImage OutputImageType;
73  typedef typename InputImageType::PixelType InputPixelType;
74  typedef typename OutputImageType::PixelType OutputPixelType;
75  typedef typename InputImageType::RegionType RegionType;
76 
77  void SetInput1(const InputImageType *image1);
78  void SetInput2(const InputImageType *image2);
79  void SetInput3(const InputImageType *image3);
80 
81 #ifdef ITK_USE_CONCEPT_CHECKING
82 
83  itkConceptMacro( InputCovertibleToOutputCheck,
85 
87 #endif
88 protected:
90 
91  virtual void GenerateOutputInformation(void);
92 
93  virtual void BeforeThreadedGenerateData();
94 
95  virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType);
96 
97 private:
98  ComposeImageFilter(const Self &); //purposely not implemented
99  void operator=(const Self &); //purposely not implemented
100 
101 
102  // we have to specialize the code for complex, because it provides no operator[]
103  // method
105  typedef std::vector< InputIteratorType > InputIteratorContainerType;
106 
107  template<class 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<class 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
131