3d/filter.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef mia_3d_filter_hh
#define mia_3d_filter_hh
#include <boost/any.hpp>
#include <mia/3d/image.hh>
#include <mia/core/combiner.hh>
#include <mia/core/factory.hh>
#include <mia/core/filter.hh>
#include <mia/core/spacial_kernel.hh>
#include <mia/template/filter_chain.hh>
#include <mia/template/combiner.hh>
NS_MIA_BEGIN
typedef TDataFilter<C3DImage> C3DFilter;
typedef TDataFilterPlugin<C3DImage> C3DFilterPlugin;
typedef THandlerSingleton<TFactoryPluginHandler<C3DFilterPlugin>> C3DFilterPluginHandler;
typedef std::shared_ptr<C3DFilter> P3DFilter;
typedef TImageCombiner< C3DImage > C3DImageCombiner;
typedef std::shared_ptr<C3DImageCombiner> P3DImageCombiner;
typedef TFactory<C3DImageCombiner> C3DImageCombinerPlugin;
typedef THandlerSingleton<TFactoryPluginHandler<C3DImageCombinerPlugin>>
C3DImageCombinerPluginHandler;
FACTORY_TRAIT(C3DFilterPluginHandler);
FACTORY_TRAIT(C3DImageCombinerPluginHandler);
template <typename S>
std::vector<P3DFilter> create_filter_chain(const std::vector<S>& chain)
{
std::vector<P3DFilter> filters;
for (typename std::vector<S>::const_iterator i = chain.begin();
i != chain.end(); ++i) {
cvdebug() << "Prepare filter " << *i << std::endl;
auto filter = C3DFilterPluginHandler::instance().produce(*i);
if (!filter) {
std::stringstream error;
error << "Filter " << *i << " not found";
throw std::invalid_argument(error.str());
}
filters.push_back(filter);
}
return filters;
}
typedef TFilterChain<C3DFilterPluginHandler> C3DImageFilterChain;
inline P3DFilter produce_3dimage_filter(const char *descr)
{
return C3DFilterPluginHandler::instance().produce(descr);
}
P3DImage EXPORT_3D run_filter(const C3DImage& image, const char *filter);
P3DImage EXPORT_3D run_filter_chain(P3DImage image, const std::vector<const char *>& filters);
NS_MIA_END
#endif
C3DImageCombinerPlugin
TFactory< C3DImageCombiner > C3DImageCombinerPlugin
Definition 3d/filter.hh:72
produce_3dimage_filter
P3DFilter produce_3dimage_filter(const char *descr)
Definition 3d/filter.hh:125
P3DImageCombiner
std::shared_ptr< C3DImageCombiner > P3DImageCombiner
Definition 3d/filter.hh:71
C3DImageCombinerPluginHandler
THandlerSingleton< TFactoryPluginHandler< C3DImageCombinerPlugin > > C3DImageCombinerPluginHandler
Plugin handler for image combiner plugins.
Definition 3d/filter.hh:76
image.hh
P3DImage
C3DImage::Pointer P3DImage
define a shortcut to the 3D image shared pointer.
Definition 3d/image.hh:135
C3DImage
The generic base type of a 3D image.
Definition 3d/image.hh:47
TDataFilterPlugin
Generic image filter plugin base.
Definition core/filter.hh:186
TDataFilter
Generic interface class to data filters.
Definition core/filter.hh:87
TFactory
This is tha base of all plugins that create "things", like filters, cost functions time step operator...
Definition factory.hh:51
TFilterChain
create and use a chain of filters
Definition filter_chain.hh:41
THandlerSingleton
the singleton that a plug-in handler really is
Definition handler.hh:159
THandlerSingleton< TFactoryPluginHandler< C3DFilterPlugin > >::instance
static const TFactoryPluginHandler< C3DFilterPlugin > & instance()
TImageCombiner< C3DImage >
combiner.hh
filter.hh
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
factory.hh
filter_chain.hh
C3DFilterPluginHandler
THandlerSingleton< TFactoryPluginHandler< C3DFilterPlugin > > C3DFilterPluginHandler
The 3D filter plugin handler.
Definition 3d/filter.hh:55
C3DFilterPlugin
TDataFilterPlugin< C3DImage > C3DFilterPlugin
The 3D filter plugin type.
Definition 3d/filter.hh:49
C3DImageFilterChain
TFilterChain< C3DFilterPluginHandler > C3DImageFilterChain
3D filter chain to apply various filters in one run
Definition 3d/filter.hh:119
run_filter
P3DImage EXPORT_3D run_filter(const C3DImage &image, const char *filter)
convenience function: create and run a filter on an image
C3DImageCombiner
TImageCombiner< C3DImage > C3DImageCombiner
Base class for plug-ins that combine two 3D images in certain ways.
Definition 3d/filter.hh:70
filter
static F::result_type filter(const F &f, const B &b)
Definition core/filter.hh:258
C3DFilter
TDataFilter< C3DImage > C3DFilter
Base class for 3D image filters. Filters are implemented as plug-ins.
Definition 3d/filter.hh:43
create_filter_chain
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
P3DFilter
std::shared_ptr< C3DFilter > P3DFilter
The 3D filter shared pointer.
Definition 3d/filter.hh:61
run_filter_chain
P3DImage EXPORT_3D run_filter_chain(P3DImage image, const std::vector< const char * > &filters)
FACTORY_TRAIT
#define FACTORY_TRAIT(F)
Definition factory_trait.hh:69
cvdebug
CDebugSink & cvdebug()
Definition msgstream.hh:226
spacial_kernel.hh
combiner.hh