ITK  6.0.0
Insight Toolkit
itkGPUFiniteDifferenceImageFilter.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 itkGPUFiniteDifferenceImageFilter_h
19#define itkGPUFiniteDifferenceImageFilter_h
20
24#include "itkTimeProbe.h"
26
27namespace itk
28{
29
37template <typename TInputImage,
38 typename TOutputImage,
39 typename TParentImageFilter = FiniteDifferenceImageFilter<TInputImage, TOutputImage>>
40class ITK_TEMPLATE_EXPORT GPUFiniteDifferenceImageFilter
41 : public GPUInPlaceImageFilter<TInputImage, TOutputImage, TParentImageFilter>
42{
43public:
44 ITK_DISALLOW_COPY_AND_MOVE(GPUFiniteDifferenceImageFilter);
45
49 using CPUSuperclass = TParentImageFilter;
52
54 itkOverrideGetNameOfClassMacro(GPUFiniteDifferenceImageFilter);
55
57 using InputImageType = TInputImage;
58 using OutputImageType = TOutputImage;
59
61 static constexpr unsigned int ImageDimension = OutputImageType::ImageDimension;
62
64 using OutputPixelType = typename TOutputImage::PixelType;
65 using InputPixelType = typename TInputImage::PixelType;
67
71
79
84 GetDifferenceFunction() const override
85 {
86 return this->m_DifferenceFunction;
87 }
88
92 void
94 {
95 itkDebugMacro("setting m_DifferenceFunction to " << differenceFunction);
96 if (this->m_DifferenceFunction != differenceFunction)
97 {
98 this->m_DifferenceFunction = differenceFunction;
99 this->Modified();
100 }
101 }
104#if !defined(ITK_LEGACY_REMOVE)
106 using FilterStateType = GPUFiniteDifferenceFilterEnum;
107 // We need to expose the enum values at the class level for backwards compatibility
110#endif
111
113 void
115 {
117 }
118
120 void
122 {
124 }
125
127#if !defined(ITK_WRAPPING_PARSER)
128 itkSetMacro(State, GPUFiniteDifferenceFilterEnum);
129 itkGetConstReferenceMacro(State, GPUFiniteDifferenceFilterEnum);
130#endif
133#ifdef ITK_USE_CONCEPT_CHECKING
134 // Begin concept checking
135 itkConceptMacro(OutputPixelIsFloatingPointCheck, (Concept::IsFloatingPoint<OutputPixelValueType>));
136 // End concept checking
137#endif
138
140 itkGetConstReferenceMacro(InitTime, TimeProbe);
141 itkGetConstReferenceMacro(ComputeUpdateTime, TimeProbe);
142 itkGetConstReferenceMacro(ApplyUpdateTime, TimeProbe);
143 itkGetConstReferenceMacro(SmoothFieldTime, TimeProbe);
146protected:
149
150 void
151 PrintSelf(std::ostream & os, Indent indent) const override;
152
154 void
155 AllocateUpdateBuffer() override = 0;
156
160 virtual void
162
168 virtual TimeStepType
170
174 void
175 CopyInputToOutput() override = 0;
176
180 void
181 GPUGenerateData() override;
182
194 void
196
199 bool
200 Halt() override;
201
211 bool
212 ThreadedHalt(void * itkNotUsed(threadInfo)) override
213 {
214 return this->Halt();
215 }
216
222 void
223 Initialize() override
224 {}
225
232 void
234 {
235 m_DifferenceFunction->InitializeIteration();
236 }
237
250 TimeStepType
251 ResolveTimeStep(const std::vector<TimeStepType> & timeStepList, const BooleanStdVectorType & valid) const override;
252
255 void
257 {}
258
260 TimeProbe m_InitTime, m_ComputeUpdateTime, m_ApplyUpdateTime, m_SmoothFieldTime{};
261
262private:
266 void
268
270 typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction{};
271
274 bool m_UseImageSpacing{};
275
278};
279
280} // end namespace itk
281
282#ifndef ITK_MANUAL_INSTANTIATION
283# include "itkGPUFiniteDifferenceImageFilter.hxx"
284#endif
285
286#endif
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType
typename NumericTraits< InputPixelType >::ValueType InputPixelValueType
typename TInputImage::PixelType InputPixelType
typename FiniteDifferenceFunctionType::RadiusType RadiusType
typename TOutputImage::PixelType OutputPixelType
typename NumericTraits< OutputPixelType >::ValueType OutputPixelValueType
Base class for GPU Finite Difference Image Filters.
void SetDifferenceFunction(FiniteDifferenceFunctionType *differenceFunction) override
virtual TimeStepType GPUCalculateChange()=0
const FiniteDifferenceFunctionType::Pointer & GetDifferenceFunction() const override
void GenerateInputRequestedRegion() override
TimeStepType ResolveTimeStep(const std::vector< TimeStepType > &timeStepList, const BooleanStdVectorType &valid) const override
void PrintSelf(std::ostream &os, Indent indent) const override
void AllocateUpdateBuffer() override=0
virtual void GPUApplyUpdate(const TimeStepType &dt)=0
Base class for GPU filters that take an image as input and overwrite that image as the output.
Base class for all process objects that output image data.
TOutputImage OutputImageType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Computes the time passed between two points in code.
Definition: itkTimeProbe.h:45
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
#define itkConceptMacro(name, concept)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
std::vector< Boolean > BooleanStdVectorType