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 
120 
123 
126 
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 
147 
150 
153 
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
base class for 1D filter kernels
C1DFilterKernel(unsigned fsize)
std::vector< double > apply(const std::vector< double > &data) const
void apply_inplace(std::vector< double > &data) const
spacial_kernel_data plugin_data
define the plugin search path, data part
size_t size() const
returns the width of the kernel
kernel_plugin_type plugin_type
define the plugin search path, type part
virtual ~C1DFilterKernel()
int get_fsize() const
returns the filter width definition parameter
Base class for folding kernal types.
iterator begin()
returns an iterator at the begin of the kernel
vec_mask::iterator iterator
kernel iterator
C1DFoldingKernel(int fsize)
std::vector< double > vec_mask
Data type of the kernel coefficient vector.
iterator dbegin()
returns an iterator at the begin if the derivative of the kernel
vec_mask::const_iterator const_iterator
iterator over the kernel
double operator[](int i) const
standard access operator, ro version
double & operator[](int i)
standard access operator, rw version
const_iterator begin() const
returns a constant iterator at the begin of the filter kernel
iterator dend()
returns an iterator at the end if the derivative of the kernel
iterator end()
returns an iterator at the end of the kernel
const_iterator dbegin() const
returns a constant iterator at the begin of the derivative of the filter kernel
const_iterator end() const
returns a constant iterator at the end of the filter kernel
const_iterator dend() const
returns a constant iterator at the end of the derivative of the filter kernel
The base class for all plug-in created object.
Definition: product_base.hh:41
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition: factory.hh:51
the singleton that a plug-in handler really is
Definition: handler.hh:159
static const T & instance()
The basic template of all plugin handlers.
Definition: handler.hh:57
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
#define FACTORY_TRAIT(F)
P1DSpacialKernel produce_spacial_kernel(const std::string &descr)
TFactory< C1DFoldingKernel > C1DSpacialKernelPlugin
base class for filters kernels working in the spacial domain
std::shared_ptr< C1DFoldingKernel > P1DSpacialKernel
THandlerSingleton< TFactoryPluginHandler< C1DSpacialKernelPlugin > > C1DSpacialKernelPluginHandler
plugin handler for spaciel filter kernels
static const char * type_descr
static const char * data_descr