RTK  2.6.0
Reconstruction Toolkit
rtkUnwarpSequenceImageFilter.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 rtkUnwarpSequenceImageFilter_h
20 #define rtkUnwarpSequenceImageFilter_h
21 
25 #include "rtkConstantImageSource.h"
26 
27 #ifdef RTK_USE_CUDA
30 #endif
31 
32 namespace rtk
33 {
73 template <typename TImageSequence,
74  typename TDVFImageSequence =
75  itk::Image<itk::CovariantVector<typename TImageSequence::ValueType, TImageSequence::ImageDimension - 1>,
76  TImageSequence::ImageDimension>,
77  typename TImage = itk::Image<typename TImageSequence::ValueType, TImageSequence::ImageDimension - 1>,
78  typename TDVFImage =
79  itk::Image<itk::CovariantVector<typename TImageSequence::ValueType, TImageSequence::ImageDimension - 1>,
80  TImageSequence::ImageDimension - 1>>
81 class ITK_TEMPLATE_EXPORT UnwarpSequenceImageFilter : public itk::ImageToImageFilter<TImageSequence, TImageSequence>
82 {
83 public:
84  ITK_DISALLOW_COPY_AND_MOVE(UnwarpSequenceImageFilter);
85 
90 
92  itkNewMacro(Self);
93 
95  itkOverrideGetNameOfClassMacro(UnwarpSequenceImageFilter);
96 
97  using CGOperatorFilterType =
101 
104 #ifdef RTK_USE_CUDA
105  typedef typename std::conditional<std::is_same<TImageSequence, CPUImageSequence>::value,
107  CudaConstantVolumeSeriesSource>::type ConstantSourceType;
108  typedef typename std::conditional<std::is_same<TImageSequence, CPUImageSequence>::value,
110  CudaConjugateGradientImageFilter<TImageSequence>>::type CudaConjugateGradientType;
111 #else
114 #endif
115 
117  void
118  SetDisplacementField(const TDVFImageSequence * DVFs);
119 
121  typename TDVFImageSequence::Pointer
122  GetDisplacementField();
123 
125  itkSetMacro(NumberOfIterations, float);
126  itkGetMacro(NumberOfIterations, float);
128 
130  itkSetMacro(PhaseShift, float);
131  itkGetMacro(PhaseShift, float);
133 
134  itkSetMacro(UseNearestNeighborInterpolationInWarping, bool);
135  itkGetMacro(UseNearestNeighborInterpolationInWarping, bool);
136 
137  itkSetMacro(CudaConjugateGradient, bool);
138  itkGetMacro(CudaConjugateGradient, bool);
139 
141  itkSetMacro(UseCudaCyclicDeformation, bool);
142  itkGetMacro(UseCudaCyclicDeformation, bool);
144 
145 protected:
147  ~UnwarpSequenceImageFilter() override = default;
148 
150  void
151  GenerateData() override;
152 
158 
161 
165  void
166  VerifyInputInformation() const override
167  {}
168 
171  void
172  GenerateInputRequestedRegion() override;
173  void
174  GenerateOutputInformation() override;
176 
177  bool m_UseNearestNeighborInterpolationInWarping; // Default is false, linear interpolation is used instead
180 
181 private:
182  unsigned int m_NumberOfIterations;
183 };
184 } // namespace rtk
185 
186 
187 #ifndef ITK_MANUAL_INSTANTIATION
188 # include "rtkUnwarpSequenceImageFilter.hxx"
189 #endif
190 
191 #endif
Implements the operator A used in the conjugate gradient unwarp sequence filter.
CGOperatorFilterType::Pointer m_CGOperator
Generate an n-dimensional image with constant pixel values.
Applies an N-D + time Motion Vector Field to an N-D + time sequence of images.
Finds the image sequence that, once warped, equals the input image sequence.
#define itkSetMacro(name, type)
ConstantSourceType::Pointer m_ConstantSource
typename itk::Image< typename TImageSequence::PixelType, TImageSequence::ImageDimension > CPUImageSequence
ConjugateGradientFilterType::Pointer m_ConjugateGradientFilter
Solves AX = B by conjugate gradient.
WarpForwardFilterType::Pointer m_WarpForwardFilter