ITK  6.0.0
Insight Toolkit
itkGPUAnisotropicDiffusionFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 <typename TImage>
38 class ITK_TEMPLATE_EXPORT GPUAnisotropicDiffusionFunction : public GPUFiniteDifferenceFunction<TImage>
39 {
40 public:
41  ITK_DISALLOW_COPY_AND_MOVE(GPUAnisotropicDiffusionFunction);
42 
48 
50  itkOverrideGetNameOfClassMacro(GPUAnisotropicDiffusionFunction);
51 
53  using typename Superclass::ImageType;
54  using typename Superclass::PixelType;
56  using typename Superclass::RadiusType;
57  using typename Superclass::NeighborhoodType;
58  using typename Superclass::TimeStepType;
59  using typename Superclass::FloatOffsetType;
60 
62  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
63 
69  virtual void
70  GPUCalculateAverageGradientMagnitudeSquared(ImageType *) = 0;
71 
75  void
77  {
78  m_TimeStep = t;
79  }
80 
81  const TimeStepType &
82  GetTimeStep() const
83  {
84  return m_TimeStep;
85  }
86 
88  void
89  SetConductanceParameter(const double c)
90  {
91  m_ConductanceParameter = c;
92  }
93 
94  const double &
96  {
97  return m_ConductanceParameter;
98  }
99 
101  const double &
103  {
104  return m_AverageGradientMagnitudeSquared;
105  }
106 
107  void
109  {
110  m_AverageGradientMagnitudeSquared = c;
111  }
112 
115  TimeStepType
116  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
117  {
118  return this->GetTimeStep();
119  }
120 
123  void *
124  GetGlobalDataPointer() const override
125  {
126  return nullptr;
127  }
128 
130  void
131  ReleaseGlobalDataPointer(void * itkNotUsed(GlobalData)) const override
132  {
133  /* do nothing */
134  }
135 
136 protected:
138  {
139  m_AverageGradientMagnitudeSquared = 0.0;
140  m_ConductanceParameter = 1.0; // default value
141  m_TimeStep = 0.125f; // default value
142  }
143 
144  ~GPUAnisotropicDiffusionFunction() override = default;
145 
146  void
147  PrintSelf(std::ostream & os, Indent indent) const override
148  {
149  Superclass::PrintSelf(os, indent);
150  os << indent << "TimeStep: " << m_TimeStep << std::endl;
151  os << indent << "ConductanceParameter: " << m_ConductanceParameter << std::endl;
152  }
153 
154  // GPU buffer for Computing Average Squared Gradient Magnitude
155  typename GPUDataManager::Pointer m_AnisotropicDiffusionFunctionGPUBuffer{};
156  typename GPUKernelManager::Pointer m_AnisotropicDiffusionFunctionGPUKernelManager{};
157 
158  // GPU Kernel Handles
159  int m_AverageGradientMagnitudeSquaredGPUKernelHandle{};
160 
161 private:
162  double m_AverageGradientMagnitudeSquared{};
163  double m_ConductanceParameter{};
164  TimeStepType m_TimeStep{};
165 };
166 } // end namespace itk
167 
168 #endif
itk::GPUAnisotropicDiffusionFunction::SetTimeStep
void SetTimeStep(const TimeStepType &t)
Definition: itkGPUAnisotropicDiffusionFunction.h:76
itk::GPUAnisotropicDiffusionFunction::GetAverageGradientMagnitudeSquared
const double & GetAverageGradientMagnitudeSquared() const
Definition: itkGPUAnisotropicDiffusionFunction.h:102
itk::GPUAnisotropicDiffusionFunction::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkGPUAnisotropicDiffusionFunction.h:147
itk::FiniteDifferenceFunction< TImage >::RadiusType
typename ConstNeighborhoodIterator< TImage >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::GPUAnisotropicDiffusionFunction::PixelrealType
typename Superclass::PixelRealType PixelrealType
Definition: itkGPUAnisotropicDiffusionFunction.h:55
itkGPUFiniteDifferenceFunction.h
itk::GPUAnisotropicDiffusionFunction
Definition: itkGPUAnisotropicDiffusionFunction.h:38
itk::GPUAnisotropicDiffusionFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkGPUAnisotropicDiffusionFunction.h:116
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::FiniteDifferenceFunction< TImage >::PixelRealType
double PixelRealType
Definition: itkFiniteDifferenceFunction.h:84
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GPUAnisotropicDiffusionFunction::SetAverageGradientMagnitudeSquared
void SetAverageGradientMagnitudeSquared(const double c)
Definition: itkGPUAnisotropicDiffusionFunction.h:108
itk::FiniteDifferenceFunction< TImage >::ImageType
TImage ImageType
Definition: itkFiniteDifferenceFunction.h:82
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::GPUAnisotropicDiffusionFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkGPUAnisotropicDiffusionFunction.h:124
itk::GPUAnisotropicDiffusionFunction::GetTimeStep
const TimeStepType & GetTimeStep() const
Definition: itkGPUAnisotropicDiffusionFunction.h:82
itk::GPUFiniteDifferenceFunction
Definition: itkGPUFiniteDifferenceFunction.h:47
itk::FiniteDifferenceFunction< TImage >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::GPUAnisotropicDiffusionFunction::GetConductanceParameter
const double & GetConductanceParameter() const
Definition: itkGPUAnisotropicDiffusionFunction.h:95
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::GPUAnisotropicDiffusionFunction::GPUAnisotropicDiffusionFunction
GPUAnisotropicDiffusionFunction()
Definition: itkGPUAnisotropicDiffusionFunction.h:137
itk::GPUAnisotropicDiffusionFunction::SetConductanceParameter
void SetConductanceParameter(const double c)
Definition: itkGPUAnisotropicDiffusionFunction.h:89
itk::GPUAnisotropicDiffusionFunction::ReleaseGlobalDataPointer
void ReleaseGlobalDataPointer(void *) const override
Definition: itkGPUAnisotropicDiffusionFunction.h:131
itk::FiniteDifferenceFunction< TImage >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90