template/fullcost.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_internal_fullcost_hh
#define mia_internal_fullcost_hh
#include <mia/core/product_base.hh>
#include <mia/core/vector.hh>
#include <mia/core/import_handler.hh>
NS_MIA_BEGIN
template <typename Transform>
class EXPORT_HANDLER TFullCost : public CProductBase
{
public:
typedef typename Transform::Size Size;
typedef TFullCost<Transform> plugin_data;
typedef TFullCost<Transform> plugin_type;
static const char *type_descr;
static const char *data_descr;
typedef std::shared_ptr<TFullCost<Transform>> Pointer;
TFullCost(double weight);
double evaluate(const Transform& t, CDoubleVector& gradient) const;
double cost_value(const Transform& t) const;
double cost_value() const;
void reinit();
void set_size(const Size& size);
bool get_full_size(Size& size) const;
protected:
double get_weight() const;
const Size& get_current_size() const;
private:
virtual double do_evaluate(const Transform& t, CDoubleVector& gradient) const = 0;
virtual double do_value(const Transform& t) const = 0;
virtual double do_value() const = 0;
virtual void do_reinit();
virtual void do_set_size() = 0;
virtual bool do_get_full_size(Size& size) const;
double m_weight;
Size m_current_size;
};
template <typename Transform>
class EXPORT_HANDLER TFullCostPlugin: public TFactory<TFullCost<Transform>>
{
public:
TFullCostPlugin(const char *name);
private:
virtual TFullCost<Transform> *do_create() const;
virtual TFullCost<Transform> *do_create(float weight) const = 0;
float m_weight;
};
NS_MIA_END
#endif
CProductBase
The base class for all plug-in created object.
Definition product_base.hh:41
TFactory< TFullCost< Transform > >::TFactory
TFactory(char const *const name)
Definition factory.hh:173
TFullCostPlugin::TFullCostPlugin
TFullCostPlugin(const char *name)
TFullCost
Base class for a general cost function.
Definition template/fullcost.hh:44
TFullCost::TFullCost
TFullCost(double weight)
TFullCost::evaluate
double evaluate(const Transform &t, CDoubleVector &gradient) const
TFullCost< C3DTransformation >::type_descr
static const char * type_descr
Definition template/fullcost.hh:57
TFullCost::cost_value
double cost_value(const Transform &t) const
TFullCost::cost_value
double cost_value() const
TFullCost< C3DTransformation >::plugin_type
TFullCost< C3DTransformation > plugin_type
Definition template/fullcost.hh:54
TFullCost::get_current_size
const Size & get_current_size() const
TFullCost< C3DTransformation >::Pointer
std::shared_ptr< TFullCost< C3DTransformation > > Pointer
Definition template/fullcost.hh:63
TFullCost::set_size
void set_size(const Size &size)
TFullCost::get_full_size
bool get_full_size(Size &size) const
TFullCost::get_weight
double get_weight() const
TFullCost< C3DTransformation >::plugin_data
TFullCost< C3DTransformation > plugin_data
Definition template/fullcost.hh:51
TFullCost< C3DTransformation >::data_descr
static const char * data_descr
Definition template/fullcost.hh:60
TFullCost< C3DTransformation >::Size
C3DTransformation::Size Size
Definition template/fullcost.hh:48
TFullCost::reinit
void reinit()
EXPORT_HANDLER
#define EXPORT_HANDLER
Definition core/cost.hh:32
vector.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
CDoubleVector
TCArrayWrapper< double > CDoubleVector
Definition core/vector.hh:266
import_handler.hh
product_base.hh