-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathitkGaussianInterpolateImageFunction.h
executable file
·180 lines (146 loc) · 5.24 KB
/
itkGaussianInterpolateImageFunction.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
180
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkGaussianInterpolateImageFunction.h,v $
Language: C++
Date: $Date: $
Version: $Revision: $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkGaussianInterpolateImageFunction_h
#define __itkGaussianInterpolateImageFunction_h
#include "itkInterpolateImageFunction.h"
#include "itkConceptChecking.h"
#include "itkFixedArray.h"
#include "vnl/vnl_erf.h"
namespace itk
{
/** \class GaussianInterpolateImageFunction
* \brief Evaluates the Gaussian interpolation of an image.
*
* This class defines an N-dimensional Gaussian interpolation function using
* the vnl error function. The two parameters associated with this function
* are:
* 1. Sigma - a scalar array of size ImageDimension determining the width
* of the interpolation function.
* 2. Alpha - a scalar specifying the cutoff distance over which the function
* is calculated.
*
* \ingroup ImageFunctions ImageInterpolators
*/
template <class TInputImage, class TCoordRep = double>
class ITK_EXPORT GaussianInterpolateImageFunction :
public InterpolateImageFunction<TInputImage, TCoordRep>
{
public:
/** Standard class typedefs. */
typedef GaussianInterpolateImageFunction Self;
typedef InterpolateImageFunction<TInputImage, TCoordRep> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro( GaussianInterpolateImageFunction, InterpolateImageFunction );
/** Method for creation through the object factory. */
itkNewMacro( Self );
/** ImageDimension constant */
itkStaticConstMacro( ImageDimension, unsigned int,
TInputImage::ImageDimension );
/** OutputType typedef support. */
typedef typename Superclass::OutputType OutputType;
/** InputImageType typedef support. */
typedef typename Superclass::InputImageType InputImageType;
/** RealType typedef support. */
typedef typename Superclass::RealType RealType;
/** Index typedef support. */
typedef typename Superclass::IndexType IndexType;
/** ContinuousIndex typedef support. */
typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
/** Array typedef support */
typedef FixedArray<RealType,
itkGetStaticConstMacro( ImageDimension )> ArrayType;
/**
* Set input image
*/
virtual void SetInputImage( const TInputImage *image )
{
Superclass::SetInputImage( image );
this->ComputeBoundingBox();
}
/**
* Set/Get ivars
*/
virtual void SetSigma( const ArrayType s )
{
itkDebugMacro( "setting Sigma to " << s );
if( this->m_Sigma != s )
{
this->m_Sigma = s;
this->ComputeBoundingBox();
this->Modified();
}
}
itkGetConstMacro( Sigma, ArrayType );
void SetSigma( RealType *s )
{
ArrayType sigma;
for( unsigned int d = 0; d < ImageDimension; d++ )
{
sigma[d] = s[d];
}
this->SetSigma( sigma );
}
virtual void SetAlpha( const RealType a )
{
itkDebugMacro( "setting Alpha to " << a );
if( this->m_Alpha != a )
{
this->m_Alpha = a;
this->ComputeBoundingBox();
this->Modified();
}
}
itkGetConstMacro( Alpha, RealType );
void SetParameters( RealType *sigma, RealType alpha )
{
this->SetSigma( sigma );
this->SetAlpha( alpha );
}
/**
* Evaluate at the given index
*/
virtual OutputType EvaluateAtContinuousIndex(
const ContinuousIndexType & cindex ) const
{
return this->EvaluateAtContinuousIndex( cindex, NULL );
}
/**
* Evaluate function value and gradient at the given index
*/
virtual OutputType EvaluateAtContinuousIndex(
const ContinuousIndexType &, OutputType * ) const;
protected:
GaussianInterpolateImageFunction();
~GaussianInterpolateImageFunction(){};
void PrintSelf( std::ostream& os, Indent indent ) const;
private:
GaussianInterpolateImageFunction( const Self& ); //purposely not implemented
void operator=( const Self& ); //purposely not implemented
void ComputeBoundingBox();
void ComputeErrorFunctionArray( unsigned int dimension, RealType cindex,
vnl_vector<RealType> &erfArray, vnl_vector<RealType> &gerfArray,
bool evaluateGradient = false ) const;
ArrayType m_Sigma;
RealType m_Alpha;
ArrayType m_BoundingBoxStart;
ArrayType m_BoundingBoxEnd;
ArrayType m_ScalingFactor;
ArrayType m_CutoffDistance;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkGaussianInterpolateImageFunction.hxx"
#endif
#endif