RTK  1.4.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  * 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:
59 
61  itkNewMacro(Self);
62 
65 
67  typedef typename TInputImage::Pointer InputImagePointer;
68 
69  typedef typename TInputImage::RegionType RegionType;
70  typedef typename TInputImage::SizeType SizeType;
71  typedef typename TInputImage::IndexType IndexType;
72  typedef typename TInputImage::PixelType PixelType;
73 
75  itkStaticConstMacro(ImageDimension, unsigned int,
76  TInputImage::ImageDimension);
77 
80 
82  typedef typename itk::DataObject::Pointer DataObjectPointer;
83 
86 // typedef SimpleDataObjectDecorator< PixelType > PixelObjectType;
87 
89  RealType GetTotalVariation() const
90  { return this->GetTotalVariationOutput()->Get(); }
91  RealObjectType * GetTotalVariationOutput();
93 
94  const RealObjectType * GetTotalVariationOutput() const;
95 
98  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
99  using Superclass::MakeOutput;
100  DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) ITK_OVERRIDE;
101 
102 #ifdef ITK_USE_CONCEPT_CHECKING
103  // Begin concept checking
104  itkConceptMacro( InputHasNumericTraitsCheck,
106  // End concept checking
107 #endif
108 
112  { this->SetUseImageSpacing(true); }
113 
117  { this->SetUseImageSpacing(false); }
118 
121  itkSetMacro(UseImageSpacing, bool);
122  itkGetConstMacro(UseImageSpacing, bool);
124 
125 protected:
127  virtual ~TotalVariationImageFilter() ITK_OVERRIDE {}
128  void PrintSelf(std::ostream & os, itk::Indent indent) const ITK_OVERRIDE;
129 
133  void AllocateOutputs() ITK_OVERRIDE;
134 
136  void BeforeThreadedGenerateData() ITK_OVERRIDE;
137 
140  void AfterThreadedGenerateData() ITK_OVERRIDE;
141 
143  void ThreadedGenerateData(const RegionType &
144  outputRegionForThread,
145  itk::ThreadIdType threadId) ITK_OVERRIDE;
146 
147  // Override since the filter needs all the data for the algorithm
148  void GenerateInputRequestedRegion() ITK_OVERRIDE;
149 
150  // Override since the filter produces all of its output
151  void EnlargeOutputRequestedRegion(itk::DataObject *data) ITK_OVERRIDE;
152 
154 
155 private:
156  TotalVariationImageFilter(const Self &); //purposely not implemented
157  void operator=(const Self &); //purposely not implemented
158 
160 }; // end of class
161 } // end namespace rtk
162 
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "rtkTotalVariationImageFilter.hxx"
165 #endif
166 
167 #endif
void operator=(const Self &)
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
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
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx) override
void AfterThreadedGenerateData() override
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::NumericTraits< PixelType >::RealType RealType
unsigned int ThreadIdType
RealObjectType * GetTotalVariationOutput()
itk::SmartPointer< const Self > ConstPointer
itk::ImageToImageFilter< TInputImage, TInputImage > Superclass
#define itkConceptMacro(name, concept)
virtual void SetUseImageSpacing(bool _arg)
#define itkSetMacro(name, type)
void BeforeThreadedGenerateData() override
itk::SimpleDataObjectDecorator< RealType > RealObjectType