ITK  4.6.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>
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 
132  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
133 
138 
143  typedef typename::itk::Statistics::ImageToNeighborhoodSampleAdaptor<
145  typedef typename ListAdaptorType::NeighborhoodRadiusType PatchRadiusType;
148 
154  itkSetMacro(PatchRadius, unsigned int);
155  itkGetConstMacro(PatchRadius, unsigned int);
157 
159 
161 
163 
168  void SetPatchWeights(const PatchWeightsType& weights);
169 
171 
176  itkSetMacro(NoiseModel, NoiseModelType);
177  itkGetConstMacro(NoiseModel, NoiseModelType);
179 
184  itkSetClampMacro(SmoothingWeight, double, 0.0, 1.0);
185  itkGetConstMacro(SmoothingWeight, double);
187 
192  itkSetClampMacro(NoiseModelFidelityWeight, double, 0.0, 1.0);
193  itkGetConstMacro(NoiseModelFidelityWeight, double);
195 
200  itkSetMacro(KernelBandwidthEstimation, bool);
201  itkBooleanMacro(KernelBandwidthEstimation);
202  itkGetConstMacro(KernelBandwidthEstimation, bool);
204 
211  itkSetClampMacro(KernelBandwidthUpdateFrequency, unsigned int, 1, NumericTraits<unsigned int>::max() );
212  itkGetConstMacro(KernelBandwidthUpdateFrequency, unsigned int);
214 
219  itkSetClampMacro(NumberOfIterations, unsigned int, 1, NumericTraits<unsigned int>::max() );
220  itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
222 
224  itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
225 
230  itkSetMacro(AlwaysTreatComponentsAsEuclidean, bool);
231  itkBooleanMacro(AlwaysTreatComponentsAsEuclidean);
232  itkGetConstMacro(AlwaysTreatComponentsAsEuclidean, bool);
234 
236  virtual void SetStateToInitialized();
237 
239  virtual void SetStateToUninitialized();
240 
242 #if !defined(CABLE_CONFIGURATION)
243  itkSetMacro(State, FilterStateType);
244  itkGetConstReferenceMacro(State, FilterStateType);
245 #endif
246 
247 
250  itkSetMacro(ManualReinitialization, bool);
251  itkGetConstReferenceMacro(ManualReinitialization, bool);
252  itkBooleanMacro(ManualReinitialization);
254 
255 protected:
258 
259  virtual void PrintSelf(std::ostream& os, Indent indent) const;
260 
261  virtual void GenerateInputRequestedRegion();
262 
263  virtual void GenerateData();
264 
265  virtual void CopyInputToOutput() = 0;
266 
268  virtual void InitializePatchWeights();
269 
270  virtual void Initialize() { }
271 
273  virtual void AllocateUpdateBuffer() = 0;
274 
275  virtual void PreProcessInput() { }
276 
277  virtual void InitializeIteration() { }
278 
280  virtual void ComputeKernelBandwidthUpdate() = 0;
281 
283  virtual void ComputeImageUpdate() = 0;
284 
285  virtual void ApplyUpdate() = 0;
286 
287  virtual void PostProcessOutput() { }
288 
290  virtual bool Halt();
291 
292  virtual bool ThreadedHalt(void *itkNotUsed(threadInfo) )
293  {
294  return this->Halt();
295  }
296 
297  itkSetMacro(ElapsedIterations, unsigned int);
298 
301  {
302  return EUCLIDEAN;
303  }
304 
306  {
307  return EUCLIDEAN;
308  }
309 
311  {
312  return RIEMANNIAN;
313  }
314 
315  template <typename PixelT>
316  ComponentSpaceType DetermineComponentSpace(const PixelT& itkNotUsed(p) )
317  {
318  return EUCLIDEAN;
319  }
320 
322  unsigned int m_PatchRadius;
324 
328 
331  unsigned int m_NumberOfIterations;
332  unsigned int m_ElapsedIterations;
333 
338 
343 
347 
353 
354 private:
355  PatchBasedDenoisingBaseImageFilter(const Self&); // purposely not implemented
356  void operator=(const Self&); // purposely not implemented
357 
360 
361 }; // end class PatchBasedDenoisingBaseImageFilter
362 
363 } // end namespace itk
364 
365 #ifndef ITK_MANUAL_INSTANTIATION
366 # include "itkPatchBasedDenoisingBaseImageFilter.hxx"
367 #endif
368 
369 #endif
virtual void PrintSelf(std::ostream &os, Indent indent) const
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 denoisng algorithms.
ZeroFluxNeumannBoundaryCondition< OutputImageType > BoundaryConditionType
PatchRadiusType::SizeValueType GetPatchLengthInVoxels() const
Base class for all process objects that output image data.
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 > &)
PatchRadiusType GetPatchRadiusInVoxels() const
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:58
ComponentSpaceType DetermineComponentSpace(const RGBPixel< PixelValueType > &)
PatchRadiusType GetPatchDiameterInVoxels() const
Base class for filters that take an image as input and produce an image as output.
PatchWeightsType GetPatchWeights() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
TOutputImage OutputImageType
void SetPatchWeights(const PatchWeightsType &weights)
Represent a diffusion tensor as used in DTI images.
ComponentSpaceType DetermineComponentSpace(const DiffusionTensor3D< PixelValueType > &)
ListAdaptorType::NeighborhoodRadiusType PatchRadiusType