-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathitkSparseTensorsDiffusionFunction.h
179 lines (130 loc) · 5.04 KB
/
itkSparseTensorsDiffusionFunction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*=========================================================================
Program: Tensor ToolKit - TTK
Module: $URL$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) INRIA 2010. All rights reserved.
See LICENSE.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _itk_SparseTensorsDiffusionFunction_h_
#define _itk_SparseTensorsDiffusionFunction_h_
#include "itkFiniteDifferenceFunction.h"
#include "itkMacro.h"
namespace itk
{
/** \class SparseTensorsDiffusionFunction
*
*
*/
template <class TImage>
class ITK_EXPORT SparseTensorsDiffusionFunction :
public FiniteDifferenceFunction<TImage>
{
public:
/** Standard typedefs */
typedef SparseTensorsDiffusionFunction Self;
typedef FiniteDifferenceFunction<TImage> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods) */
itkTypeMacro(SparseTensorsDiffusionFunction,
FiniteDifferenceFunction);
/** Extract superclass dimension. */
itkStaticConstMacro(ImageDimension, unsigned int,
Superclass::ImageDimension);
/** Inherit some parameters from the superclass type. */
typedef typename Superclass::ImageType ImageType;
typedef typename ImageType::PointType PointType;
typedef typename ImageType::IndexType IndexType;
typedef typename ImageType::SpacingType SpacingType;
typedef typename Superclass::PixelType PixelType;
typedef typename Superclass::RadiusType RadiusType;
typedef typename PixelType::ValueType ScalarType;
typedef typename Superclass::NeighborhoodType NeighborhoodType;
typedef typename Superclass::FloatOffsetType FloatOffsetType;
typedef typename Superclass::TimeStepType TimeStepType;
typedef std::vector<PixelType> VectorOfTensorsType;
typedef std::vector<PointType> VectorOfPointsType;
virtual TimeStepType ComputeGlobalTimeStep(void *GlobalData) const
{ return this->GetTimeStep(); }
void *GetGlobalDataPointer() const
{
GlobalDataStruct *global = new GlobalDataStruct();
global->Energy = 0.0;
return global;
};
void ReleaseGlobalDataPointer(void *GlobalData) const
{
GlobalDataStruct* data = static_cast<GlobalDataStruct*>(GlobalData);
m_Energy += data->Energy;
delete data;
};
virtual void InitializeIteration(void);
/** Set the time step parameter */
void SetTimeStep( const TimeStepType & t )
{ m_TimeStep = t; }
/** Get the time step parameter */
const TimeStepType &GetTimeStep() const
{ return m_TimeStep; }
void SetTensors( const VectorOfTensorsType vec );
VectorOfTensorsType GetTensors(void) const
{ return m_Tensors; }
void SetPoints( const VectorOfPointsType vec )
{ m_Points=vec; }
VectorOfPointsType GetPoints(void) const
{ return m_Points; }
void SetTangents( const VectorOfPointsType vec )
{ m_Tangents = vec; }
VectorOfPointsType GetTangents(void) const
{ return m_Tangents; }
void SetLambda(const double val)
{ m_Lambda = val; }
double GetLambda (void) const
{ return m_Lambda; }
void SetSigma(const double s)
{ m_Sigma=s; }
double GetSigma(void) const
{ return m_Sigma; }
void SetDoNotDiffuseTangents (const bool a)
{ m_DoNotDiffuseTangents = a; }
bool GetDoNotDiffuseTangents (void) const
{ return m_DoNotDiffuseTangents; }
/** This method computes the solution update for each pixel that does not
* lie on a the data set boundary. */
virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
void * globalData,
const FloatOffsetType& offset = FloatOffsetType(0.0)
);
const double GetRMSChange()
{return fabs(m_Energy-m_OldEnergy);};
protected:
SparseTensorsDiffusionFunction();
~SparseTensorsDiffusionFunction(){};
struct GlobalDataStruct
{
double Energy;
};
private:
SparseTensorsDiffusionFunction(const Self&);
void operator=(const Self&);
TimeStepType m_TimeStep;
ScalarType m_Lambda;
ScalarType m_Sigma;
mutable ScalarType m_Energy;
mutable ScalarType m_OldEnergy;
VectorOfTensorsType m_Tensors;
VectorOfPointsType m_Points;
VectorOfPointsType m_Tangents;
bool m_DoNotDiffuseTangents;
};
} // end of namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkSparseTensorsDiffusionFunction.txx"
#endif
#endif