/usr/include/mia-2.4/mia/template/fullcost.hh is in libmia-2.4-dev 2.4.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /* -*- 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
/**
\ingroup registration
\tparam Transform the transformation type used to achieve registration by optimizing the cost function
\brief Base class for a general cost function.
This base class for a cost function does not make any assumptions about what kind of cost is measured.
It only considers a transformation to be applied to input data or to measure a transformation penalty.
*/
template <typename Transform>
class EXPORT_HANDLER TFullCost : public CProductBase {
public:
/// Typedef of the size of the data considered by this cost function
typedef typename Transform::Size Size;
/// helper type for plug-in handling
typedef TFullCost<Transform> plugin_data;
/// helper type for plug-in handling
typedef TFullCost<Transform> plugin_type;
/// helper string for plug-in handling
static const char *type_descr;
/// helper string for plug-in handling
static const char *data_descr;
/// The shatred pointer type for this cost function
typedef std::shared_ptr<TFullCost<Transform> > Pointer;
/**
Initialize the cost function with a weight
\param weight
*/
TFullCost(double weight);
/**
Evaluate the weighted cost value and the weighted gradient in optimizer space
given a current transformation.
\param t tranformation to be applied
\param[out] gradient gradient in optimizer space
\returns weighted cost value
*/
double evaluate(const Transform& t, CDoubleVector& gradient) const;
/**
Evaluate the weighted cost value
\param t tranformation to be applied
\returns weighted cost value
*/
double cost_value(const Transform& t) const;
/**
Evaluate the weighted cost value without transforming the image
\returns weighted cost value
*/
double cost_value() const;
/**
Re-initialalize the cost function
*/
void reinit();
/**
Set the size of the cost function
*/
void set_size(const Size& size);
/**
Get the full size of the registration problem and see if everybody agrees on it.
\param size if it is at Size() at input input it will simply be overwritten, if
it is not equal to Size(), it will be checked that the size is equal to the local one
\returns true if the cost function has setthe size or has the same size as the nonzero one give at input
*/
bool get_full_size(Size& size) const;
protected:
/** \returns cost function weight */
double get_weight() const;
/** \returns the current size of the data in the cost function */
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;
};
/**
\ingroup registration
\tparam Transform the transformation type used to achieve registration by optimizing the cost function
\brief the base class for the TFullCost cost function plug-ins.
*/
template <typename Transform>
class EXPORT_HANDLER TFullCostPlugin: public TFactory<TFullCost<Transform> > {
public:
/**
Constructor for plug-in
\param name the name of the plug-in
*/
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
|