My Project
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 {
53 protected:
54 
58  C1DFilterKernel(unsigned fsize);
59 
60  virtual ~C1DFilterKernel();
61 public:
66 
68  int get_fsize() const;
69 
71  size_t size() const;
72 
76  void apply_inplace(std::vector<double>& data) const;
77 
83  std::vector<double> apply(const std::vector<double>& data) const;
84 
85 private:
87  virtual size_t do_size() const = 0;
88 
89  virtual std::vector<double> do_apply(const std::vector<double>& data) const = 0;
90 
91  unsigned m_fsize;
92 
93 };
94 
101 {
102 public:
103 
104 
106  typedef std::vector<double> vec_mask;
107 
109  typedef vec_mask::const_iterator const_iterator;
110 
115  C1DFoldingKernel(int fsize);
116 
117 
119  const_iterator begin()const;
120 
122  const_iterator end()const;
123 
125  const_iterator dbegin()const;
126 
128  const_iterator dend()const;
129 
131  double& operator[](int i)
132  {
133  return m_mask[i];
134  }
135 
137  double operator[](int i)const
138  {
139  return m_mask[i];
140  }
141 protected:
143  typedef vec_mask::iterator iterator;
144 
146  iterator begin();
147 
149  iterator end();
150 
152  iterator dbegin();
153 
155  iterator dend();
156 
157 private:
159  virtual size_t do_size() const;
160 
161  vec_mask m_mask;
162  vec_mask m_derivative;
163 
164 };
165 
168 
169 typedef std::shared_ptr<C1DFoldingKernel> P1DSpacialKernel;
170 
171 template<> const char *const
173 
176 
177 
178 inline P1DSpacialKernel produce_spacial_kernel(const std::string& descr)
179 {
180  return C1DSpacialKernelPluginHandler::instance().produce(descr);
181 }
182 
186 
188 
189 #endif
spacial_kernel_data::data_descr
static const char * data_descr
Definition: spacial_kernel.hh:34
spacial_kernel_data
Definition: spacial_kernel.hh:33
THandlerSingleton::instance
static const T & instance()
factory.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
produce_spacial_kernel
P1DSpacialKernel produce_spacial_kernel(const std::string &descr)
Definition: spacial_kernel.hh:178
kernel_plugin_type
Definition: spacial_kernel.hh:38
C1DFilterKernel
base class for 1D filter kernels
Definition: spacial_kernel.hh:51
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
P1DSpacialKernel
std::shared_ptr< C1DFoldingKernel > P1DSpacialKernel
Definition: spacial_kernel.hh:169
THandlerSingleton
the singleton that a plug-in handler really is
Definition: handler.hh:158
C1DFoldingKernel
Base class for folding kernal types.
Definition: spacial_kernel.hh:100
TPluginHandler
The basic template of all plugin handlers.
Definition: handler.hh:56
C1DFoldingKernel::operator[]
double operator[](int i) const
standard access operator, ro version
Definition: spacial_kernel.hh:137
kernel_plugin_type::type_descr
static const char * type_descr
Definition: spacial_kernel.hh:39
C1DFoldingKernel::const_iterator
vec_mask::const_iterator const_iterator
iterator over the kernel
Definition: spacial_kernel.hh:109
CProductBase
The base class for all plug-in created object.
Definition: product_base.hh:40
C1DFoldingKernel::vec_mask
std::vector< double > vec_mask
Data type of the kernel coefficient vector.
Definition: spacial_kernel.hh:106
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
FACTORY_TRAIT
#define FACTORY_TRAIT(F)
Definition: factory_trait.hh:69
C1DFilterKernel::plugin_type
kernel_plugin_type plugin_type
define the plugin search path, type part
Definition: spacial_kernel.hh:65
C1DSpacialKernelPlugin
TFactory< C1DFoldingKernel > C1DSpacialKernelPlugin
base class for filters kernels working in the spacial domain
Definition: spacial_kernel.hh:167
C1DFoldingKernel::iterator
vec_mask::iterator iterator
kernel iterator
Definition: spacial_kernel.hh:143
C1DFoldingKernel::operator[]
double & operator[](int i)
standard access operator, rw version
Definition: spacial_kernel.hh:131
C1DSpacialKernelPluginHandler
THandlerSingleton< TFactoryPluginHandler< C1DSpacialKernelPlugin > > C1DSpacialKernelPluginHandler
plugin handler for spaciel filter kernels
Definition: spacial_kernel.hh:175
defines.hh
C1DFilterKernel::plugin_data
spacial_kernel_data plugin_data
define the plugin search path, data part
Definition: spacial_kernel.hh:63
TFactory
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:49