ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkGPUAnisotropicDiffusionFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkGPUAnisotropicDiffusionFunction_h
19 #define __itkGPUAnisotropicDiffusionFunction_h
20 
22 
23 namespace itk
24 {
37 template< class TImage >
39  public GPUFiniteDifferenceFunction< TImage >
40 {
41 public:
42 
48 
51 
53  typedef typename Superclass::ImageType ImageType;
54  typedef typename Superclass::PixelType PixelType;
60 
62  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
63 
69  virtual void GPUCalculateAverageGradientMagnitudeSquared(ImageType *) = 0;
70 
74  void SetTimeStep(const TimeStepType & t)
75  {
76  m_TimeStep = t;
77  }
78 
79  const TimeStepType & GetTimeStep() const
80  {
81  return m_TimeStep;
82  }
83 
85  void SetConductanceParameter(const double & c)
86  {
87  m_ConductanceParameter = c;
88  }
89 
90  const double & GetConductanceParameter() const
91  {
92  return m_ConductanceParameter;
93  }
94 
96  const double & GetAverageGradientMagnitudeSquared() const
97  {
98  return m_AverageGradientMagnitudeSquared;
99  }
100 
101  void SetAverageGradientMagnitudeSquared(const double & c)
102  {
103  m_AverageGradientMagnitudeSquared = c;
104  }
105 
108  virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) const
109  {
110  return this->GetTimeStep();
111  }
112 
115  virtual void * GetGlobalDataPointer() const
116  {
117  return 0;
118  }
119 
121  virtual void ReleaseGlobalDataPointer( void *itkNotUsed(GlobalData) ) const
122  {
123  /* do nothing */
124  }
125 
126 protected:
128  {
129  m_AverageGradientMagnitudeSquared = 0.0;
130  m_ConductanceParameter = 1.0; // default value
131  m_TimeStep = 0.125f; // default value
132  }
133 
135  }
136 
137  void PrintSelf(std::ostream & os, Indent indent) const
138  {
139  Superclass::PrintSelf(os, indent);
140  os << indent << "TimeStep: " << m_TimeStep << std::endl;
141  os << indent << "ConductanceParameter: " << m_ConductanceParameter
142  << std::endl;
143  }
144 
145  // GPU buffer for Computing Average Squared Gradient Magnitude
148 
149  // GPU Kernel Handles
151 private:
152  GPUAnisotropicDiffusionFunction(const Self &); //purposely not implemented
153  void operator=(const Self &); //purposely not implemented
154 
158 };
159 } // end namespace itk
160 
161 #endif
162