ANIMA  4.0
animaCheckStructureNeighborFilter.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <itkImageToImageFilter.h>
6 #include <itkImageRegionIterator.h>
7 #include <itkImageRegionConstIterator.h>
8 #include <itkRelabelComponentImageFilter.h>
9 #include <itkConnectedComponentImageFilter.h>
10 #include <itkGrayscaleDilateImageFilter.h>
11 #include <itkBinaryBallStructuringElement.h>
12 #include <itkBinaryImageToLabelMapFilter.h>
13 #include <itkLabelMapToLabelImageFilter.h>
14 #include <itkLabelContourImageFilter.h>
15 
16 namespace anima
17 {
24 template<typename TInput, typename TMask, typename TOutput = TInput>
26 public itk::ImageToImageFilter< TInput , TOutput >
27 {
28 public:
31  typedef itk::ImageToImageFilter< TInput , TOutput > Superclass;
32  typedef itk::SmartPointer<Self> Pointer;
33  typedef itk::SmartPointer<const Self> ConstPointer;
34 
36  itkNewMacro(Self)
37 
38 
39  itkTypeMacro(CheckStructureNeighborFilter, ImageToImageFilter)
40 
41 
44  typedef TInput InputImageType;
45  typedef typename InputImageType::ConstPointer InputImageConstPointer;
46  typedef typename InputImageType::PixelType InputPixelType;
47  typedef typename itk::ImageRegionConstIterator< InputImageType > InputConstIteratorType;
48 
50  typedef TMask MaskImageType;
51  typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
52  typedef typename MaskImageType::PixelType MaskPixelType;
53  typedef typename itk::ImageRegionConstIterator< MaskImageType > MaskConstIteratorType;
54 
56  typedef TOutput OutputImageType;
57  typedef typename OutputImageType::Pointer OutputImagePointer;
58  typedef typename OutputImageType::PixelType OutputPixelType;
59  typedef typename itk::ImageRegionIterator <OutputImageType> OutputIteratorType;
60 
61  typedef int PixelTypeInt;
62  typedef itk::Image <PixelTypeInt,3> ImageTypeInt;
63  typedef itk::ImageRegionIterator <ImageTypeInt> ImageIteratorTypeInt;
64 
65  typedef typename itk::ConnectedComponentImageFilter <InputImageType,ImageTypeInt> ConnectedComponentFilterType;
66  typedef itk::LabelContourImageFilter<ImageTypeInt,ImageTypeInt> LabelContourFilterType;
67  typedef itk::BinaryBallStructuringElement<PixelTypeInt, 3> StructuringElementType;
68  typedef itk::GrayscaleDilateImageFilter <ImageTypeInt,ImageTypeInt,StructuringElementType> DilateFilterType;
69 
71  void SetInputClassification(const TInput* image);
72  void SetInputMap(const TMask* image);
73 
74  void WriteOutputs();
75 
76  void SetTol(const double tol)
77  {
78  this->SetCoordinateTolerance(tol);
79  this->SetDirectionTolerance(tol);
80  m_Tol = tol;
81  }
82 
84  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
85 
86  itkSetMacro(LabelToCheck, int)
87  itkGetMacro(LabelToCheck, int)
88 
89  itkSetMacro(Verbose, bool)
90  itkGetMacro(Verbose, bool)
91 
92  itkSetMacro(Ratio, double)
93  itkGetMacro(Ratio, double)
94 
95  std::string GetOutputFilename() {return m_OutputFilename;}
96  void SetOutputFilename(std::string filename) {m_OutputFilename=filename;}
97 
98 protected:
100  {
101  this->SetNumberOfRequiredOutputs(1);
102  this->SetNumberOfRequiredInputs(2);
103 
104  m_Verbose=false;
105  m_Tol = 0.0001;
106  m_Ratio = 0;
107 
108  this->SetNumberOfWorkUnits(itk::MultiThreaderBase::GetGlobalDefaultNumberOfThreads());
109  }
110 
112  {
113  }
114 
115  typename TInput::ConstPointer GetInputClassification();
116  typename TMask::ConstPointer GetInputMap();
117 
118  void GenerateData() ITK_OVERRIDE;
119 
120 private:
121  ITK_DISALLOW_COPY_AND_ASSIGN(CheckStructureNeighborFilter);
122 
123  std::string m_OutputFilename;
124  int m_LabelToCheck;
125  bool m_Verbose;
126  double m_Tol;
127  double m_Ratio;
128 
129 };
130 
131 } // end of namespace anima
132 
itk::ImageRegionConstIterator< InputImageType > InputConstIteratorType
itk::ConnectedComponentImageFilter< InputImageType, ImageTypeInt > ConnectedComponentFilterType
Class removing lesions that are not sufficiently in the white matter. Intensity rules may not be enou...
Superclass::OutputImageRegionType OutputImageRegionType
itk::GrayscaleDilateImageFilter< ImageTypeInt, ImageTypeInt, StructuringElementType > DilateFilterType
STL namespace.
itk::ImageRegionIterator< ImageTypeInt > ImageIteratorTypeInt
itk::ImageRegionIterator< OutputImageType > OutputIteratorType
itk::ImageRegionConstIterator< MaskImageType > MaskConstIteratorType
itk::BinaryBallStructuringElement< PixelTypeInt, 3 > StructuringElementType
itk::LabelContourImageFilter< ImageTypeInt, ImageTypeInt > LabelContourFilterType
itk::ImageToImageFilter< TInput, TOutput > Superclass