ITK  6.0.0
Insight Toolkit
itkFiniteDifferenceImageFilter.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 itkFiniteDifferenceImageFilter_h
19 #define itkFiniteDifferenceImageFilter_h
20 
21 #include "itkBooleanStdVector.h"
22 #include "itkInPlaceImageFilter.h"
24 
25 namespace itk
26 {
132 template <typename TInputImage, typename TOutputImage>
133 class ITK_TEMPLATE_EXPORT FiniteDifferenceImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
134 {
135 public:
136  ITK_DISALLOW_COPY_AND_MOVE(FiniteDifferenceImageFilter);
137 
143 
145  itkOverrideGetNameOfClassMacro(FiniteDifferenceImageFilter);
146 
148  using InputImageType = TInputImage;
149  using OutputImageType = TOutputImage;
150 
152  static constexpr unsigned int ImageDimension = OutputImageType::ImageDimension;
153 
155  using OutputPixelType = typename TOutputImage::PixelType;
156  using InputPixelType = typename TInputImage::PixelType;
158 
162 
168 
171 
173  itkGetConstReferenceMacro(ElapsedIterations, IdentifierType);
174 
178  itkGetConstReferenceObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType);
179 
183  itkSetObjectMacro(DifferenceFunction, FiniteDifferenceFunctionType);
184 
186  itkSetMacro(NumberOfIterations, IdentifierType);
187  itkGetConstReferenceMacro(NumberOfIterations, IdentifierType);
192  itkSetMacro(UseImageSpacing, bool);
193  itkBooleanMacro(UseImageSpacing);
194  itkGetConstReferenceMacro(UseImageSpacing, bool);
199  itkSetMacro(MaximumRMSError, double);
200  itkGetConstReferenceMacro(MaximumRMSError, double);
205  itkSetMacro(RMSChange, double);
206  itkGetConstReferenceMacro(RMSChange, double);
211  itkSetMacro(ManualReinitialization, bool);
212  itkGetConstReferenceMacro(ManualReinitialization, bool);
213  itkBooleanMacro(ManualReinitialization);
216  itkSetMacro(IsInitialized, bool);
217  itkGetMacro(IsInitialized, bool);
218 
219  void
221  {
222  this->SetIsInitialized(false);
223  }
224  void
226  {
227  this->SetIsInitialized(true);
228  }
229 
230 #ifdef ITK_USE_CONCEPT_CHECKING
231  // Begin concept checking
232  itkConceptMacro(OutputPixelIsFloatingPointCheck, (Concept::IsFloatingPoint<OutputPixelValueType>));
233  // End concept checking
234 #endif
235 
236 protected:
238  ~FiniteDifferenceImageFilter() override = default;
239 
241  bool m_IsInitialized{};
242 
243  void
244  PrintSelf(std::ostream & os, Indent indent) const override;
245 
247  virtual void
248  AllocateUpdateBuffer() = 0;
249 
253  virtual void
254  ApplyUpdate(const TimeStepType & dt) = 0;
255 
261  virtual TimeStepType
262  CalculateChange() = 0;
263 
267  virtual void
268  CopyInputToOutput() = 0;
269 
273  void
274  GenerateData() override;
275 
287  void
288  GenerateInputRequestedRegion() override;
289 
292  virtual bool
293  Halt();
294 
304  virtual bool
305  ThreadedHalt(void * itkNotUsed(threadInfo))
306  {
307  return this->Halt();
308  }
309 
315  virtual void
317  {}
318 
325  virtual void
327  {
328  m_DifferenceFunction->InitializeIteration();
329  }
330 
343  virtual TimeStepType
344  ResolveTimeStep(const std::vector<TimeStepType> & timeStepList, const BooleanStdVectorType & valid) const;
345 
347  itkSetMacro(ElapsedIterations, IdentifierType);
348 
351  virtual void
353  {}
354 
356  IdentifierType m_NumberOfIterations{};
357 
360  IdentifierType m_ElapsedIterations{};
361 
364  bool m_ManualReinitialization{};
365 
366  double m_RMSChange{};
367  double m_MaximumRMSError{};
368 
369 private:
373  void
374  InitializeFunctionCoefficients();
375 
378  bool m_UseImageSpacing{ true };
379 
381  typename FiniteDifferenceFunctionType::Pointer m_DifferenceFunction{};
382 };
383 } // end namespace itk
384 
385 #ifndef ITK_MANUAL_INSTANTIATION
386 # include "itkFiniteDifferenceImageFilter.hxx"
387 #endif
388 
389 #endif
itk::FiniteDifferenceImageFilter::PostProcessOutput
virtual void PostProcessOutput()
Definition: itkFiniteDifferenceImageFilter.h:352
itk::FiniteDifferenceImageFilter::InitializeIteration
virtual void InitializeIteration()
Definition: itkFiniteDifferenceImageFilter.h:326
itk::FiniteDifferenceFunction::RadiusType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::FiniteDifferenceImageFilter::SetStateToInitialized
void SetStateToInitialized()
Definition: itkFiniteDifferenceImageFilter.h:225
itkBooleanStdVector.h
itk::BooleanStdVectorType
std::vector< Boolean > BooleanStdVectorType
Definition: itkBooleanStdVector.h:34
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::TimeStepType
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
Definition: itkFiniteDifferenceImageFilter.h:167
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::InputPixelValueType
typename NumericTraits< InputPixelType >::ValueType InputPixelValueType
Definition: itkFiniteDifferenceImageFilter.h:161
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkFiniteDifferenceFunction.h
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::NeighborhoodScalesType
typename FiniteDifferenceFunctionType::NeighborhoodScalesType NeighborhoodScalesType
Definition: itkFiniteDifferenceImageFilter.h:170
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::RadiusType
typename FiniteDifferenceFunctionType::RadiusType RadiusType
Definition: itkFiniteDifferenceImageFilter.h:169
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::OutputPixelValueType
typename NumericTraits< OutputPixelType >::ValueType OutputPixelValueType
Definition: itkFiniteDifferenceImageFilter.h:160
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::OutputPixelType
typename TSparseOutputImageType ::PixelType OutputPixelType
Definition: itkFiniteDifferenceImageFilter.h:155
itk::FiniteDifferenceImageFilter::Initialize
virtual void Initialize()
Definition: itkFiniteDifferenceImageFilter.h:316
itk::Concept::IsFloatingPoint
Definition: itkConceptChecking.h:953
itk::FiniteDifferenceImageFilter::ThreadedHalt
virtual bool ThreadedHalt(void *)
Definition: itkFiniteDifferenceImageFilter.h:305
itk::ImageToImageFilter< TInputImageType, TSparseOutputImageType >::InputImageType
TInputImageType InputImageType
Definition: itkImageToImageFilter.h:129
itk::FiniteDifferenceImageFilter
Definition: itkFiniteDifferenceImageFilter.h:133
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::PixelType
OutputPixelType PixelType
Definition: itkFiniteDifferenceImageFilter.h:157
itk::FiniteDifferenceImageFilter::SetStateToUninitialized
void SetStateToUninitialized()
Definition: itkFiniteDifferenceImageFilter.h:220
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkInPlaceImageFilter.h
itk::FiniteDifferenceFunction
Definition: itkFiniteDifferenceFunction.h:66
itk::FiniteDifferenceImageFilter< TInputImageType, TSparseOutputImageType >::InputPixelType
typename TInputImageType ::PixelType InputPixelType
Definition: itkFiniteDifferenceImageFilter.h:156
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::ImageSource< TSparseOutputImageType >::OutputImageType
TSparseOutputImageType OutputImageType
Definition: itkImageSource.h:90
itk::FiniteDifferenceFunction::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90