My Project
template/fullcost.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-2017 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#ifndef mia_internal_fullcost_hh
22#define mia_internal_fullcost_hh
23
25#include <mia/core/vector.hh>
27
29
42template <typename Transform>
44{
45public:
46
48 typedef typename Transform::Size Size;
49
52
55
57 static const char *type_descr;
58
60 static const char *data_descr;
61
63 typedef std::shared_ptr<TFullCost<Transform>> Pointer;
64
69 TFullCost(double weight);
70
71
79 double evaluate(const Transform& t, CDoubleVector& gradient) const;
80
86 double cost_value(const Transform& t) const;
87
92 double cost_value() const;
93
97 void reinit();
98
102 void set_size(const Size& size);
103
110 bool get_full_size(Size& size) const;
111
112protected:
114 double get_weight() const;
115
117 const Size& get_current_size() const;
118private:
119 virtual double do_evaluate(const Transform& t, CDoubleVector& gradient) const = 0;
120 virtual double do_value(const Transform& t) const = 0;
121 virtual double do_value() const = 0;
122 virtual void do_reinit();
123 virtual void do_set_size() = 0;
124 virtual bool do_get_full_size(Size& size) const;
125
126 double m_weight;
127 Size m_current_size;
128
129};
130
137template <typename Transform>
138class EXPORT_HANDLER TFullCostPlugin: public TFactory<TFullCost<Transform>>
139{
140public:
145 TFullCostPlugin(const char *name);
146private:
147 virtual TFullCost<Transform> *do_create() const;
148 virtual TFullCost<Transform> *do_create(float weight) const = 0;
149 float m_weight;
150};
151
152
154
155#endif
The base class for all plug-in created object.
A wrapper around the c-array to provide an STL like interface for iterators.
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition factory.hh:51
the base class for the TFullCost cost function plug-ins.
TFullCostPlugin(const char *name)
Base class for a general cost function.
TFullCost(double weight)
double evaluate(const Transform &t, CDoubleVector &gradient) const
static const char * type_descr
helper string for plug-in handling
double cost_value(const Transform &t) const
double cost_value() const
TFullCost< Transform > plugin_type
helper type for plug-in handling
const Size & get_current_size() const
std::shared_ptr< TFullCost< Transform > > Pointer
The shatred pointer type for this cost function.
void set_size(const Size &size)
bool get_full_size(Size &size) const
double get_weight() const
TFullCost< Transform > plugin_data
helper type for plug-in handling
static const char * data_descr
helper string for plug-in handling
Transform::Size Size
Typedef of the size of the data considered by this cost function.
void reinit()
#define EXPORT_HANDLER
Definition core/cost.hh:32
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36