ANIMA  4.0
animaNLMeansPatientToGroupComparisonImageFilter.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
5 #include <itkVectorImage.h>
6 #include <itkImage.h>
7 
8 #include <vector>
9 
10 namespace anima
11 {
12 
13 template <class PixelScalarType>
15  public anima::MaskedImageToImageFilter< itk::VectorImage <PixelScalarType, 3> , itk::Image <PixelScalarType, 3> >
16 {
17 public:
20  typedef itk::SmartPointer<Self> Pointer;
21  typedef itk::SmartPointer<const Self> ConstPointer;
22 
24  itkNewMacro(Self)
25 
26 
28 
29 
30  typedef itk::VectorImage <PixelScalarType, 3> InputImageType;
31  typedef itk::Image <PixelScalarType, 3> OutputImageType;
32 
33  typedef typename InputImageType::PixelType VectorType;
34 
35  typedef vnl_matrix <double> CovarianceType;
36 
37  typedef typename InputImageType::Pointer InputImagePointer;
38  typedef typename InputImageType::IndexType InputImageIndexType;
39  typedef typename OutputImageType::Pointer OutputImagePointer;
40 
42  typedef anima::MaskedImageToImageFilter< InputImageType, OutputImageType > Superclass;
43  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
44  typedef typename Superclass::MaskImageType MaskImageType;
45 
46  typedef struct
47  {
48  OutputImageRegionType movingRegion;
49  unsigned int numDatabaseImage;
50  InputImageIndexType centerIndex;
52 
54  {
55  m_DatabaseImages.push_back(tmpIm);
56  }
57 
58  itkSetMacro(DatabaseCovarianceDistanceAverage, OutputImagePointer)
59  itkSetMacro(DatabaseCovarianceDistanceStd, OutputImagePointer)
60  itkSetMacro(DatabaseMeanDistanceAverage, OutputImagePointer)
61  itkSetMacro(DatabaseMeanDistanceStd, OutputImagePointer)
62 
63  itkSetMacro(PatchHalfSize, unsigned int)
64  itkSetMacro(SearchNeighborhood, unsigned int)
65  itkSetMacro(SearchStepSize, unsigned int)
66  itkSetMacro(WeightThreshold, double)
67  itkSetMacro(MeanThreshold, double)
68  itkSetMacro(VarianceThreshold, double)
69  itkSetMacro(BetaParameter, double)
70 
71 protected:
73  : Superclass()
74  {
75  this->SetNumberOfRequiredOutputs(3);
76  this->SetNthOutput(0,this->MakeOutput(0));
77  this->SetNthOutput(1,this->MakeOutput(1));
78  this->SetNthOutput(2,this->MakeOutput(2));
79 
80  m_DatabaseImages.clear();
81 
82  m_DatabaseCovarianceDistanceAverage = NULL;
83  m_DatabaseCovarianceDistanceStd = NULL;
84  m_DatabaseMeanDistanceAverage = NULL;
85  m_DatabaseMeanDistanceStd = NULL;
86 
87  m_WeightThreshold = 0.0;
88  m_MeanThreshold = 0.5;
89  m_VarianceThreshold = 6.0;
90 
91  m_BetaParameter = 1;
92  m_PatchHalfSize = 1;
93  m_SearchStepSize = 2;
94  m_SearchNeighborhood = 4;
95  }
96 
98 
99  void BeforeThreadedGenerateData() ITK_OVERRIDE;
100  void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE;
101 
102 private:
103  ITK_DISALLOW_COPY_AND_ASSIGN(NLMeansPatientToGroupComparisonImageFilter);
104 
105  double ComputeWeightedDistanceScore(itk::VariableLengthVector <double> &patientSample, std::vector < double > &databaseWeights,
106  std::vector < itk::VariableLengthVector <double> > &databaseSamples, double &diffScore);
107 
108  std::vector <InputImagePointer> m_DatabaseImages;
109 
110  OutputImagePointer m_DatabaseCovarianceDistanceAverage;
111  OutputImagePointer m_DatabaseCovarianceDistanceStd;
112  OutputImagePointer m_DatabaseMeanDistanceAverage;
113  OutputImagePointer m_DatabaseMeanDistanceStd;
114 
115  double m_WeightThreshold;
116  double m_MeanThreshold, m_VarianceThreshold;
117  double m_BetaParameter;
118 
119  unsigned int m_PatchHalfSize;
120  unsigned int m_SearchStepSize;
121  unsigned int m_SearchNeighborhood;
122 };
123 
124 } // end namespace anima
125 
NLMeansPatientToGroupComparisonImageFilter< PixelScalarType > Self
void DynamicThreadedGenerateData(const OutputImageRegionType &outputRegionForThread) ITK_OVERRIDE