3d/splinetransformpenalty.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 #ifndef mia_3d_splinetransformpenalty_hh
22 #define mia_3d_splinetransformpenalty_hh
23 
24 #include <mia/3d/interpolator.hh>
25 #include <mia/3d/datafield.hh>
26 #include <mia/core/vector.hh>
27 #include <mia/core/product_base.hh>
28 
29 
31 
40 
41 public:
43  static const char *data_descr;
45  static const char *type_descr;
46 
51  C3DSplineTransformPenalty(double weight);
52 
54  C3DSplineTransformPenalty& operator = (const C3DSplineTransformPenalty& org) = delete;
55 
60  C3DSplineTransformPenalty *clone() const __attribute__((warn_unused_result));
61 
62  virtual ~C3DSplineTransformPenalty();
63 
70  void initialize(const C3DBounds& size, const C3DFVector& range, PSplineKernel kernel);
71 
77  double value(const C3DFVectorfield& coefficients) const;
78 
87  double value_and_gradient(const C3DFVectorfield& coefficients, CDoubleVector& gradient) const;
88 
89 protected:
90 
91 
92 
93  const C3DBounds& get_size() const;
94 
95  const C3DFVector& get_range() const;
96 
97  PSplineKernel get_kernel() const;
98 
99  double get_weight() const;
100 
101 private:
102 
103  virtual void do_initialize() = 0;
104 
105  virtual double do_value(const C3DFVectorfield& coefficients) const = 0;
106 
107  virtual double do_value_and_gradient(const C3DFVectorfield& coefficients, CDoubleVector& gradient) const = 0;
108 
109  virtual C3DSplineTransformPenalty *do_clone() const = 0;
110 
111  double m_weight;
112 
113  C3DBounds m_size;
114  C3DFVector m_range;
115  PSplineKernel m_kernel;
116 };
117 
118 typedef std::shared_ptr<C3DSplineTransformPenalty> P3DSplineTransformPenalty;
119 
120 
121 class EXPORT_3D C3DSplineTransformPenaltyPlugin: public TFactory<C3DSplineTransformPenalty> {
122 public:
123  C3DSplineTransformPenaltyPlugin(char const * const name);
124 private:
125  virtual Product *do_create() const __attribute__((warn_unused_result));
126  virtual Product *do_create(float weight) const __attribute__((warn_unused_result)) = 0 ;
127 
128  float m_weight;
129 };
130 
131 
135 
136 
138 
139 
140 EXPORT_3D C3DSplineTransformPenaltyPluginHandler::ProductPtr produce_3d_spline_transform_penalty(const std::string& descr);
141 
142 
144 public:
146 };
147 
149 
150 #endif
the singleton that a plug-in handler really is
Definition: handler.hh:143
Base class for transformation penalties in spline based deformations.
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:74
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:43
#define EXPORT_3D
Definition: defines3d.hh:44
THandlerSingleton< TFactoryPluginHandler< C3DSplineTransformPenaltyPlugin > > C3DSplineTransformPenaltyPluginHandler
Plugin handler for image combiner plugins.
std::shared_ptr< CSplineKernel > PSplineKernel
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:49
C3DSplineTransformPenalty plugin_data
std::shared_ptr< C3DSplineTransformPenalty > P3DSplineTransformPenalty
The base class for all plug-in created object.
Definition: product_base.hh:40
EXPORT_3D C3DSplineTransformPenaltyPluginHandler::ProductPtr produce_3d_spline_transform_penalty(const std::string &descr)
FACTORY_TRAIT(C3DSplineTransformPenaltyPluginHandler)
C3DSplineTransformPenalty plugin_type
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:46