Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
mia
core
transformation.hh
Go to the documentation of this file.
1
/* -*- mia-c++ -*-
2
*
3
* This file is part of MIA - a toolbox for medical image analysis
4
* Copyright (c) Leipzig, Madrid 1999-2013 Gert Wollny
5
*
6
* MIA is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
#ifndef mia_core_transformation_hh
23
#define mia_core_transformation_hh
24
25
#include <
mia/core/iodata.hh
>
26
#include <
mia/core/attributes.hh
>
27
#include <
mia/core/vector.hh
>
28
29
NS_MIA_BEGIN
30
31
43
template
<
typename
D,
typename
I>
44
class
Transformation
:
public
CIOData
,
public
CAttributedData
{
45
public
:
46
48
static
const
char
*
type_descr
;
49
50
virtual
~Transformation
();
51
53
typedef
D
Data
;
54
56
typedef
I
InterpolatorFactory
;
57
62
Transformation
(
const
I& ipf);
63
68
std::shared_ptr<D>
operator ()
(
const
D& input)
const
;
69
74
void
set_interpolator_factory
(
const
I& ipf);
75
76
84
double
get_energy_penalty_and_gradient
(
CDoubleVector
& gradient)
const
;
85
87
double
get_energy_penalty
()
const
;
88
90
bool
has_energy_penalty
()
const
;
91
protected
:
92
94
const
I&
get_interpolator_factory
()
const
;
95
private
:
96
virtual
std::shared_ptr<D> do_transform(
const
D& input,
const
I& ipf)
const
= 0;
97
virtual
double
do_get_energy_penalty_and_gradient(
CDoubleVector
& gradient)
const
;
98
virtual
double
do_get_energy_penalty()
const
;
99
virtual
bool
do_has_energy_penalty()
const
;
100
101
I m_ipf;
102
103
};
104
112
template
<
typename
T>
113
T
load_transform
(
const
std::string& MIA_PARAM_UNUSED(file)) {
114
static_assert(
sizeof
(T) == 0,
"this needs to specialized for the handled type"
);
115
}
116
117
// implementation
118
template
<
typename
D,
typename
I>
119
Transformation<D, I>::Transformation
(
const
I& ipf):
120
m_ipf(ipf)
121
{
122
123
}
124
125
template
<
typename
D,
typename
I>
126
Transformation<D, I>::~Transformation
()
127
{
128
}
129
130
template
<
typename
D,
typename
I>
131
void
Transformation<D, I>::set_interpolator_factory
(
const
I& ipf)
132
{
133
m_ipf = ipf;
134
}
135
136
template
<
typename
D,
typename
I>
137
const
I&
Transformation<D, I>::get_interpolator_factory
()
const
138
{
139
return
m_ipf;
140
}
141
142
template
<
typename
D,
typename
I>
143
std::shared_ptr<D >
Transformation<D,I>::operator()
(
const
D& input)
const
144
{
145
return
do_transform(input, m_ipf);
146
}
147
148
template
<
typename
D,
typename
I>
149
double
Transformation<D,I>::get_energy_penalty_and_gradient
(
CDoubleVector
& gradient)
const
150
{
151
return
do_get_energy_penalty_and_gradient(gradient);
152
}
153
154
155
template
<
typename
D,
typename
I>
156
double
Transformation<D,I>::get_energy_penalty
()
const
157
{
158
return
do_get_energy_penalty();
159
}
160
161
template
<
typename
D,
typename
I>
162
double
Transformation<D,I>::do_get_energy_penalty_and_gradient
(
CDoubleVector
& gradient)
const
163
{
164
std::fill(gradient.
begin
(), gradient.
end
(), 0.0);
165
return
0.0;
166
}
167
168
169
template
<
typename
D,
typename
I>
170
double
Transformation<D,I>::do_get_energy_penalty
()
const
171
{
172
return
0.0;
173
}
174
175
template
<
typename
D,
typename
I>
176
bool
Transformation<D,I>::has_energy_penalty
()
const
177
{
178
return
do_has_energy_penalty();
179
}
180
181
182
template
<
typename
D,
typename
I>
183
bool
Transformation<D,I>::do_has_energy_penalty
()
const
184
{
185
return
false
;
186
}
187
188
template
<
typename
D,
typename
I>
189
const
char
*
Transformation<D, I>::type_descr
=
"transform"
;
190
191
NS_MIA_END
192
193
194
#endif
Generated on Tue Oct 15 2013 13:56:37 by
1.8.4