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  itkOverrideGetNameOfClassMacro(TotalVariationImageFilter);
66 
68  using InputImagePointer = typename TInputImage::Pointer;
69 
70  using RegionType = typename TInputImage::RegionType;
71  using SizeType = typename TInputImage::SizeType;
72  using IndexType = typename TInputImage::IndexType;
73  using PixelType = typename TInputImage::PixelType;
74 
76  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
77 
80 
83 
86  // using PixelObjectType = SimpleDataObjectDecorator< PixelType >;
87 
89  RealType
91  {
92  return this->GetTotalVariationOutput()->Get();
93  }
94  RealObjectType *
95  GetTotalVariationOutput();
97 
98  const RealObjectType *
99  GetTotalVariationOutput() const;
100 
104  using Superclass::MakeOutput;
106  MakeOutput(DataObjectPointerArraySizeType output) override;
107 
108  // Begin concept checking
109  itkConceptMacro(InputHasNumericTraitsCheck, (itk::Concept::HasNumericTraits<PixelType>));
110  // End concept checking
111 
114  void
116  {
117  this->SetUseImageSpacing(true);
118  }
119 
122  void
124  {
125  this->SetUseImageSpacing(false);
126  }
127 
130  itkSetMacro(UseImageSpacing, bool);
131  itkGetConstMacro(UseImageSpacing, bool);
133 
134 protected:
136  ~TotalVariationImageFilter() override = default;
137  void
138  PrintSelf(std::ostream & os, itk::Indent indent) const override;
139 
143  void
144  AllocateOutputs() override;
145 
147  void
148  BeforeThreadedGenerateData() override;
149 
152  void
153  AfterThreadedGenerateData() override;
154 
156  void
157  ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override;
158 
159  // Override since the filter needs all the data for the algorithm
160  void
161  GenerateInputRequestedRegion() override;
162 
163  // Override since the filter produces all of its output
164  void
165  EnlargeOutputRequestedRegion(itk::DataObject * data) override;
166 
168 
169 private:
171 }; // end of class
172 } // end namespace rtk
173 
174 #ifndef ITK_MANUAL_INSTANTIATION
175 # include "rtkTotalVariationImageFilter.hxx"
176 #endif
177 
178 #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