aimsalgo 6.0.0
Neuroimaging image processing
filteringfunction_element.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34
35#ifndef AIMS_SIGNALFILTER_FILTERINGFUNCTION_ELEMENT_H
36#define AIMS_SIGNALFILTER_FILTERINGFUNCTION_ELEMENT_H
37
38//--- aims -------------------------------------------------------------------
39#include <aims/signalfilter/filteringfunction.h> // aims::FilteringFunction
40//--- std --------------------------------------------------------------------
41#include <set>
42#include <string>
43#include <map>
44//--- forward declarations ---------------------------------------------------
45namespace carto {
46 template <typename T> class VolumeRef;
47 template <typename T> class rc_ptr;
48 class Object;
49 Object none();
50}
51namespace aims {
53}
54//----------------------------------------------------------------------------
55
56namespace aims {
57
58 //==========================================================================
59 // ELEMENT FILTERING FUNCTON
60 //==========================================================================
64 template <typename T>
66 {
67 public:
69 //----------------------------------------------------------------------
70 // interface
71 //----------------------------------------------------------------------
74 virtual T execute( const carto::VolumeRef<T> & in,
75 const carto::rc_ptr<StructuringElement> & se ) const = 0;
78 virtual T execute( const carto::VolumeRef<T> & in ) const = 0;
80 virtual ElementFilteringFunction<T> *clone() const = 0;
81
82 protected:
83 //----------------------------------------------------------------------
84 // magic 3
85 //----------------------------------------------------------------------
89 };
90
91 //==========================================================================
92 // ELEMENT FILTERING FUNCTIONS: FACTORY
93 //==========================================================================
95 template <typename T>
97 {
98 public:
101 static ElementFilteringFunction<T> * create( const std::string & name,
102 carto::Object options = carto::none() );
104 static void registerFunction( const std::string & name,
105 const ElementFilteringFunction<T> & func );
107 static std::set<std::string> names();
108 protected:
109 static void init();
110 static std::map<std::string,carto::rc_ptr<ElementFilteringFunction<T> > > & _map();
111 };
112
113} // namespace aims
114
115
116//============================================================================
117// ELEMENT FILTERING FUNCTIONS: DERIVED CLASSES
118//============================================================================
119
120#define AIMS_DECLARE_ELEMENTFILTERFUNC_CUSTOMIZED( NAME ) \
121 template <typename T> \
122 class NAME: public ElementFilteringFunction<T> \
123 { \
124 public: \
125 NAME( carto::Object options = carto::none() ) \
126 { setOptions( options ); } \
127 NAME( const NAME<T> & other ); \
128 virtual ~NAME(); \
129 NAME<T> & operator=( const NAME<T> & other ); \
130 virtual NAME<T> *clone() const { return new NAME<T>(*this); } \
131 virtual void setOptions( const carto::Object & options ); \
132 virtual T execute( const carto::VolumeRef<T> & in ) const; \
133 virtual T execute( const carto::VolumeRef<T> & in, \
134 const carto::rc_ptr<StructuringElement> & se ) const;
135
136#define AIMS_DEFINE_ELEMENTFILTERFUNC_BASIC( NAME ) \
137 template <typename T> \
138 NAME<T>::NAME( const NAME<T> & /*other*/ ) : ElementFilteringFunction<T>() {} \
139 template <typename T> \
140 NAME<T>::~NAME() {} \
141 template <typename T> \
142 NAME<T> & NAME<T>::operator=( const NAME<T> & /*other*/ ) { return *this; } \
143 template <typename T> \
144 void NAME<T>::setOptions( const carto::Object & /*options*/ ) {}
145
146#define AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC( NAME ) \
147 AIMS_DECLARE_ELEMENTFILTERFUNC_CUSTOMIZED(NAME) \
148 }; \
149 AIMS_DEFINE_ELEMENTFILTERFUNC_BASIC(NAME)
150
151
152namespace aims {
155 AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(MajorityFilterFunc)
156 AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(ExtremaDifferenceFilterFunc)
162 AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(NotNullMeanFilterFunc)
163 AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(NotNullMedianFilterFunc)
164 AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(NotNullMajorityFilterFunc)
165} // namespace aims
166
167#endif
Associates a string with a ElementFilteringFunction.
static std::set< std::string > names()
List all function ids registered in the factory.
static std::map< std::string, carto::rc_ptr< ElementFilteringFunction< T > > > & _map()
static ElementFilteringFunction< T > * create(const std::string &name, carto::Object options=carto::none())
Build and return the ElementFilteringFunction associated with the id name.
static void registerFunction(const std::string &name, const ElementFilteringFunction< T > &func)
Register a ElementFilterigFunction into the factory.
Base class for filtering functions applied in a structuring element.
ElementFilteringFunction< T > & operator=(const ElementFilteringFunction< T > &)
virtual ElementFilteringFunction< T > * clone() const =0
clone
virtual T execute(const carto::VolumeRef< T > &in) const =0
virtual T execute(const carto::VolumeRef< T > &in, const carto::rc_ptr< StructuringElement > &se) const =0
ElementFilteringFunction(const ElementFilteringFunction< T > &)
#define AIMS_DECLARE_ELEMENTFILTERFUNC_BASIC(NAME)
Object none()