3d/filter.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_3d_filter_hh
22 #define mia_3d_filter_hh
23 
24 #include <boost/any.hpp>
25 
26 #include <mia/3d/image.hh>
27 #include <mia/core/combiner.hh>
28 #include <mia/core/factory.hh>
29 #include <mia/core/filter.hh>
32 
34 
35 
43 
49 
55 
60 typedef std::shared_ptr<C3DFilter> P3DFilter;
61 
69 class EXPORT_3D C3DImageCombiner : public TFilter< PCombinerResult >, public CProductBase {
70 public:
72  typedef combiner_type plugin_type;
73 
74  virtual ~C3DImageCombiner();
78  result_type combine( const C3DImage& a, const C3DImage& b) const;
79 private:
80  virtual result_type do_combine( const C3DImage& a, const C3DImage& b) const = 0;
81 };
82 
84 typedef std::shared_ptr<C3DImageCombiner > P3DImageCombiner;
86 
87 
93 class EXPORT_3D C3DFilterPluginHandlerTestPath {
94 public:
95  C3DFilterPluginHandlerTestPath();
96 private:
97  C1DSpacialKernelPluginHandlerTestPath spk_path;
98 };
100 
101 
102 
103 
104 
105 
110 
111 
120 template <typename S>
121 std::vector<P3DFilter> create_filter_chain(const std::vector<S>& chain)
122 {
123  std::vector<P3DFilter> filters;
124 
125  for (typename std::vector<S>::const_iterator i = chain.begin();
126  i != chain.end(); ++i) {
127  cvdebug() << "Prepare filter " << *i << std::endl;
128  auto filter = C3DFilterPluginHandler::instance().produce(*i);
129  if (!filter){
130  std::stringstream error;
131  error << "Filter " << *i << " not found";
132  throw std::invalid_argument(error.str());
133  }
134  filters.push_back(filter);
135  }
136  return filters;
137 }
138 
144 
145 
149 inline P3DFilter produce_3dimage_filter(const char* descr)
150 {
151  return C3DFilterPluginHandler::instance().produce(descr);
152 }
153 
154 
162 P3DImage EXPORT_3D run_filter(const C3DImage& image, const char *filter);
163 
164 
173 P3DImage EXPORT_3D run_filter_chain(P3DImage image, const std::vector<const char *>& filters);
174 
175 
177 
178 
179 #endif