RTK  2.4.1
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 
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 #ifdef ITK_USE_CONCEPT_CHECKING
109  // Begin concept checking
110  itkConceptMacro(InputHasNumericTraitsCheck, (itk::Concept::HasNumericTraits<PixelType>));
111  // End concept checking
112 #endif
113 
116  void
118  {
119  this->SetUseImageSpacing(true);
120  }
121 
124  void
126  {
127  this->SetUseImageSpacing(false);
128  }
129 
132  itkSetMacro(UseImageSpacing, bool);
133  itkGetConstMacro(UseImageSpacing, bool);
135 
136 protected:
138  ~TotalVariationImageFilter() override = default;
139  void
140  PrintSelf(std::ostream & os, itk::Indent indent) const override;
141 
145  void
146  AllocateOutputs() override;
147 
149  void
150  BeforeThreadedGenerateData() override;
151 
154  void
155  AfterThreadedGenerateData() override;
156 
158  void
159  ThreadedGenerateData(const RegionType & outputRegionForThread, itk::ThreadIdType threadId) override;
160 
161  // Override since the filter needs all the data for the algorithm
162  void
163  GenerateInputRequestedRegion() override;
164 
165  // Override since the filter produces all of its output
166  void
167  EnlargeOutputRequestedRegion(itk::DataObject * data) override;
168 
170 
171 private:
173 }; // end of class
174 } // end namespace rtk
175 
176 #ifndef ITK_MANUAL_INSTANTIATION
177 # include "rtkTotalVariationImageFilter.hxx"
178 #endif
179 
180 #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