My Project
2d/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-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_2d_splinetransformpenalty_hh
22 #define mia_2d_splinetransformpenalty_hh
23 
24 #include <mia/2d/interpolator.hh>
25 #include <mia/2d/datafield.hh>
26 #include <mia/core/vector.hh>
27 #include <mia/core/product_base.hh>
28 
29 
31 
40 {
41 
42 public:
44  static const char *data_descr;
46  static const char *type_descr;
47 
53  C2DSplineTransformPenalty(double weight, bool normalize);
54 
56  C2DSplineTransformPenalty& operator = (const C2DSplineTransformPenalty& org) = delete;
57 
62  C2DSplineTransformPenalty *clone() const __attribute__((warn_unused_result));
63 
65 
72  void initialize(const C2DBounds& size, const C2DFVector& range, PSplineKernel kernel);
73 
79  double value(const C2DFVectorfield& coefficients) const;
80 
89  double value_and_gradient(const C2DFVectorfield& coefficients, CDoubleVector& gradient) const;
90 
91 protected:
92 
93  const C2DBounds& get_size() const;
94 
95  const C2DFVector& get_range() const;
96 
97  PSplineKernel get_kernel() const;
98 
99  double get_weight() const;
100 
101  bool get_normalize() const;
102 
103 private:
104 
105  virtual void do_initialize() = 0;
106 
107  virtual double do_value(const C2DFVectorfield& coefficients) const = 0;
108 
109  virtual double do_value_and_gradient(const C2DFVectorfield& coefficients, CDoubleVector& gradient) const = 0;
110 
111  virtual C2DSplineTransformPenalty *do_clone() const = 0;
112 
113  double m_weight;
114  bool m_normalize;
115 
116  C2DBounds m_size;
117  C2DFVector m_range;
118  PSplineKernel m_kernel;
119 };
120 
122 
123 
125 {
126 public:
127  C2DSplineTransformPenaltyPlugin(char const *const name);
128 private:
129  virtual Product *do_create() const __attribute__((warn_unused_result));
130  virtual Product *do_create(float weight, bool normalize) const __attribute__((warn_unused_result)) = 0 ;
131 
132  float m_weight;
133  bool m_normalize;
134 };
135 
136 
140 
141 
143 
144 
146 
147 
149 {
150 public:
152 };
153 
155 
156 #endif
C2DSplineTransformPenalty::C2DSplineTransformPenalty
C2DSplineTransformPenalty(double weight, bool normalize)
datafield.hh
produce_2d_spline_transform_penalty
EXPORT_2D C2DSplineTransformPenaltyPluginHandler::ProductPtr produce_2d_spline_transform_penalty(const std::string &descr)
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
C2DSplineTransformPenaltyPluginHandlerTest::C2DSplineTransformPenaltyPluginHandlerTest
C2DSplineTransformPenaltyPluginHandlerTest()
C2DSplineTransformPenaltyPlugin::C2DSplineTransformPenaltyPlugin
C2DSplineTransformPenaltyPlugin(char const *const name)
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
C2DSplineTransformPenalty::plugin_type
C2DSplineTransformPenalty plugin_type
Definition: 2d/splinetransformpenalty.hh:45
THandlerSingleton
the singleton that a plug-in handler really is
Definition: handler.hh:159
interpolator.hh
T2DVector< unsigned int >
vector.hh
PSplineKernel
std::shared_ptr< CSplineKernel > PSplineKernel
Definition: splinekernel.hh:291
C2DSplineTransformPenalty::C2DSplineTransformPenalty
C2DSplineTransformPenalty(const C2DSplineTransformPenalty &org)=delete
C2DSplineTransformPenaltyPlugin
Definition: 2d/splinetransformpenalty.hh:125
normalize
std::shared_ptr< Image > normalize(const Image &image)
a normalizer for image intensities
Definition: normalize.hh:135
C2DSplineTransformPenalty::plugin_data
C2DSplineTransformPenalty plugin_data
Definition: 2d/splinetransformpenalty.hh:43
CProductBase
The base class for all plug-in created object.
Definition: product_base.hh:41
FACTORY_TRAIT
FACTORY_TRAIT(C2DSplineTransformPenaltyPluginHandler)
C2DFVectorfield
a 2D field of floating point single accuracy 2D vectors
Definition: 2d/vectorfield.hh:80
C2DSplineTransformPenalty::data_descr
static const char * data_descr
Definition: 2d/splinetransformpenalty.hh:44
TFactoryPluginHandler
the Base class for all plugn handlers that deal with factory plugins.
Definition: factory.hh:95
P2DSplineTransformPenalty
std::shared_ptr< C2DSplineTransformPenalty > P2DSplineTransformPenalty
Definition: 2d/splinetransformpenalty.hh:121
C2DSplineTransformPenaltyPluginHandlerTest
Definition: 2d/splinetransformpenalty.hh:149
std
Definition: gsl_iterator.hh:324
product_base.hh
TCArrayWrapper
A wrapper around the c-array to provide an STL like interface for iterators.
Definition: core/vector.hh:78
C2DSplineTransformPenalty
Base class for transformation penalties in spline based deformations.
Definition: 2d/splinetransformpenalty.hh:40
C2DSplineTransformPenalty::type_descr
static const char * type_descr
Definition: 2d/splinetransformpenalty.hh:46
EXPORT_2D
#define EXPORT_2D
Definition: defines2d.hh:37
C2DSplineTransformPenalty::clone
C2DSplineTransformPenalty * clone() const __attribute__((warn_unused_result))
TFactory
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:51