File: simple.hh

package info (click to toggle)
mia 2.4.7-18
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,488 kB
  • sloc: cpp: 162,684; python: 1,322; sh: 321; xml: 127; makefile: 42; csh: 24; ansic: 9
file content (93 lines) | stat: -rw-r--r-- 3,369 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* -*- mia-c++  -*-
 *
 * This file is part of MIA - a toolbox for medical image analysis
 * Copyright (c) Leipzig, Madrid 1999-2016 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/>.
 *
 */

#include <mia/2d/filter.hh>


/*
   Each plug-in should provide its own namespace to avoid possible name clashes
   when more then one plug-ins are loaded.

*/
NS_BEGIN(simple_2dimage_filter)


/*
   The actual 2D filter is a derivative of the C2DFilter class which is a model of TImageFilter.
   Note, that these class names are not visible outside of this plug-in code, so there is really no need
   to give very expressive names.
*/

class C2DSimple: public mia::C2DFilter
{
public:
       /*
          The constructor takes all the necessary parameters. Usually this means that after construction, the
          filter does not change anymore. As an exception to this rule, a data key may be provided that makes
          it possible to load data from the internal memory that was created after construction of the filter.
          This may be the case when specifying a long pipeline of filters.
        */

       C2DSimple(double a);


       /*
          This templated operator does the actual work of the filter. The operator must support all pixel types
          that are currently provided by MIA. If some input pixel type is nor supported, e.g. because the filter
          just doesn't define an operation on the pixel type, then you should use (partial) template specialization
          to dispatch the work based on the pixel type, and if an image with an unsupported type is provided as input then
          an exception should be thrown.
          Thr result type is a P2Dimage.
        */
       template <typename T>
       C2DSimple::result_type operator () (const mia::T2DImage<T>& data) const;
private:
       /*
          This method implements always the same code - redirect to dispatching the call
          based on input pixel type.
        */
       virtual mia::P2DImage do_filter(const mia::C2DImage& image) const;

       /*
          This is the actual parameter of the 'simple' filter
        */
       double m_a;
};


/*
  This class provides the actual plug-in interface that is used to create the filter. It also provides some
  information about the filter to be used in the help system.
*/
class C2DSimpleImageFilterPlugin: public mia::C2DFilterPlugin
{
public:
       C2DSimpleImageFilterPlugin();
       virtual mia::C2DFilter *do_create()const;
       virtual const std::string do_get_descr()const;
private:
       /*
         This is a duplicate of the  parameter of the 'simple' filter used when parsing the plug-in
         description and creaing the actual filter - the product of the plug-in.
       */
       double m_a;
};

NS_END