ITK  4.2.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"
25 #include "itkLoggerThreadWrapper.h"
26 #include "itkLogger.h"
30 #include "itkRGBPixel.h"
31 #include "itkRGBAPixel.h"
32 #include "itkDiffusionTensor3D.h"
33 
34 namespace itk
35 {
36 
94 template <class TInputImage, class TOutputImage>
96 public ImageToImageFilter<TInputImage, TOutputImage>
97 {
98  public:
104 
107 
109  typedef TInputImage InputImageType;
110  typedef TOutputImage OutputImageType;
111 
113  itkStaticConstMacro(ImageDimension, unsigned int,
114  InputImageType::ImageDimension);
115 
119  typedef typename InputImageType::PixelType InputPixelType;
120  typedef typename OutputImageType::PixelType OutputPixelType;
123 
126 
128  typedef enum { GAUSSIAN = 0, RICIAN = 1, POISSON = 2 } NoiseModelType;
129 
133  typedef enum { EUCLIDEAN = 0, RIEMANNIAN = 1 } ComponentSpaceType;
134 
135  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
136 
141 
146  typedef typename ::itk::Statistics::ImageToNeighborhoodSampleAdaptor<
151 
152 
158  itkSetMacro(PatchRadius, unsigned int);
159  itkGetConstMacro(PatchRadius, unsigned int);
161 
162  PatchRadiusType GetPatchRadiusInVoxels() const;
163  PatchRadiusType GetPatchDiameterInVoxels() const;
164  typename PatchRadiusType::SizeValueType GetPatchLengthInVoxels() const;
165 
170  void SetPatchWeights(const PatchWeightsType& weights);
171  PatchWeightsType GetPatchWeights() const;
173 
174 
179  itkSetMacro(NoiseModel, NoiseModelType);
180  itkGetConstMacro(NoiseModel, NoiseModelType);
182 
187  itkSetClampMacro(SmoothingWeight, double, 0.0, 1.0);
188  itkGetConstMacro(SmoothingWeight, double);
190 
195  itkSetClampMacro(FidelityWeight, double, 0.0, 1.0);
196  itkGetConstMacro(FidelityWeight, double);
198 
199 
204  itkSetMacro(DoKernelBandwidthEstimation, bool);
205  itkBooleanMacro(DoKernelBandwidthEstimation);
206  itkGetConstMacro(DoKernelBandwidthEstimation, bool);
208 
215  itkSetClampMacro(KernelBandwidthUpdateFrequency, unsigned int, 1, NumericTraits<unsigned int>::max());
216  itkGetConstMacro(KernelBandwidthUpdateFrequency, unsigned int);
218 
219 
224  itkSetClampMacro(NumberOfIterations, unsigned int, 1, NumericTraits<unsigned int>::max());
225  itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
227 
229  itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
230 
231 
236  itkSetMacro(AlwaysTreatComponentsAsEuclidean, bool);
237  itkBooleanMacro(AlwaysTreatComponentsAsEuclidean);
238  itkGetConstMacro(AlwaysTreatComponentsAsEuclidean, bool);
240 
241 
243  virtual void SetStateToInitialized();
244 
246  virtual void SetStateToUninitialized();
247 
249 #if !defined(CABLE_CONFIGURATION)
250  itkSetMacro(State, FilterStateType);
251  itkGetConstReferenceMacro(State, FilterStateType);
252 #endif
253 
254 
257  itkSetMacro(ManualReinitialization, bool);
258  itkGetConstReferenceMacro(ManualReinitialization, bool);
259  itkBooleanMacro(ManualReinitialization);
261 
263  itkSetObjectMacro(Logger, LoggerType);
264  itkGetObjectMacro(Logger, LoggerType);
266 
267  protected:
270 
271  virtual void PrintSelf(std::ostream& os, Indent indent) const;
272 
273  virtual void GenerateInputRequestedRegion();
274 
275  virtual void GenerateData();
276 
277  virtual void CopyInputToOutput() = 0;
278 
280  virtual void InitializePatchWeights();
281  virtual void Initialize() { };
283 
285  virtual void AllocateUpdateBuffer() = 0;
286 
287  virtual void PreProcessInput() { };
288 
289  virtual void InitializeIteration() { };
290 
292  virtual void ComputeKernelBandwidthUpdate() = 0;
293 
295  virtual void ComputeImageUpdate() = 0;
296  virtual void ApplyUpdate() = 0;
298 
299  virtual void PostProcessOutput() { };
300 
302  virtual bool Halt();
303  virtual bool ThreadedHalt(void *itkNotUsed(threadInfo)) { return this->Halt(); }
305 
306  itkSetMacro(ElapsedIterations, unsigned int);
307 
308 /* /\** Set the component space based on pixel type *\/ */
309 /* itkSetMacro(ComponentSpace, ComponentSpaceType); */
311  ComponentSpaceType DetermineComponentSpace(const RGBPixel<PixelValueType>& itkNotUsed(p))
312  { return EUCLIDEAN; }
313  ComponentSpaceType DetermineComponentSpace(const RGBAPixel<PixelValueType>& itkNotUsed(p))
314  { return EUCLIDEAN; }
315  ComponentSpaceType DetermineComponentSpace(const DiffusionTensor3D<PixelValueType>& itkNotUsed(p))
316  { return RIEMANNIAN; }
317  template <class PixelT>
318  ComponentSpaceType DetermineComponentSpace(const PixelT& itkNotUsed(p))
319  { return EUCLIDEAN; }
321 
322 
324  unsigned int m_PatchRadius;
326 
330 
333  unsigned int m_NumberOfIterations;
334  unsigned int m_ElapsedIterations;
335 
340 
345 
349 
352 
353  private:
354  PatchBasedDenoisingBaseImageFilter(const Self&); // purposely not implemented
355  void operator=(const Self&); // purposely not implemented
356 
359 
360  }; // end class PatchBasedDenoisingBaseImageFilter
361 
362 } // end namespace itk
363 
364 // Define instantiation macro for this template
365 
366 #define ITK_TEMPLATE_PatchBasedDenoisingBaseImageFilter(_, EXPORT, x, y) namespace itk { \
367  _(2(class EXPORT PatchBasedDenoisingBaseImageFilter< ITK_TEMPLATE_2 x >)) | \
368  namespace Templates { typedef PatchBasedDenoisingBaseImageFilter< ITK_TEMPLATE_2 x > \
369  PatchBasedDenoisingBaseImageFilter##y; } \
370  }
371 
372 #if ITK_TEMPLATE_EXPLICIT
373 # include "Templates/itkPatchBasedDenoisingBaseImageFilter+-.h"
374 #endif
375 
376 #if ITK_TEMPLATE_TXX
377 # include "itkPatchBasedDenoisingBaseImageFilter.hxx"
378 #endif
379 
380 #endif
381