RTK  2.0.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  * http://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 >
51  public itk::ImageToImageFilter< TInputImage, TInputImage >
52 {
53 public:
54  ITK_DISALLOW_COPY_AND_ASSIGN(TotalVariationImageFilter);
55 
61 
63  itkNewMacro(Self);
64 
67 
69  using InputImagePointer = typename TInputImage::Pointer;
70 
71  using RegionType = typename TInputImage::RegionType;
72  using SizeType = typename TInputImage::SizeType;
73  using IndexType = typename TInputImage::IndexType;
74  using PixelType = typename TInputImage::PixelType;
75 
77  itkStaticConstMacro(ImageDimension, unsigned int,
78  TInputImage::ImageDimension);
79 
81  using RealType = typename itk::NumericTraits< PixelType >::RealType;
82 
84  using DataObjectPointer = typename itk::DataObject::Pointer;
85 
88 // using PixelObjectType = SimpleDataObjectDecorator< PixelType >;
89 
92  { return this->GetTotalVariationOutput()->Get(); }
95 
97 
100  using DataObjectPointerArraySizeType = itk::ProcessObject::DataObjectPointerArraySizeType;
101  using Superclass::MakeOutput;
103 
104 #ifdef ITK_USE_CONCEPT_CHECKING
105  // Begin concept checking
106  itkConceptMacro( InputHasNumericTraitsCheck,
108  // End concept checking
109 #endif
110 
114  { this->SetUseImageSpacing(true); }
115 
119  { this->SetUseImageSpacing(false); }
120 
123  itkSetMacro(UseImageSpacing, bool);
124  itkGetConstMacro(UseImageSpacing, bool);
126 
127 protected:
129  ~TotalVariationImageFilter() override = default;
130  void PrintSelf(std::ostream & os, itk::Indent indent) const override;
131 
135  void AllocateOutputs() override;
136 
138  void BeforeThreadedGenerateData() override;
139 
142  void AfterThreadedGenerateData() override;
143 
145  void ThreadedGenerateData(const RegionType &
146  outputRegionForThread,
147  itk::ThreadIdType threadId) override;
148 
149  // Override since the filter needs all the data for the algorithm
150  void GenerateInputRequestedRegion() override;
151 
152  // Override since the filter produces all of its output
153  void EnlargeOutputRequestedRegion(itk::DataObject *data) override;
154 
156 
157 private:
159 }; // end of class
160 } // end namespace rtk
161 
162 #ifndef ITK_MANUAL_INSTANTIATION
163 #include "rtkTotalVariationImageFilter.hxx"
164 #endif
165 
166 #endif
typename TInputImage::RegionType RegionType
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
typename TInputImage::IndexType IndexType
void ThreadedGenerateData(const RegionType &outputRegionForThread, itk::ThreadIdType threadId) override
Compute the total variation of an Image.
void GenerateInputRequestedRegion() override
void EnlargeOutputRequestedRegion(itk::DataObject *data) override
~TotalVariationImageFilter() override=default
typename itk::DataObject::Pointer DataObjectPointer
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
typename itk::NumericTraits< PixelType >::RealType RealType
typename TInputImage::SizeType SizeType
void AfterThreadedGenerateData() override
void PrintSelf(std::ostream &os, itk::Indent indent) const override
unsigned int ThreadIdType
RealObjectType * GetTotalVariationOutput()
typename TInputImage::Pointer InputImagePointer
#define itkConceptMacro(name, concept)
typename TInputImage::PixelType PixelType
virtual void SetUseImageSpacing(bool _arg)
#define itkSetMacro(name, type)
void BeforeThreadedGenerateData() override