ITK
4.2.0
Insight Segmentation and Registration Toolkit
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
ITK
Modules
Numerics
FEM
include
itkFEMImageMetricLoad.h
Go to the documentation of this file.
1
/*=========================================================================
2
*
3
* Copyright Insight Software Consortium
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0.txt
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*=========================================================================*/
18
#ifndef __itkFEMImageMetricLoad_h
19
#define __itkFEMImageMetricLoad_h
20
21
#include "
itkFEMLoadElementBase.h
"
22
23
#include "
itkImage.h
"
24
#include "
itkTranslationTransform.h
"
25
26
#include "
itkImageRegionIteratorWithIndex.h
"
27
#include "
itkNeighborhoodIterator.h
"
28
#include "
itkNeighborhoodIterator.h
"
29
#include "
itkNeighborhoodInnerProduct.h
"
30
#include "
itkDerivativeOperator.h
"
31
#include "
itkForwardDifferenceOperator.h
"
32
#include "
itkLinearInterpolateImageFunction.h
"
33
#include "vnl/vnl_math.h"
34
35
#include <
itkMutualInformationImageToImageMetric.h
>
36
#include <
itkMattesMutualInformationImageToImageMetric.h
>
37
#include <
itkMeanSquaresImageToImageMetric.h
>
38
#include <
itkNormalizedCorrelationImageToImageMetric.h
>
39
40
namespace
itk
41
{
42
namespace
fem
43
{
68
template
<
class
TMoving,
class
TFixed>
69
class
ImageMetricLoad
:
public
LoadElement
70
{
71
public
:
72
74
typedef
ImageMetricLoad
Self
;
75
typedef
LoadElement
Superclass
;
76
typedef
SmartPointer<Self>
Pointer
;
77
typedef
SmartPointer<const Self>
ConstPointer
;
78
80
itkSimpleNewMacro(
Self
);
81
83
itkTypeMacro(
ImageMetricLoad
,
LoadElement
);
84
87
virtual::itk::LightObject::Pointer
CreateAnother
(
void
)
const
;
88
89
// Necessary typedefs for dealing with images BEGIN
90
typedef
typename
LoadElement::Float
Float
;
91
92
typedef
TMoving
MovingType
;
93
typedef
typename
MovingType::ConstPointer
MovingConstPointer
;
94
typedef
MovingType
*
MovingPointer
;
95
typedef
TFixed
FixedType
;
96
typedef
FixedType
*
FixedPointer
;
97
typedef
typename
FixedType::ConstPointer
FixedConstPointer
;
98
100
itkStaticConstMacro(
ImageDimension
,
unsigned
int
,
101
MovingType::ImageDimension);
102
103
typedef
ImageRegionIteratorWithIndex<MovingType>
RefRegionIteratorType
;
104
typedef
ImageRegionIteratorWithIndex<FixedType>
TarRegionIteratorType
;
105
106
typedef
NeighborhoodIterator<MovingType>
107
MovingNeighborhoodIteratorType
;
108
typedef
typename
MovingNeighborhoodIteratorType::IndexType
109
MovingNeighborhoodIndexType
;
110
typedef
typename
MovingNeighborhoodIteratorType::RadiusType
111
MovingRadiusType
;
112
typedef
NeighborhoodIterator<FixedType>
113
FixedNeighborhoodIteratorType
;
114
typedef
typename
FixedNeighborhoodIteratorType::IndexType
115
FixedNeighborhoodIndexType
;
116
typedef
typename
FixedNeighborhoodIteratorType::RadiusType
117
FixedRadiusType
;
118
119
// IMAGE DATA
120
typedef
typename
MovingType::PixelType
RefPixelType
;
121
typedef
typename
FixedType::PixelType
TarPixelType
;
122
typedef
Float
PixelType
;
123
typedef
Float
ComputationType
;
124
typedef
Image<RefPixelType, itkGetStaticConstMacro(ImageDimension)>
RefImageType
;
125
typedef
Image<TarPixelType, itkGetStaticConstMacro(ImageDimension)>
TarImageType
;
126
typedef
Image<PixelType, itkGetStaticConstMacro(ImageDimension)>
ImageType
;
127
typedef
vnl_vector<Float>
VectorType
;
128
129
// Necessary typedefs for dealing with images END
130
131
// ------------------------------------------------------------
132
// Set up the metrics
133
// ------------------------------------------------------------
134
typedef
double
135
CoordinateRepresentationType
;
136
typedef
Transform
<
CoordinateRepresentationType
, itkGetStaticConstMacro(
ImageDimension
),
137
itkGetStaticConstMacro(
ImageDimension
)>
TransformBaseType
;
138
typedef
TranslationTransform
<
CoordinateRepresentationType
,
139
itkGetStaticConstMacro(
ImageDimension
)>
DefaultTransformType
;
140
142
typedef
ImageToImageMetric<FixedType, MovingType>
MetricBaseType
;
143
typedef
typename
MetricBaseType::Pointer
MetricBaseTypePointer
;
144
145
typedef
MutualInformationImageToImageMetric<MovingType, FixedType>
MutualInformationMetricType
;
146
147
typedef
MeanSquaresImageToImageMetric<MovingType, FixedType>
MeanSquaresMetricType
;
148
149
typedef
NormalizedCorrelationImageToImageMetric<MovingType, FixedType>
NormalizedCorrelationMetricType
;
150
151
typedef
MeanSquaresMetricType
DefaultMetricType
;
152
typedef
typename
DefaultTransformType::ParametersType
ParametersType
;
153
typedef
typename
DefaultTransformType::JacobianType
JacobianType
;
154
155
typedef
unsigned
long
ElementIdentifier
;
156
typedef
VectorContainer<ElementIdentifier, Element::Pointer>
ElementContainerType
;
157
// ------------------------------------------------------------
158
// Set up an Interpolator
159
// ------------------------------------------------------------
160
typedef
LinearInterpolateImageFunction<MovingType, double>
InterpolatorType
;
161
163
typedef
float
RealType
;
164
typedef
CovariantVector
<
RealType
,
165
itkGetStaticConstMacro(
ImageDimension
)>
GradientPixelType
;
166
typedef
Image
<
GradientPixelType
,
167
itkGetStaticConstMacro(
ImageDimension
)>
GradientImageType
;
168
typedef
SmartPointer<GradientImageType>
GradientImagePointer
;
169
typedef
GradientRecursiveGaussianImageFilter
<
ImageType
,
170
GradientImageType
>
171
GradientImageFilterType
;
172
// typedef typename GradientImageFilterType::Pointer
173
// GradientImageFilterPointer;
175
176
// FUNCTIONS
177
179
void
SetMetric
(
MetricBaseTypePointer
MP)
180
{
181
m_Metric
= MP;
182
}
183
185
void
SetMovingImage
(
MovingType
*R)
186
{
187
m_RefImage
= R;
188
m_RefSize
=
m_RefImage
->GetLargestPossibleRegion().GetSize();
189
}
191
192
void
SetMetricMovingImage
(
MovingType
*R)
193
{
194
m_Metric
->SetMovingImage(R);
195
m_RefSize
= R->GetLargestPossibleRegion().GetSize();
196
}
197
199
void
SetFixedImage
(
FixedType
*T)
200
{
201
m_TarImage
= T;
202
m_TarSize
= T->GetLargestPossibleRegion().GetSize();
203
}
205
206
void
SetMetricFixedImage
(
FixedType
*T)
207
{
208
m_Metric
->SetFixedImage(T);
209
m_TarSize
= T->GetLargestPossibleRegion().GetSize();
210
}
211
212
MovingPointer
GetMovingImage
()
213
{
214
return
m_RefImage
;
215
}
216
FixedPointer
GetFixedImage
()
217
{
218
return
m_TarImage
;
219
}
220
222
void
SetMetricRadius
(
MovingRadiusType
T)
223
{
224
m_MetricRadius = T;
225
}
226
228
MovingRadiusType
GetMetricRadius
()
229
{
230
return
m_MetricRadius;
231
}
232
237
void
SetNumberOfIntegrationPoints
(
unsigned
int
i)
238
{
239
m_NumberOfIntegrationPoints
= i;
240
}
241
unsigned
int
GetNumberOfIntegrationPoints
()
242
{
243
return
m_NumberOfIntegrationPoints
;
244
}
246
250
void
SetSign
(
Float
s)
251
{
252
m_Sign
= s;
253
}
254
256
void
SetTemp
(
Float
s)
257
{
258
m_Temp
= s;
259
}
260
262
void
SetGamma
(
Float
s)
263
{
264
m_Gamma
= s;
265
}
266
270
void
SetSolution
(
Solution::ConstPointer
ptr)
271
{
272
m_Solution
= ptr;
273
}
274
278
Solution::ConstPointer
GetSolution
()
279
{
280
return
m_Solution
;
281
}
282
286
Float
GetMetric
(
VectorType
InVec);
287
288
VectorType
GetPolynomialFitToMetric
(
VectorType
PositionInElement,
VectorType
SolutionAtPosition);
289
290
VectorType
MetricFiniteDiff
(
VectorType
PositionInElement,
VectorType
SolutionAtPosition);
291
292
// FIXME - WE ASSUME THE 2ND VECTOR (INDEX 1) HAS THE INFORMATION WE WANT
293
Float
GetSolution
(
unsigned
int
i,
unsigned
int
which = 0)
294
{
295
return
m_Solution
->
GetSolutionValue
(i, which);
296
}
297
298
// define the copy constructor
299
// ImageMetricLoad(const ImageMetricLoad& LMS);
300
301
void
InitializeMetric
(
void
);
302
303
ImageMetricLoad
();
// cannot be private until we always use smart pointers
304
Float
EvaluateMetricGivenSolution
(
Element::ArrayType
*el,
Float
step = 1.0);
305
306
Float
EvaluateMetricGivenSolution1
(
Element::ArrayType
*el,
Float
step = 1.0);
307
311
VectorType
Fe
(
VectorType
,
VectorType
);
312
313
static
Baseclass
*
NewImageMetricLoad
(
void
)
314
{
315
return
new
ImageMetricLoad
;
316
}
317
319
// void InitializeGradientImage();
320
void
SetMetricGradientImage
(
GradientImageType
*g)
321
{
322
m_MetricGradientImage
= g;
323
}
324
GradientImageType
*
GetMetricGradientImage
()
325
{
326
return
m_MetricGradientImage
;
327
}
329
330
void
PrintCurrentEnergy
()
331
{
332
std::cout <<
" energy "
<<
m_Energy
<< std::endl;
333
}
334
double
GetCurrentEnergy
()
335
{
336
return
m_Energy
;
337
}
338
void
SetCurrentEnergy
(
double
e
)
339
{
340
m_Energy
=
e
;
341
}
342
343
// FIXME - Documentation
344
virtual
void
ApplyLoad
(
Element::ConstPointer
element,
Element::VectorType
&
Fe
);
345
346
protected
:
347
virtual
void
PrintSelf
(std::ostream& os,
Indent
indent)
const
;
348
349
private
:
350
GradientImageType
*
m_MetricGradientImage
;
351
MovingPointer
m_RefImage
;
352
FixedPointer
m_TarImage
;
355
typename
MovingType::SizeType
m_RefSize
;
356
typename
FixedType::SizeType
m_TarSize
;
357
unsigned
int
m_NumberOfIntegrationPoints
;
358
unsigned
int
m_SolutionIndex
;
359
unsigned
int
m_SolutionIndex2
;
360
Float
m_Sign
;
361
Float
m_Temp
;
362
Float
m_Gamma
;
363
364
typename
Solution::ConstPointer
m_Solution
;
365
MetricBaseTypePointer
m_Metric
;
366
typename
TransformBaseType::Pointer
m_Transform
;
367
typename
InterpolatorType::Pointer
m_Interpolator
;
368
369
mutable
double
m_Energy
;
370
private
:
371
372
};
373
}
374
}
// end namespace fem/itk
375
376
#ifndef ITK_MANUAL_INSTANTIATION
377
#include "itkFEMImageMetricLoad.hxx"
378
#endif
379
380
#endif
381
Generated on Tue Jul 10 2012 23:25:07 for ITK by
1.8.1