DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkMaskedImageToImageFilter.h
Go to the documentation of this file.
1 
18 #ifndef __itkMaskedImageToImageFilter_h
19 #define __itkMaskedImageToImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkThreadLogger.h"
23 #include "utlSTDHeaders.h"
24 #include "utlITKMacro.h"
25 
26 
27 namespace itk
28 {
29 
36 template< class TInputImage, class TOutputImage, class TMaskImage=Image<double, 3> >
37 class ITK_EXPORT MaskedImageToImageFilter
38  :public ImageToImageFilter< TInputImage, TOutputImage >
39 {
40 public:
43  typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
44  typedef SmartPointer< Self > Pointer;
45  typedef SmartPointer< const Self > ConstPointer;
46 
48  itkNewMacro(Self);
49 
51  itkTypeMacro(MaskedImageToImageFilter, ImageToImageFilter);
52 
53  typedef TInputImage InputImageType;
54  typedef typename InputImageType::Pointer InputImagePointer;
55  typedef typename InputImageType::ConstPointer InputImageConstPointer;
56  typedef typename InputImageType::IndexType InputImageIndexType;
57  typedef typename InputImageType::SizeType InputImageSizeType;
58  typedef typename InputImageType::SpacingType InputImageSpacingType;
59  typedef typename InputImageType::PixelType InputImagePixelType;
60  typedef typename InputImageType::RegionType InputImageRegionType;
61 
62  typedef TOutputImage OutputImageType;
63  typedef typename OutputImageType::Pointer OutputImagePointer;
64  typedef typename OutputImageType::IndexType OutputImageIndexType;
65  typedef typename OutputImageType::SizeType OutputImageSizeType;
66  typedef typename OutputImageType::SpacingType OutputImageSpacingType;
67  typedef typename OutputImageType::PixelType OutputImagePixelType;
68  typedef typename OutputImageType::RegionType OutputImageRegionType;
69 
70  typedef TMaskImage MaskImageType;
71  typedef typename MaskImageType::Pointer MaskImagePointer;
72 
74  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
75  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
76 
77  typedef ThreadLogger LoggerType;
78  typedef typename LoggerType::Pointer LoggerPointer;
79  typedef std::vector<LoggerPointer> LoggerVectorType;
80  typedef utl_shared_ptr<LoggerVectorType> LoggerVectorPointer;
81 
83  itkSetObjectMacro(MaskImage, MaskImageType);
84  itkGetObjectMacro(MaskImage, MaskImageType);
85  itkGetConstObjectMacro(MaskImage, MaskImageType);
86  void SetMaskImage(const std::string& file);
87 
89  itkSetObjectMacro(Logger, LoggerType);
90  itkGetObjectMacro(Logger, LoggerType);
91  itkGetConstObjectMacro(Logger, LoggerType);
92 
94 
95  bool IsMaskUsed()
96  {
97  return !IsImageEmpty(this->m_MaskImage);
98  }
99 
100 
101 protected:
103  virtual ~MaskedImageToImageFilter();
104 
105  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
106  typename LightObject::Pointer InternalClone() const ITK_OVERRIDE;
107 
108  virtual void VerifyMaskInformation() const;
109 
110  virtual void VerifyInputParameters() const
111  {
112  if (!IsImageEmpty(this->m_MaskImage))
113  this->VerifyMaskInformation();
114  }
115 
118  virtual void InitializeThreadedLibraries();
119 
121  void CreateLoggerVector ();
122 
123  void WriteLogger(const std::string& str, const LoggerBase::PriorityLevelType level=LoggerBase::DEBUG) const;
124 
125  std::string ThreadIDToString() const;
126 
127  MaskImagePointer m_MaskImage;
128 
129  LoggerPointer m_Logger;
130  LoggerVectorPointer m_LoggerVector;
131 
134 
140 
141 private:
142  MaskedImageToImageFilter(const Self &); //purposely not implemented
143  void operator=(const Self &); //purposely not implemented
144 
145 };
146 
147 }
148 
149 // Define instantiation macro for this template.
150 #define ITK_TEMPLATE_MaskedImageToImageFilter(_, EXPORT, TypeX, TypeY) \
151  namespace itk \
152  { \
153  _( 2 ( class EXPORT MaskedImageToImageFilter< ITK_TEMPLATE_2 TypeX > ) ) \
154  namespace Templates \
155  { \
156  typedef MaskedImageToImageFilter< ITK_TEMPLATE_2 TypeX > MaskedImageToImageFilter##TypeY; \
157  } \
158  }
159 
160 #if ITK_TEMPLATE_EXPLICIT
161 #include "Templates/itkMaskedImageToImageFilter+-.h"
162 #endif
163 
164 #if !defined(ITK_MANUAL_INSTANTIATION) && !defined(__itkMaskedImageToImageFilter_hxx)
166 #endif
167 
168 
169 #endif
170 
OutputImageType::RegionType OutputImageRegionType
std::vector< LoggerPointer > LoggerVectorType
InputImageType::SizeType InputImageSizeType
bool IsImageEmpty(const SmartPointer< ImageType > &image)
Definition: utlITK.h:435
ImageToImageFilter< TInputImage, TOutputImage > Superclass
InputImageType::RegionType InputImageRegionType
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
SmartPointer< const Self > ConstPointer
OutputImageType::IndexType OutputImageIndexType
ImageToImageFilter with mask and threaded logger support.
static int LogLevel
Definition: utlCoreMacro.h:203
InputImageType::IndexType InputImageIndexType
utl_shared_ptr< LoggerVectorType > LoggerVectorPointer
#define itkSetGetMacro(name, type)
Definition: utlITKMacro.h:134
static void InitializeThreadedLibraries(const int numThreads)
Definition: utl.h:327
OutputImageType::PixelType OutputImagePixelType
OutputImageType::Pointer OutputImagePointer
InputImageType::SpacingType InputImageSpacingType
InputImageType::PixelType InputImagePixelType
InputImageType::ConstPointer InputImageConstPointer
OutputImageType::SizeType OutputImageSizeType
OutputImageType::SpacingType OutputImageSpacingType