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-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_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 #include <mia/template/combiner.hh>
33 
35 
36 
44 
50 
56 
61 typedef std::shared_ptr<C3DFilter> P3DFilter;
62 
71 typedef std::shared_ptr<C3DImageCombiner> P3DImageCombiner;
73 
77 
78 
83 
84 
93 template <typename S>
94 std::vector<P3DFilter> create_filter_chain(const std::vector<S>& chain)
95 {
96  std::vector<P3DFilter> filters;
97 
98  for (typename std::vector<S>::const_iterator i = chain.begin();
99  i != chain.end(); ++i) {
100  cvdebug() << "Prepare filter " << *i << std::endl;
101  auto filter = C3DFilterPluginHandler::instance().produce(*i);
102  if (!filter){
103  std::stringstream error;
104  error << "Filter " << *i << " not found";
105  throw std::invalid_argument(error.str());
106  }
107  filters.push_back(filter);
108  }
109  return filters;
110 }
111 
117 
118 
122 inline P3DFilter produce_3dimage_filter(const char* descr)
123 {
124  return C3DFilterPluginHandler::instance().produce(descr);
125 }
126 
127 
135 P3DImage EXPORT_3D run_filter(const C3DImage& image, const char *filter);
136 
137 
146 P3DImage EXPORT_3D run_filter_chain(P3DImage image, const std::vector<const char *>& filters);
147 
148 
150 
151 
152 #endif
the singleton that a plug-in handler really is
Definition: handler.hh:157
std::shared_ptr< C3DFilter > P3DFilter
The 3D filter shared pointer.
Definition: 3d/filter.hh:61
CDebugSink & cvdebug()
Definition: msgstream.hh:216
C3DImage::Pointer P3DImage
define a shortcut to the 3D image shared pointer.
Definition: 3d/image.hh:134
THandlerSingleton< TFactoryPluginHandler< C3DImageCombinerPlugin > > C3DImageCombinerPluginHandler
Plugin handler for image combiner plugins.
Definition: 3d/filter.hh:76
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define EXPORT_3D
Definition: defines3d.hh:44
static F::result_type filter(const F &f, const B &b)
Definition: core/filter.hh:250
TDataFilterPlugin< C3DImage > C3DFilterPlugin
The 3D filter plugin type.
Definition: 3d/filter.hh:49
P3DImage EXPORT_3D run_filter(const C3DImage &image, const char *filter)
convenience function: create and run a filter on an image
#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< C3DImageCombiner > C3DImageCombinerPlugin
Definition: 3d/filter.hh:72
The generic base type of a 3D image.
Definition: 3d/image.hh:46
Generic image filter plugin base.
Definition: core/filter.hh:178
TImageCombiner< C3DImage > C3DImageCombiner
Base class for plug-ins that combine two 3D images in certain ways.
Definition: 3d/filter.hh:70
create and use a chain of filters
Definition: filter_chain.hh:40
P3DFilter produce_3dimage_filter(const char *descr)
Definition: 3d/filter.hh:122
std::vector< P3DFilter > create_filter_chain(const std::vector< S > &chain)
Convenience function to create a filter chain from a series of filter descriptions.
Definition: 3d/filter.hh:94
TDataFilter< C3DImage > C3DFilter
Base class for 3D image filters. Filters are implemented as plug-ins.
Definition: 3d/filter.hh:43
static const T & instance()
TFilterChain< C3DFilterPluginHandler > C3DImageFilterChain
3D filter chain to apply various filters in one run
Definition: 3d/filter.hh:116
Generic interface class to data filters.
Definition: core/filter.hh:86
std::shared_ptr< C3DImageCombiner > P3DImageCombiner
Definition: 3d/filter.hh:71
THandlerSingleton< TFactoryPluginHandler< C3DFilterPlugin > > C3DFilterPluginHandler
The 3D filter plugin handler.
Definition: 3d/filter.hh:55
P3DImage EXPORT_3D run_filter_chain(P3DImage image, const std::vector< const char *> &filters)
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36