RTK  2.6.0
Reconstruction Toolkit
rtkForwardDifferenceGradientImageFilter.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 rtkForwardDifferenceGradientImageFilter_h
20 #define rtkForwardDifferenceGradientImageFilter_h
21 
22 #include <itkImageToImageFilter.h>
23 #include <itkCovariantVector.h>
24 #include <itkImageRegionIterator.h>
25 
26 #include "rtkMacro.h"
27 
28 namespace rtk
29 {
50 template <typename TInputImage,
51  typename TOperatorValueType = float,
52  typename TOuputValue = float,
53  typename TOuputImage =
55 class ITK_TEMPLATE_EXPORT ForwardDifferenceGradientImageFilter
56  : public itk::ImageToImageFilter<TInputImage, TOuputImage>
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_MOVE(ForwardDifferenceGradientImageFilter);
60 
62  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
63  static constexpr unsigned int OutputImageDimension = TOuputImage::ImageDimension;
64 
67 
69  using InputImageType = TInputImage;
70  using InputImagePointer = typename InputImageType::Pointer;
71  using OutputImageType = TOuputImage;
72  using OutputImagePointer = typename OutputImageType::Pointer;
73 
78 
80  itkNewMacro(Self);
81 
83  itkOverrideGetNameOfClassMacro(ForwardDifferenceGradientImageFilter);
84 
86  using OperatorValueType = TOperatorValueType;
87  using OutputValueType = TOuputValue;
88  using InputPixelType = typename InputImageType::PixelType;
89  using CovariantVectorType = typename OutputImageType::PixelType;
90  using OutputImageRegionType = typename OutputImageType::RegionType;
91 
98  void
99  GenerateInputRequestedRegion() override;
100 
103  void
105  {
106  this->SetUseImageSpacing(true);
107  }
108 
111  void
113  {
114  this->SetUseImageSpacing(false);
115  }
116 
119  itkSetMacro(UseImageSpacing, bool);
120  itkGetConstMacro(UseImageSpacing, bool);
122 
126  void
127  SetDimensionsProcessed(bool * DimensionsProcessed);
128 
130  void
131  OverrideBoundaryCondition(itk::ImageBoundaryCondition<TInputImage> * boundaryCondition);
132 
133  // Begin concept checking
136  // End concept checking
137 
148  itkSetMacro(UseImageDirection, bool);
149  itkGetConstMacro(UseImageDirection, bool);
150  itkBooleanMacro(UseImageDirection);
152 
153 protected:
156  void
157  PrintSelf(std::ostream & os, itk::Indent indent) const override;
158 
169  void
170  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
171 
172  void
173  GenerateOutputInformation() override;
174 
175 private:
176  // // An overloaded method which may transform the gradient to a
177  // // physical vector and converts to the correct output pixel type.
178  // template <typename TValue>
179  // void SetOutputPixel( ImageRegionIterator< VectorImage<TValue,OutputImageDimension> > &it, CovariantVectorType
180  // &gradient )
181  // {
182  // if ( this->m_UseImageDirection )
183  // {
184  // CovariantVectorType physicalGradient;
185  // it.GetImage()->TransformLocalVectorToPhysicalVector( gradient, physicalGradient );
186  // it.Set( OutputPixelType( physicalGradient.GetDataPointer(), InputImageDimension, false ) );
187  // }
188  // else
189  // {
190  // it.Set( OutputPixelType( gradient.GetDataPointer(), InputImageDimension, false ) );
191  // }
192  // }
193 
194  template <typename T>
195  void
197  {
198  it.Value() = gradient;
199  }
200 
201 
203 
204  // flag to take or not the image direction into account
205  // when computing the derivatives.
207 
208  // list of the dimensions along which the gradient has
209  // to be computed. The components on other dimensions
210  // are set to zero
211  bool m_DimensionsProcessed[TInputImage::ImageDimension];
212 
215 };
216 } // namespace rtk
217 
218 #ifndef ITK_MANUAL_INSTANTIATION
219 # include "rtkForwardDifferenceGradientImageFilter.hxx"
220 #endif
221 
222 #endif
typename OutputImageType::Pointer OutputImagePointer
itk::ImageBoundaryCondition< TInputImage, TInputImage > * m_BoundaryCondition
#define itkSetMacro(name, type)
Computes the gradient of an image using forward difference.
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
void SetOutputPixel(itk::ImageRegionIterator< T > &it, CovariantVectorType &gradient)
#define itkConceptMacro(name, concept)