spacial_kernel.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_core_spacial_kernel_hh
22 #define mia_core_spacial_kernel_hh
23 
24 
25 #include <vector>
26 
27 // MIA specific
28 #include <mia/core/defines.hh>
29 #include <mia/core/factory.hh>
30 
32 
34  static const char *data_descr;
35 };
36 
37 
39  static const char *type_descr;
40 };
41 
52 protected:
53 
57  C1DFilterKernel(unsigned fsize);
58 
59  virtual ~C1DFilterKernel();
60 public:
65 
67  int get_fsize() const;
68 
70  size_t size() const;
71 
75  void apply_inplace(std::vector<double>& data) const;
76 
82  std::vector<double> apply(const std::vector<double>& data) const;
83 
84 private:
86  virtual size_t do_size() const = 0;
87 
88  virtual std::vector<double> do_apply(const std::vector<double>& data) const = 0;
89 
90  unsigned m_fsize;
91 
92 };
93 
100 public:
101 
102 
104  typedef std::vector<double> vec_mask;
105 
107  typedef vec_mask::const_iterator const_iterator;
108 
113  C1DFoldingKernel(int fsize);
114 
115 
117  const_iterator begin()const;
118 
120  const_iterator end()const;
121 
123  const_iterator dbegin()const;
124 
126  const_iterator dend()const;
127 
129  double& operator[](int i) {
130  return m_mask[i];
131  }
132 
134  double operator[](int i)const {
135  return m_mask[i];
136  }
137 protected:
139  typedef vec_mask::iterator iterator;
140 
142  iterator begin();
143 
145  iterator end();
146 
148  iterator dbegin();
149 
151  iterator dend();
152 
153 private:
155  virtual size_t do_size() const;
156 
157  vec_mask m_mask;
158  vec_mask m_derivative;
159 
160 };
161 
164 
165 typedef std::shared_ptr<C1DFoldingKernel> P1DSpacialKernel;
166 
167 template<> const char * const
169 
172 
173 
174 inline P1DSpacialKernel produce_spacial_kernel(const std::string& descr)
175 {
176  return C1DSpacialKernelPluginHandler::instance().produce(descr);
177 }
178 
182 
184 
185 #endif
the singleton that a plug-in handler really is
Definition: handler.hh:157
std::shared_ptr< C1DFoldingKernel > P1DSpacialKernel
THandlerSingleton< TFactoryPluginHandler< C1DSpacialKernelPlugin > > C1DSpacialKernelPluginHandler
plugin handler for spaciel filter kernels
static const char * data_descr
vec_mask::iterator iterator
kernel iterator
P1DSpacialKernel produce_spacial_kernel(const std::string &descr)
vec_mask::const_iterator const_iterator
iterator over the kernel
spacial_kernel_data plugin_data
define the plugin search path, data part
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
base class for 1D filter kernels
double & operator[](int i)
standard access operator, rw version
#define FACTORY_TRAIT(F)
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:49
TFactory< C1DFoldingKernel > C1DSpacialKernelPlugin
base class for filters kernels working in the spacial domain
kernel_plugin_type plugin_type
define the plugin search path, type part
double operator[](int i) const
standard access operator, ro version
Base class for folding kernal types.
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
static const char * type_descr
The base class for all plug-in created object.
Definition: product_base.hh:40
static const T & instance()
std::vector< double > vec_mask
Data type of the kernel coefficient vector.
The basic template of all plugin handlers.
Definition: handler.hh:56
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36