DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkUnaryFunctorVectorImageFilter.h
Go to the documentation of this file.
1 
12 #ifndef itkUnaryFunctorVectorImageFilter_h
13 #define itkUnaryFunctorVectorImageFilter_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 
85  virtual void GenerateOutputInformation() ITK_OVERRIDE;
86 
97  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
98  ThreadIdType threadId) ITK_OVERRIDE;
99 
100 protected:
101 
102 
103 private:
105  void operator=(const Self &) ITK_DELETE_FUNCTION;
106 
107 };
108 
109 
114 template <class ImageType, class ImageOutType, class OpFunctor, class MaskImageType=Image<double,4> >
115 void
116 UnaryVectorOPImage(const itk::SmartPointer<ImageType>& image, itk::SmartPointer<ImageOutType>& outImage, const OpFunctor& func, const itk::SmartPointer<MaskImageType>& mask=nullptr, int numberOfThreads=-1, int vectorAxis=3)
117 {
119  typename UnaryFunctorFilterType::Pointer filter = UnaryFunctorFilterType::New();
120 
121  if (!itk::IsImageEmpty(mask))
122  filter->SetMaskImage(mask);
123  filter->SetInput(image);
124  if (vectorAxis>=0)
125  filter->SetVectorAxis(vectorAxis);
126  filter->SetFunctor(func);
127  filter->SetDebug(utl::IsLogDebug());
128  filter->SetLogLevel(utl::LogLevel);
129  if (numberOfThreads>0)
130  filter->SetNumberOfThreads(numberOfThreads);
131 
132  filter->Update();
133 
134  outImage = filter->GetOutput();
135 }
136 
137 } // end namespace itk
138 
139 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkUnaryFunctorVectorImageFilter_hxx)
141 #endif
142 
143 #endif
Implements vector-valued generic operation on one image.
void UnaryVectorOPImage(const itk::SmartPointer< ImageType > &image, itk::SmartPointer< ImageOutType > &outImage, const OpFunctor &func, const itk::SmartPointer< MaskImageType > &mask=nullptr, int numberOfThreads=-1, int vectorAxis=3)
bool IsImageEmpty(const SmartPointer< ImageType > &image)
Definition: utlITK.h:435
#define ITK_DELETE_FUNCTION
Definition: utlITKMacro.h:49
FunctorBaseVectorImageFilter< TInputImage, TOutputImage, TFunction, TMaskImage > Superclass
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
bool IsLogDebug(const int level=utl::LogLevel)
Definition: utlCoreMacro.h:213
static int LogLevel
Definition: utlCoreMacro.h:203
Implements vector-valued generic operation on one image.