DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkMultiVariableFunctorVectorImageFilter.h
Go to the documentation of this file.
1 
12 #ifndef itkMultiVariableFunctorVectorImageFilter_h
13 #define itkMultiVariableFunctorVectorImageFilter_h
14 
16 
17 namespace itk
18 {
32 template< typename TInputImage, typename TOutputImage, typename TFunction, class TMaskImage=Image<double,3> >
34  :public FunctorBaseVectorImageFilter< TInputImage, TOutputImage, TFunction, TMaskImage >
35 {
36 public:
40  typedef SmartPointer< Self > Pointer;
41  typedef SmartPointer< const Self > ConstPointer;
42 
44  itkNewMacro(Self);
45 
48 
50  typedef TFunction FunctorType;
51 
52  typedef TInputImage InputImageType;
53  typedef typename InputImageType::Pointer InputImagePointer;
54  typedef typename InputImageType::ConstPointer InputImageConstPointer;
55  typedef typename InputImageType::IndexType InputImageIndexType;
56  typedef typename InputImageType::SizeType InputImageSizeType;
57  typedef typename InputImageType::SpacingType InputImageSpacingType;
58  typedef typename InputImageType::PixelType InputImagePixelType;
59  typedef typename InputImageType::RegionType InputImageRegionType;
60 
61  typedef TOutputImage OutputImageType;
62  typedef typename OutputImageType::Pointer OutputImagePointer;
63  typedef typename OutputImageType::IndexType OutputImageIndexType;
64  typedef typename OutputImageType::SizeType OutputImageSizeType;
65  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
66  typedef typename OutputImageType::PixelType OutputImagePixelType;
67  typedef typename OutputImageType::RegionType OutputImageRegionType;
68 
70 
71 protected:
74 
75  void BeforeThreadedGenerateData () ITK_OVERRIDE;
76 
78  virtual void PropagateRequestedRegion(DataObject *output) ITK_OVERRIDE
79  {
80  }
81 
82  virtual void GenerateOutputInformation() ITK_OVERRIDE;
83 
84  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
85  ThreadIdType threadId) ITK_OVERRIDE;
86 
87 protected:
88 
89 
90 private:
92  void operator=(const Self &) ITK_DELETE_FUNCTION;
93 
94 };
95 
96 
101 template <class ImageType, class ImageOutType, class OpFunctor, class MaskImageType=Image<double,4> >
102 void
103 MultiVariableVectorOPImage(const std::vector<itk::SmartPointer<ImageType> >& images, itk::SmartPointer<ImageOutType>& outImage, const OpFunctor& func, const itk::SmartPointer<MaskImageType>& mask=nullptr, int numberOfThreads=-1, int vectorAxis=3)
104 {
106  typename FunctorImageFilterType::Pointer filter = FunctorImageFilterType::New();
107 
108  if (!itk::IsImageEmpty(mask))
109  filter->SetMaskImage(mask);
110  for ( int i = 0; i < images.size(); ++i )
111  {
112  filter->SetInput(i, images[i]);
113  }
114  if (vectorAxis>=0)
115  filter->SetVectorAxis(vectorAxis);
116  filter->SetFunctor(func);
117  filter->SetDebug(utl::IsLogDebug());
118  filter->SetLogLevel(utl::LogLevel);
119  if (numberOfThreads>0)
120  filter->SetNumberOfThreads(numberOfThreads);
121 
122  filter->Update();
123 
124  outImage = filter->GetOutput();
125 }
126 
127 
128 } // end namespace itk
129 
130 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkMultiVariableFunctorVectorImageFilter_hxx)
132 #endif
133 
134 #endif
void MultiVariableVectorOPImage(const std::vector< itk::SmartPointer< ImageType > > &images, itk::SmartPointer< ImageOutType > &outImage, const OpFunctor &func, const itk::SmartPointer< MaskImageType > &mask=nullptr, int numberOfThreads=-1, int vectorAxis=3)
Implements vector-valued generic operation on one image.
bool IsImageEmpty(const SmartPointer< ImageType > &image)
Definition: utlITK.h:435
#define ITK_DELETE_FUNCTION
Definition: utlITKMacro.h:49
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
Implements vector-valued generic operation on one image.
bool IsLogDebug(const int level=utl::LogLevel)
Definition: utlCoreMacro.h:213
static int LogLevel
Definition: utlCoreMacro.h:203
virtual void PropagateRequestedRegion(DataObject *output) ITK_OVERRIDE
FunctorBaseVectorImageFilter< TInputImage, TOutputImage, TFunction, TMaskImage > Superclass