ITK  4.6.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> >
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);
93 
94  virtual void BeforeThreadedGenerateData();
95 
96  virtual void ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType);
97 
98 private:
99  ComposeImageFilter(const Self &); //purposely not implemented
100  void operator=(const Self &); //purposely not implemented
101 
102 
103  // we have to specialize the code for complex, because it provides no operator[]
104  // method
106  typedef std::vector< InputIteratorType > InputIteratorContainerType;
107 
108  template<typename T>
109  void ComputeOutputPixel(std::complex<T> & pix, InputIteratorContainerType & inputItContainer )
110  {
111  pix = std::complex<T>(inputItContainer[0].Get(), inputItContainer[1].Get());
112  ++( inputItContainer[0] );
113  ++( inputItContainer[1] );
114  }
115  template<typename TPixel>
116  void ComputeOutputPixel(TPixel & pix, InputIteratorContainerType & inputItContainer)
117  {
118  for ( unsigned int i = 0; i < this->GetNumberOfInputs(); i++ )
119  {
120  pix[i] = static_cast<typename NumericTraits<OutputPixelType>::ValueType >(inputItContainer[i].Get());
121  ++( inputItContainer[i] );
122  }
123  }
124 };
125 }
126 
127 #ifndef ITK_MANUAL_INSTANTIATION
128 #include "itkComposeImageFilter.hxx"
129 #endif
130 
131 #endif
void ComputeOutputPixel(TPixel &pix, InputIteratorContainerType &inputItContainer)
virtual void BeforeThreadedGenerateData()
InputImageType::RegionType RegionType
void ComputeOutputPixel(std::complex< T > &pix, InputIteratorContainerType &inputItContainer)
void SetInput3(const InputImageType *image3)
ImageToImageFilter< TInputImage, TOutputImage > Superclass
SmartPointer< Self > Pointer
OutputImageType::PixelType OutputPixelType
Base class for all process objects that output image data.
virtual void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType)
DataObjectPointerArraySizeType GetNumberOfInputs() const
ComposeImageFilter combine several scalar images into a multicomponent image.
A multi-dimensional iterator templated over image type that walks a region of pixels.
ImageRegionConstIterator< InputImageType > InputIteratorType
void SetInput1(const InputImageType *image1)
void SetInput2(const InputImageType *image2)
virtual void GenerateOutputInformation(void)
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)
void operator=(const Self &)
static const unsigned int Dimension
unsigned int ThreadIdType
Definition: itkIntTypes.h:159