ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkPatchBasedDenoisingBaseImageFilter.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 itkPatchBasedDenoisingBaseImageFilter_h
19 #define itkPatchBasedDenoisingBaseImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkArray.h"
23 #include "itkSample.h"
24 #include "itkNumericTraits.h"
28 #include "itkRGBPixel.h"
29 #include "itkRGBAPixel.h"
30 #include "itkDiffusionTensor3D.h"
31 
32 namespace itk
33 {
34 
93 template <typename TInputImage, typename TOutputImage>
94 class ITK_TEMPLATE_EXPORT PatchBasedDenoisingBaseImageFilter :
95  public ImageToImageFilter<TInputImage, TOutputImage>
96 {
97 public:
103 
106 
108  typedef TInputImage InputImageType;
109  typedef TOutputImage OutputImageType;
110 
112  itkStaticConstMacro(ImageDimension, unsigned int,
113  InputImageType::ImageDimension);
114 
118  typedef typename InputImageType::PixelType InputPixelType;
119  typedef typename OutputImageType::PixelType OutputPixelType;
122 
124  typedef enum { NOMODEL = 0, GAUSSIAN = 1, RICIAN = 2, POISSON = 3 } NoiseModelType;
125 
130  typedef enum { EUCLIDEAN = 0, RIEMANNIAN = 1 } ComponentSpaceType;
131 
133  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
134 
139 
144  typedef typename::itk::Statistics::ImageToNeighborhoodSampleAdaptor<
146  typedef typename ListAdaptorType::NeighborhoodRadiusType PatchRadiusType;
149 
155  itkSetMacro(PatchRadius, unsigned int);
156  itkGetConstMacro(PatchRadius, unsigned int);
158 
159  PatchRadiusType GetPatchRadiusInVoxels() const;
160 
161  PatchRadiusType GetPatchDiameterInVoxels() const;
162 
163  typename PatchRadiusType::SizeValueType GetPatchLengthInVoxels() const;
164 
169  void SetPatchWeights(const PatchWeightsType& weights);
170 
171  PatchWeightsType GetPatchWeights() const;
172 
177  itkSetMacro(NoiseModel, NoiseModelType);
178  itkGetConstMacro(NoiseModel, NoiseModelType);
180 
186  itkSetClampMacro(SmoothingWeight, double, 0.0, 1.0);
187  itkGetConstMacro(SmoothingWeight, double);
189 
195  itkSetClampMacro(NoiseModelFidelityWeight, double, 0.0, 1.0);
196  itkGetConstMacro(NoiseModelFidelityWeight, double);
198 
203  itkSetMacro(KernelBandwidthEstimation, bool);
204  itkBooleanMacro(KernelBandwidthEstimation);
205  itkGetConstMacro(KernelBandwidthEstimation, bool);
207 
214  itkSetClampMacro(KernelBandwidthUpdateFrequency, unsigned int, 1, NumericTraits<unsigned int>::max() );
215  itkGetConstMacro(KernelBandwidthUpdateFrequency, unsigned int);
217 
222  itkSetClampMacro(NumberOfIterations, unsigned int, 1, NumericTraits<unsigned int>::max() );
223  itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
225 
227  itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
228 
233  itkSetMacro(AlwaysTreatComponentsAsEuclidean, bool);
234  itkBooleanMacro(AlwaysTreatComponentsAsEuclidean);
235  itkGetConstMacro(AlwaysTreatComponentsAsEuclidean, bool);
237 
239  virtual void SetStateToInitialized();
240 
242  virtual void SetStateToUninitialized();
243 
245 #if !defined(ITK_WRAPPING_PARSER)
246  itkSetMacro(State, FilterStateType);
247  itkGetConstReferenceMacro(State, FilterStateType);
248 #endif
249 
250 
255  itkSetMacro(ManualReinitialization, bool);
256  itkGetConstReferenceMacro(ManualReinitialization, bool);
257  itkBooleanMacro(ManualReinitialization);
259 
260 protected:
262  ~PatchBasedDenoisingBaseImageFilter() ITK_OVERRIDE;
263 
264  virtual void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
265 
266  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
267 
268  virtual void GenerateData() ITK_OVERRIDE;
269 
270  virtual void CopyInputToOutput() = 0;
271 
273  virtual void InitializePatchWeights();
274 
275  virtual void Initialize() { }
276 
278  virtual void AllocateUpdateBuffer() = 0;
279 
280  virtual void PreProcessInput() { }
281 
282  virtual void InitializeIteration() { }
283 
285  virtual void ComputeKernelBandwidthUpdate() = 0;
286 
288  virtual void ComputeImageUpdate() = 0;
289 
290  virtual void ApplyUpdate() = 0;
291 
292  virtual void PostProcessOutput() { }
293 
295  virtual bool Halt();
296 
297  virtual bool ThreadedHalt(void *itkNotUsed(threadInfo) )
298  {
299  return this->Halt();
300  }
301 
302  itkSetMacro(ElapsedIterations, unsigned int);
303 
306  {
307  return EUCLIDEAN;
308  }
309 
311  {
312  return EUCLIDEAN;
313  }
314 
316  {
317  return RIEMANNIAN;
318  }
319 
320  template <typename PixelT>
321  ComponentSpaceType DetermineComponentSpace(const PixelT& itkNotUsed(p) )
322  {
323  return EUCLIDEAN;
324  }
325 
327  itkSetMacro(ComponentSpace, ComponentSpaceType);
328  itkGetConstMacro(ComponentSpace, ComponentSpaceType);
330 
331  // Cache input and output pointer to get rid of thousands of calls
332  // to GetInput and GetOutput.
335 
336 private:
337  ITK_DISALLOW_COPY_AND_ASSIGN(PatchBasedDenoisingBaseImageFilter);
338 
340  unsigned int m_PatchRadius;
342 
346 
349  unsigned int m_NumberOfIterations;
350  unsigned int m_ElapsedIterations;
351 
356 
361 
363 
365 };
366 } // end namespace itk
367 
368 #ifndef ITK_MANUAL_INSTANTIATION
369 #include "itkPatchBasedDenoisingBaseImageFilter.hxx"
370 #endif
371 
372 #endif
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
ImageToImageFilter< TInputImage, TOutputImage > Superclass
ConstNeighborhoodIterator< InputImageType, BoundaryConditionType > InputImagePatchIterator
Represent Red, Green, Blue and Alpha components for color images.
Definition: itkRGBAPixel.h:59
Base class for patch-based denoising algorithms.
ZeroFluxNeumannBoundaryCondition< OutputImageType > BoundaryConditionType
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
unsigned long SizeValueType
Definition: itkIntTypes.h:143
typename::itk::Statistics::ImageToNeighborhoodSampleAdaptor< OutputImageType, BoundaryConditionType > ListAdaptorType
ComponentSpaceType DetermineComponentSpace(const RGBAPixel< PixelValueType > &)
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:58
ComponentSpaceType DetermineComponentSpace(const RGBPixel< PixelValueType > &)
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
Represent a diffusion tensor as used in DTI images.
ComponentSpaceType DetermineComponentSpace(const DiffusionTensor3D< PixelValueType > &)
ListAdaptorType::NeighborhoodRadiusType PatchRadiusType