ANIMA  4.0
animaTLinksFilter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageToImageFilter.h>
4 #include <itkImageRegionIterator.h>
5 #include <itkImageRegionConstIterator.h>
6 #include <itkVariableSizeMatrix.h>
7 
9 {
12 };
13 
14 namespace anima
15 {
21 template <typename TInput, typename TOutput>
22 class TLinksFilter :
23  public itk::ImageToImageFilter< TInput,TOutput>
24 {
25 public:
27  typedef TLinksFilter Self;
28  typedef itk::ImageToImageFilter< TInput ,TOutput > Superclass;
29  typedef itk::SmartPointer<Self> Pointer;
30  typedef itk::SmartPointer<const Self> ConstPointer;
31 
33  itkNewMacro(Self)
34 
35 
36  itkTypeMacro(TLinksFilter, ImageToImageFilter)
37 
38 
39  typedef typename TInput::PixelType InputPixelType;
40  typedef typename TInput::Pointer InputImagePointer;
41  typedef typename TInput::ConstPointer InputImageConstPointer;
42  typedef itk::ImageRegionConstIterator< TInput > InConstIteratorType;
43  typedef itk::ImageRegionIterator< TInput > InIteratorType;
44 
45  typedef typename TOutput::PixelType OutputPixelType;
46  typedef typename TOutput::Pointer OutputImagePointer;
47  typedef itk::ImageRegionIterator< TOutput > OutRegionIteratorType;
48 
49  typedef double PixelTypeD;
50  typedef itk::Image <PixelTypeD,3> TSeedProba;
51  typedef itk::ImageRegionConstIterator< TSeedProba > SeedProbaRegionConstIteratorType;
52 
53  typedef unsigned char PixelTypeUC;
54  typedef itk::Image <PixelTypeUC,3> TSeedMask;
55  typedef TSeedMask::Pointer TSeedMaskPointer;
56  typedef itk::ImageRegionIterator< TSeedMask > SeedMaskRegionIteratorType;
57  typedef itk::ImageRegionConstIterator< TSeedMask > SeedMaskRegionConstIteratorType;
58 
59  typedef double NumericType;
60  typedef itk::VariableSizeMatrix<NumericType> DoubleVariableSizeMatrixType;
61  typedef itk::Matrix<double, 1, 1> MatrixTypeRes;
62 
64  void SetInputImage(unsigned int i, const TInput* image);
65 
68  void SetInputSeedSourcesMask(const TSeedMask* mask);
69  void SetInputSeedSinksMask(const TSeedMask* mask);
70 
71  void SetInputSeedSourcesProba(const TSeedProba* mask);
72  void SetInputSeedSinksProba(const TSeedProba* mask);
73 
74  TLinkMode GetTLinkMode() {return m_TLinkMode;}
75  void SetTLinkMode(TLinkMode m) {m_TLinkMode=m;}
76 
77  TOutput* GetOutputSources();
78  TOutput* GetOutputSinks();
79 
80  void SetTol(const double tol)
81  {
82  this->SetCoordinateTolerance(tol);
83  this->SetDirectionTolerance(tol);
84  }
85 
87  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
88 
89  itkSetMacro(Alpha, double)
90  itkGetMacro(Alpha, double)
91 
92  itkSetMacro(MultiVarSources, double)
93  itkGetMacro(MultiVarSources, double)
94 
95  itkSetMacro(MultiVarSinks, double)
96  itkGetMacro(MultiVarSinks, double)
97 
98  itkSetMacro(NbModalities, unsigned int)
99  itkGetMacro(NbModalities, unsigned int)
100 
101  itkSetMacro(Verbose, bool)
102  itkGetMacro(Verbose, bool)
103 
104 protected:
106  {
107  m_Alpha = 10;
108  m_MultiVarSources = 1;
109  m_MultiVarSinks = 1;
110  m_TLinkMode = singleGaussianTLink;
111  m_NbModalities = 0;
112  m_NbInputs = 1;
113  m_Verbose=false;
114 
115  m_NbMaxImage = 11;
116  m_IndexSourcesMask= m_NbMaxImage, m_IndexSourcesProba= m_NbMaxImage,m_IndexSinksMask= m_NbMaxImage, m_IndexSinksProba= m_NbMaxImage;
117 
118  this->SetNumberOfRequiredOutputs(2);
119  this->SetNumberOfRequiredInputs(2);
120 
121  this->SetNthOutput( 0, this->MakeOutput(0) );
122  this->SetNthOutput( 1, this->MakeOutput(1) );
123  }
124 
125  virtual ~TLinksFilter()
126  {
127  }
128 
129  TSeedMask::ConstPointer GetInputSeedSourcesMask();
130  TSeedMask::ConstPointer GetInputSeedSinksMask();
131 
132  TSeedProba::ConstPointer GetInputSeedSourcesProba();
133  TSeedProba::ConstPointer GetInputSeedSinksProba();
134 
135  void GenerateData() ITK_OVERRIDE;
136  void computeSingleGaussian();
137  void computeSingleGaussianSeeds(TSeedMask::ConstPointer seedMask, OutputImagePointer output, double multiVar, TSeedMask::ConstPointer seedMaskOpp = ITK_NULLPTR);
138  void computeStrem();
139 
141  itk::DataObject::Pointer MakeOutput(unsigned int idx);
142 
143 private:
144  ITK_DISALLOW_COPY_AND_ASSIGN(TLinksFilter);
145 
148  double m_Alpha;
149  double m_MultiVarSources;
150  double m_MultiVarSinks;
151  TLinkMode m_TLinkMode;
152  bool m_Verbose;
153  unsigned int m_NbModalities;
154  unsigned int m_NbInputs, m_NbMaxImage;
155  unsigned int m_IndexSourcesMask, m_IndexSourcesProba, m_IndexSinksMask, m_IndexSinksProba;
156 
157  std::vector<InConstIteratorType> m_imagesVectorIt;
158  std::vector<InIteratorType> m_imagesVectorIt2;
159  std::vector<InputImageConstPointer> m_imagesVector;
160  std::vector<InputImagePointer> m_imagesVector2;
161 };
162 
163 } // end of namespace anima
164 
165 #include "animaTLinksFilter.hxx"
void SetInputSeedSourcesMask(const TSeedMask *mask)
TSeedMask::ConstPointer GetInputSeedSourcesMask()
void SetInputSeedSinksMask(const TSeedMask *mask)
TLinkMode
TSeedProba::ConstPointer GetInputSeedSinksProba()
unsigned char PixelTypeUC
itk::Image< PixelTypeD, 3 > TSeedProba
itk::ImageRegionConstIterator< TSeedProba > SeedProbaRegionConstIteratorType
itk::SmartPointer< const Self > ConstPointer
itk::DataObject::Pointer MakeOutput(unsigned int idx)
void SetInputSeedSinksProba(const TSeedProba *mask)
TInput::PixelType InputPixelType
TSeedMask::ConstPointer GetInputSeedSinksMask()
Class computing the probability maps that are used to create the t-links.
itk::ImageRegionConstIterator< TSeedMask > SeedMaskRegionConstIteratorType
void SetInputImage(unsigned int i, const TInput *image)
Superclass::OutputImageRegionType OutputImageRegionType
itk::SmartPointer< Self > Pointer
void SetTLinkMode(TLinkMode m)
itk::ImageRegionIterator< TOutput > OutRegionIteratorType
itk::ImageRegionIterator< TInput > InIteratorType
itk::ImageRegionConstIterator< TInput > InConstIteratorType
itk::ImageToImageFilter< TInput,TOutput > Superclass
itk::Matrix< double, 1, 1 > MatrixTypeRes
void SetTol(const double tol)
void GenerateData() ITK_OVERRIDE
itk::Image< PixelTypeUC, 3 > TSeedMask
itk::VariableSizeMatrix< NumericType > DoubleVariableSizeMatrixType
itk::ImageRegionIterator< TSeedMask > SeedMaskRegionIteratorType
TOutput::Pointer OutputImagePointer
TOutput::PixelType OutputPixelType
void SetInputSeedSourcesProba(const TSeedProba *mask)
TInput::Pointer InputImagePointer
TSeedProba::ConstPointer GetInputSeedSourcesProba()
TInput::ConstPointer InputImageConstPointer
void computeSingleGaussianSeeds(TSeedMask::ConstPointer seedMask, OutputImagePointer output, double multiVar, TSeedMask::ConstPointer seedMaskOpp=ITK_NULLPTR)
TSeedMask::Pointer TSeedMaskPointer