RTK  2.6.0
Reconstruction Toolkit
rtkTotalVariationImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK 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  * 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 
19 #ifndef rtkTotalVariationImageFilter_h
20 #define rtkTotalVariationImageFilter_h
21 
22 #include <itkImageToImageFilter.h>
23 #include <itkNumericTraits.h>
24 #include <itkArray.h>
26 
27 #include "rtkMacro.h"
28 
29 namespace rtk
30 {
49 template <typename TInputImage>
50 class ITK_TEMPLATE_EXPORT TotalVariationImageFilter : public itk::ImageToImageFilter<TInputImage, TInputImage>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(TotalVariationImageFilter);
54 
60 
62  itkNewMacro(Self);
63 
65 #ifdef itkOverrideGetNameOfClassMacro
66  itkOverrideGetNameOfClassMacro(TotalVariationImageFilter);
67 #else
69 #endif
70 
71 
73  using InputImagePointer = typename TInputImage::Pointer;
74 
75  using RegionType = typename TInputImage::RegionType;
76  using SizeType = typename TInputImage::SizeType;
77  using IndexType = typename TInputImage::IndexType;
78  using PixelType = typename TInputImage::PixelType;
79 
81  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
82 
85 
88 
91  // using PixelObjectType = SimpleDataObjectDecorator< PixelType >;
92 
94  RealType
96  {
97  return this->GetTotalVariationOutput()->Get();
98  }
99  RealObjectType *
100  GetTotalVariationOutput();
102 
103  const RealObjectType *
104  GetTotalVariationOutput() const;
105 
109  using Superclass::MakeOutput;
111  MakeOutput(DataObjectPointerArraySizeType output) override;
112 
113 #ifdef ITK_USE_CONCEPT_CHECKING
114  // Begin concept checking
115  itkConceptMacro(InputHasNumericTraitsCheck, (itk::Concept::HasNumericTraits<PixelType>));
116  // End concept checking
117 #endif
118 
121  void
123  {
124  this->SetUseImageSpacing(true);
125  }
126 
129  void
131  {
132  this->SetUseImageSpacing(false);
133  }
134 
137  itkSetMacro(UseImageSpacing, bool);
138  itkGetConstMacro(UseImageSpacing, bool);
140 
141 protected:
143  ~TotalVariationImageFilter() override = default;
144  void
145  PrintSelf(std::ostream & os, itk::Indent indent) const override;
146 
150  void
151  AllocateOutputs() override;
152 
154  void
155  BeforeThreadedGenerateData() override;
156 
159  void
160  AfterThreadedGenerateData() override;
161 
163  void
164  ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override;
165 
166  // Override since the filter needs all the data for the algorithm
167  void
168  GenerateInputRequestedRegion() override;
169 
170  // Override since the filter produces all of its output
171  void
172  EnlargeOutputRequestedRegion(itk::DataObject * data) override;
173 
175 
176 private:
178 }; // end of class
179 } // end namespace rtk
180 
181 #ifndef ITK_MANUAL_INSTANTIATION
182 # include "rtkTotalVariationImageFilter.hxx"
183 #endif
184 
185 #endif
typename TInputImage::RegionType RegionType
typename itk::NumericTraits< PixelType >::RealType RealType
SmartPointer< Self > Pointer
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
typename TInputImage::IndexType IndexType
Compute the total variation of an Image.
#define itkSetMacro(name, type)
typename TInputImage::SizeType SizeType
unsigned int ThreadIdType
typename TInputImage::Pointer InputImagePointer
#define itkConceptMacro(name, concept)
typename TInputImage::PixelType PixelType