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 
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  // Begin concept checking
84  itkConceptMacro( InputCovertibleToOutputCheck,
86  // End concept checking
87 #endif
88 
89 protected:
91 
92  virtual void GenerateOutputInformation(void) ITK_OVERRIDE;
93 
94  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
95 
96  virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType) ITK_OVERRIDE;
97 
98 private:
99  ITK_DISALLOW_COPY_AND_ASSIGN(ComposeImageFilter);
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<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)
InputImageType::RegionType RegionType
ImageToImageFilter< TInputImage, TOutputImage > Superclass
SmartPointer< Self > Pointer
OutputImageType::PixelType OutputPixelType
Base class for all process objects that output image data.
ComposeImageFilter combine several scalar images into a multicomponent image.
A multi-dimensional iterator templated over image type that walks a region of pixels.
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
std::vector< InputIteratorType > InputIteratorContainerType
Base class for filters that take an image as input and produce an image as output.
InputImageType::PixelType InputPixelType
Define additional traits for native types such as int or float.
SmartPointer< const Self > ConstPointer
#define itkConceptMacro(name, concept)