selxItkSmoothingRecursiveGaussianImageFilterComponent.h 5.47 KB
Newer Older
Floris Berendsen's avatar
Floris Berendsen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*=========================================================================
 *
 *  Copyright Leiden University Medical Center, Erasmus University Medical 
 *  Center and contributors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/

20
21
22
#ifndef selxItkSmoothingRecursiveGaussianImageFilterComponent_h
#define selxItkSmoothingRecursiveGaussianImageFilterComponent_h

23
24
#include "selxComponentBase.h"
#include "selxInterfaces.h"
25
#include "itkSmoothingRecursiveGaussianImageFilter.h"
26
#include "itkImageSource.h"
27
#include <string.h>
28
#include "selxMacro.h"
29
30
namespace selx
{
31
  template <int Dimensionality, class TPixel>
32
  class ItkSmoothingRecursiveGaussianImageFilterComponent : 
33
    public SuperElastixComponent<
34
35
    Accepting< itkImageInterface<Dimensionality, TPixel> >,
    Providing< itkImageInterface<Dimensionality, TPixel> >
36
37
38
    >
  {
  public:
39
    selxNewMacro(ItkSmoothingRecursiveGaussianImageFilterComponent, ComponentBase);
40

FBerendsen's avatar
FBerendsen committed
41
    // itkStaticConstMacro(Dimensionality, unsigned int, Dimensionality);
42

43
44
45
    ItkSmoothingRecursiveGaussianImageFilterComponent();
    virtual ~ItkSmoothingRecursiveGaussianImageFilterComponent();

46
47
    typedef TPixel PixelType;
    typedef itk::SmoothingRecursiveGaussianImageFilter<itk::Image<PixelType, Dimensionality>, itk::Image<PixelType, Dimensionality>> TheItkFilterType;
48
49
    typedef itk::Image<PixelType, Dimensionality> ItkImageType;
    typedef typename ItkImageType::Pointer ItkImagePointer;
50

51
52
    virtual int Set(itkImageInterface<Dimensionality, TPixel>*) override;
    virtual ItkImagePointer GetItkImage() override;
53

54
    //virtual bool MeetsCriteria(const CriteriaType &criteria);
FBerendsen's avatar
FBerendsen committed
55
    virtual bool MeetsCriterion(const ComponentBase::CriterionType &criterion) override;    
56
57
    static const char * GetDescription() { return "ItkSmoothingRecursiveGaussianImageFilter Component"; };
  private:
58
59
60
61
    typename TheItkFilterType::Pointer m_theItkFilter;
  protected:
    /* The following struct returns the string name of computation type */
    /* default implementation */
62

63
64
65
    static inline const std::string GetTypeNameString()
    {
      itkGenericExceptionMacro(<< "Unknown ScalarType" << typeid(TPixel).name());
66
67
68
69
70
71
72
73
      // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
      // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
    }

    static inline const std::string GetPixelTypeNameString()
    {
      itkGenericExceptionMacro(<< "Unknown PixelType" << typeid(TPixel).name());
      // TODO: provide the user instructions how to enable the compilation of the component with the required template types (if desired)
74
75
      // We might define an exception object that can communicate various error messages: for simple user, for developer user, etc
    }
76

77
  };
78

79
80
  // unfortunately partial specialization of member functions is not allowed, without partially specializing the entire class.

81
  /*
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  template <int Dimensionality>
  class ItkSmoothingRecursiveGaussianImageFilterComponent < Dimensionality, double >
  {
    static inline const std::string GetPixelTypeNameString();
  };

  template <int Dimensionality>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<Dimensionality, double>
    ::GetPixelTypeNameString()
  {
    return std::string("double");
  }
  */

  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<2, float>
    ::GetPixelTypeNameString()
  {
    return std::string("float");
  }


  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<2, double>
    ::GetPixelTypeNameString()
  {
    return std::string("double");
  }

  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<3, float>
    ::GetPixelTypeNameString()
  {
    return std::string("float");
  }

  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<3, double>
    ::GetPixelTypeNameString()
  {
    return std::string("double");
  }
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<2, float>
    ::GetTypeNameString()
  {
    return std::string("2_float");
  }

  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<2, double>
    ::GetTypeNameString()
  {
    return std::string("2_double");
  }

  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<3,float>
    ::GetTypeNameString()
  {
    return std::string("3_float");
  }
152
  
153
154
155
156
157
158
159
  template <>
  inline const std::string
    ItkSmoothingRecursiveGaussianImageFilterComponent<3,double>
    ::GetTypeNameString()
  {
    return std::string("3_double");
  }
160
} //end namespace selx
161
162
163
#ifndef ITK_MANUAL_INSTANTIATION
#include "selxItkSmoothingRecursiveGaussianImageFilterComponent.hxx"
#endif
164
#endif // #define GDOptimizer3rdPartyComponent_h