ITK  5.1.0
Insight Toolkit
itkGradientRecursiveGaussianImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software 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 #ifndef itkGradientRecursiveGaussianImageFilter_h
19 #define itkGradientRecursiveGaussianImageFilter_h
20 
23 #include "itkImage.h"
24 #include "itkCovariantVector.h"
26 #include "itkProgressAccumulator.h"
27 #include "itkImageRegionIterator.h"
28 #include "itkVectorImage.h"
29 #include <vector>
30 
31 namespace itk
32 {
53 template <
54  typename TInputImage,
55  typename TOutputImage = Image<
56  CovariantVector<typename NumericTraits<typename TInputImage::PixelType>::RealType, TInputImage::ImageDimension>,
57  TInputImage::ImageDimension>>
58 class ITK_TEMPLATE_EXPORT GradientRecursiveGaussianImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_ASSIGN(GradientRecursiveGaussianImageFilter);
62 
68 
70  using InputImageType = TInputImage;
71  using PixelType = typename TInputImage::PixelType;
74 
80 
82  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
83 
86 
91 
92 
98 
100 
103 
106 
109 
112 
115 
117  using OutputImagePointer = typename TOutputImage::Pointer;
118 
120  using OutputImageType = TOutputImage;
121  using OutputPixelType = typename OutputImageType::PixelType;
124 
126  itkNewMacro(Self);
127 
130 
132  void
133  SetSigmaArray(const SigmaArrayType & sigmas);
134  void
135  SetSigma(ScalarRealType sigma);
137 
139  GetSigmaArray() const;
141  GetSigma() const;
142 
146  void
147  SetNormalizeAcrossScale(bool normalizeInScaleSpace);
148  itkGetConstMacro(NormalizeAcrossScale, bool);
150 
156  void
157  GenerateInputRequestedRegion() override;
158 
169  itkSetMacro(UseImageDirection, bool);
170  itkGetConstMacro(UseImageDirection, bool);
171  itkBooleanMacro(UseImageDirection);
173 
174 #ifdef ITK_USE_CONCEPT_CHECKING
175  // Begin concept checking
176  // Does not seem to work with wrappings, disabled
177  // itkConceptMacro( InputHasNumericTraitsCheck,
178  // ( Concept::HasNumericTraits< PixelType > ) );
179  // End concept checking
180 #endif
181 
182 protected:
184  ~GradientRecursiveGaussianImageFilter() override = default;
185  void
186  PrintSelf(std::ostream & os, Indent indent) const override;
187 
189  void
190  GenerateData() override;
191 
192  // Override since the filter produces the entire dataset
193  void
194  EnlargeOutputRequestedRegion(DataObject * output) override;
195 
196  void
197  GenerateOutputInformation() override;
198 
199 private:
200  template <typename TValue>
201  void
203  {
204  // To transform Variable length vector we need to convert to and
205  // fro the CovariantVectorType
206  const CovariantVectorType gradient(it.Get().GetDataPointer());
207  CovariantVectorType physicalGradient;
208  it.GetImage()->TransformLocalVectorToPhysicalVector(gradient, physicalGradient);
209  it.Set(OutputPixelType(physicalGradient.GetDataPointer(), ImageDimension, false));
210  }
211 
212  template <typename T>
213  void
215  {
216  OutputPixelType correctedGradient;
217  const OutputPixelType & gradient = it.Get();
218 
219  const unsigned int nComponents = NumericTraits<OutputPixelType>::GetLength(gradient) / ImageDimension;
220 
221  for (unsigned int nc = 0; nc < nComponents; nc++)
222  {
223  GradientVectorType componentGradient;
224  GradientVectorType correctedComponentGradient;
225  for (unsigned int dim = 0; dim < ImageDimension; dim++)
226  {
227  componentGradient[dim] =
228  DefaultConvertPixelTraits<OutputPixelType>::GetNthComponent(nc * ImageDimension + dim, gradient);
229  }
230  it.GetImage()->TransformLocalVectorToPhysicalVector(componentGradient, correctedComponentGradient);
231  for (unsigned int dim = 0; dim < ImageDimension; dim++)
232  {
234  nc * ImageDimension + dim, correctedGradient, correctedComponentGradient[dim]);
235  }
236  }
237  it.Set(correctedGradient);
238  }
239 
240  template <template <typename, unsigned int> class P, class T, unsigned int N>
241  void
243  {
244  const OutputPixelType gradient = it.Get();
245  // This uses the more efficient set by reference method
246  it.GetImage()->TransformLocalVectorToPhysicalVector(gradient, it.Value());
247  }
248 
249 
250  std::vector<GaussianFilterPointer> m_SmoothingFilters;
253 
256 
259 
262 };
263 } // end namespace itk
264 
265 #ifndef ITK_MANUAL_INSTANTIATION
266 # include "itkGradientRecursiveGaussianImageFilter.hxx"
267 #endif
268 
269 #endif
itk::NthElementImageAdaptor
Presents an image as being composed of the N-th element of its pixels.
Definition: itkNthElementImageAdaptor.h:57
itkRecursiveGaussianImageFilter.h
itkCovariantVector.h
itk::GradientRecursiveGaussianImageFilter::m_DerivativeFilter
DerivativeFilterPointer m_DerivativeFilter
Definition: itkGradientRecursiveGaussianImageFilter.h:251
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::NumericTraits::ValueType
T ValueType
Definition: itkNumericTraits.h:65
itkNthElementImageAdaptor.h
itk::GradientRecursiveGaussianImageFilter::InternalScalarRealType
typename NumericTraits< InternalRealType >::ValueType InternalScalarRealType
Definition: itkGradientRecursiveGaussianImageFilter.h:79
itk::VectorImage
Templated n-dimensional vector image class.
Definition: itkImageAlgorithm.h:29
itk::ImageConstIterator::GetImage
const ImageType * GetImage() const
Definition: itkImageConstIterator.h:336
itk::GradientRecursiveGaussianImageFilter::TransformOutputPixel
void TransformOutputPixel(ImageRegionIterator< Image< P< T, N >, N >> &it)
Definition: itkGradientRecursiveGaussianImageFilter.h:242
itkImage.h
itk::GradientRecursiveGaussianImageFilter::m_ImageAdaptor
OutputImageAdaptorPointer m_ImageAdaptor
Definition: itkGradientRecursiveGaussianImageFilter.h:252
itk::GradientRecursiveGaussianImageFilter::TransformOutputPixel
void TransformOutputPixel(ImageRegionIterator< T > &it)
Definition: itkGradientRecursiveGaussianImageFilter.h:214
itk::SmartPointer< Self >
itkImageRegionIterator.h
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GradientRecursiveGaussianImageFilter::TransformOutputPixel
void TransformOutputPixel(ImageRegionIterator< VectorImage< TValue, ImageDimension >> &it)
Definition: itkGradientRecursiveGaussianImageFilter.h:202
itkVectorImage.h
itk::ImageRegionIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
Definition: itkImageRegionIterator.h:78
itk::GradientRecursiveGaussianImageFilter::m_NormalizeAcrossScale
bool m_NormalizeAcrossScale
Definition: itkGradientRecursiveGaussianImageFilter.h:255
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itkDefaultConvertPixelTraits.h
itk::GradientRecursiveGaussianImageFilter::OutputComponentType
typename NumericTraits< OutputPixelType >::ValueType OutputComponentType
Definition: itkGradientRecursiveGaussianImageFilter.h:122
itk::GradientRecursiveGaussianImageFilter::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkGradientRecursiveGaussianImageFilter.h:121
itk::GradientRecursiveGaussianImageFilter::OutputImageAdaptorPointer
typename OutputImageAdaptorType::Pointer OutputImageAdaptorPointer
Definition: itkGradientRecursiveGaussianImageFilter.h:99
itk::GradientRecursiveGaussianImageFilter::m_SmoothingFilters
std::vector< GaussianFilterPointer > m_SmoothingFilters
Definition: itkGradientRecursiveGaussianImageFilter.h:250
itk::DefaultConvertPixelTraits::SetNthComponent
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
Definition: itkDefaultConvertPixelTraits.h:69
itk::GradientRecursiveGaussianImageFilter
Computes the gradient of an image by convolution with the first derivative of a Gaussian.
Definition: itkGradientRecursiveGaussianImageFilter.h:58
itk::GradientRecursiveGaussianImageFilter::ScalarRealType
typename NumericTraits< PixelType >::ScalarRealType ScalarRealType
Definition: itkGradientRecursiveGaussianImageFilter.h:73
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::GradientRecursiveGaussianImageFilter::m_UseImageDirection
bool m_UseImageDirection
Definition: itkGradientRecursiveGaussianImageFilter.h:258
itk::ImageRegionIterator::Set
void Set(const PixelType &value) const
Definition: itkImageRegionIterator.h:114
itk::FixedArray< ScalarRealType, Self::ImageDimension >
itk::GradientRecursiveGaussianImageFilter::GaussianFilterPointer
typename GaussianFilterType::Pointer GaussianFilterPointer
Definition: itkGradientRecursiveGaussianImageFilter.h:111
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:68
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ImageConstIterator::Get
PixelType Get() const
Definition: itkImageConstIterator.h:343
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition: itkNumericTraits.h:208
itkProgressAccumulator.h
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:135
itk::DefaultConvertPixelTraits::GetNthComponent
static ComponentType GetNthComponent(int c, const PixelType &pixel)
Definition: itkDefaultConvertPixelTraits.h:62
itk::GradientRecursiveGaussianImageFilter::PixelType
typename TInputImage::PixelType PixelType
Definition: itkGradientRecursiveGaussianImageFilter.h:71
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::RecursiveGaussianImageFilter
Base class for computing IIR convolution with an approximation of a Gaussian kernel.
Definition: itkRecursiveGaussianImageFilter.h:75
itk::GradientRecursiveGaussianImageFilter::m_Sigma
SigmaArrayType m_Sigma
Definition: itkGradientRecursiveGaussianImageFilter.h:261
itk::GradientRecursiveGaussianImageFilter::RealType
typename NumericTraits< PixelType >::RealType RealType
Definition: itkGradientRecursiveGaussianImageFilter.h:72
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:282
itk::GradientRecursiveGaussianImageFilter::InternalRealType
typename NumericTraits< RealType >::FloatType InternalRealType
Definition: itkGradientRecursiveGaussianImageFilter.h:78
itk::GradientRecursiveGaussianImageFilter::DerivativeFilterPointer
typename DerivativeFilterType::Pointer DerivativeFilterPointer
Definition: itkGradientRecursiveGaussianImageFilter.h:114