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-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_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(int 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  int 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 
169 
170 
171 inline P1DSpacialKernel produce_spacial_kernel(const std::string& descr)
172 {
173  return C1DSpacialKernelPluginHandler::instance().produce(descr);
174 }
175 
181 class EXPORT_CORE C1DSpacialKernelPluginHandlerTestPath {
182 public:
183  C1DSpacialKernelPluginHandlerTestPath();
184 };
186 
190 
192 
193 #endif