ITK  4.3.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 
92 template <class TInputImage, class TOutputImage>
94  public ImageToImageFilter<TInputImage, TOutputImage>
95 {
96 public:
102 
105 
107  typedef TInputImage InputImageType;
108  typedef TOutputImage OutputImageType;
109 
111  itkStaticConstMacro(ImageDimension, unsigned int,
112  InputImageType::ImageDimension);
113 
117  typedef typename InputImageType::PixelType InputPixelType;
118  typedef typename OutputImageType::PixelType OutputPixelType;
121 
123  typedef enum { GAUSSIAN = 0, RICIAN = 1, POISSON = 2 } NoiseModelType;
124 
129  typedef enum { EUCLIDEAN = 0, RIEMANNIAN = 1 } ComponentSpaceType;
130 
131  typedef enum { UNINITIALIZED = 0, INITIALIZED = 1 } FilterStateType;
132 
137 
142  typedef typename::itk::Statistics::ImageToNeighborhoodSampleAdaptor<
144  typedef typename ListAdaptorType::NeighborhoodRadiusType PatchRadiusType;
147 
153  itkSetMacro(PatchRadius, unsigned int);
154  itkGetConstMacro(PatchRadius, unsigned int);
156 
157  PatchRadiusType GetPatchRadiusInVoxels() const;
158 
159  PatchRadiusType GetPatchDiameterInVoxels() const;
160 
161  typename PatchRadiusType::SizeValueType GetPatchLengthInVoxels() const;
162 
167  void SetPatchWeights(const PatchWeightsType& weights);
168 
169  PatchWeightsType GetPatchWeights() const;
170 
175  itkSetMacro(NoiseModel, NoiseModelType);
176  itkGetConstMacro(NoiseModel, NoiseModelType);
178 
183  itkSetClampMacro(SmoothingWeight, double, 0.0, 1.0);
184  itkGetConstMacro(SmoothingWeight, double);
186 
191  itkSetClampMacro(FidelityWeight, double, 0.0, 1.0);
192  itkGetConstMacro(FidelityWeight, double);
194 
199  itkSetMacro(DoKernelBandwidthEstimation, bool);
200  itkBooleanMacro(DoKernelBandwidthEstimation);
201  itkGetConstMacro(DoKernelBandwidthEstimation, bool);
203 
210  itkSetClampMacro(KernelBandwidthUpdateFrequency, unsigned int, 1, NumericTraits<unsigned int>::max() );
211  itkGetConstMacro(KernelBandwidthUpdateFrequency, unsigned int);
213 
218  itkSetClampMacro(NumberOfIterations, unsigned int, 1, NumericTraits<unsigned int>::max() );
219  itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
221 
223  itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
224 
229  itkSetMacro(AlwaysTreatComponentsAsEuclidean, bool);
230  itkBooleanMacro(AlwaysTreatComponentsAsEuclidean);
231  itkGetConstMacro(AlwaysTreatComponentsAsEuclidean, bool);
233 
235  virtual void SetStateToInitialized();
236 
238  virtual void SetStateToUninitialized();
239 
241 #if !defined(CABLE_CONFIGURATION)
242  itkSetMacro(State, FilterStateType);
243  itkGetConstReferenceMacro(State, FilterStateType);
244 #endif
245 
246 
249  itkSetMacro(ManualReinitialization, bool);
250  itkGetConstReferenceMacro(ManualReinitialization, bool);
251  itkBooleanMacro(ManualReinitialization);
253 
254 protected:
257 
258  virtual void PrintSelf(std::ostream& os, Indent indent) const;
259 
260  virtual void GenerateInputRequestedRegion();
261 
262  virtual void GenerateData();
263 
264  virtual void CopyInputToOutput() = 0;
265 
267  virtual void InitializePatchWeights();
268 
269  virtual void Initialize() { }
270 
272  virtual void AllocateUpdateBuffer() = 0;
273 
274  virtual void PreProcessInput() { }
275 
276  virtual void InitializeIteration() { }
277 
279  virtual void ComputeKernelBandwidthUpdate() = 0;
280 
282  virtual void ComputeImageUpdate() = 0;
283 
284  virtual void ApplyUpdate() = 0;
285 
286  virtual void PostProcessOutput() { }
287 
289  virtual bool Halt();
290 
291  virtual bool ThreadedHalt(void *itkNotUsed(threadInfo) )
292  {
293  return this->Halt();
294  }
295 
296  itkSetMacro(ElapsedIterations, unsigned int);
297 
299  ComponentSpaceType DetermineComponentSpace(const RGBPixel<PixelValueType>& itkNotUsed(p) )
300  {
301  return EUCLIDEAN;
302  }
303 
304  ComponentSpaceType DetermineComponentSpace(const RGBAPixel<PixelValueType>& itkNotUsed(p) )
305  {
306  return EUCLIDEAN;
307  }
308 
309  ComponentSpaceType DetermineComponentSpace(const DiffusionTensor3D<PixelValueType>& itkNotUsed(p) )
310  {
311  return RIEMANNIAN;
312  }
313 
314  template <class PixelT>
315  ComponentSpaceType DetermineComponentSpace(const PixelT& itkNotUsed(p) )
316  {
317  return EUCLIDEAN;
318  }
319 
321  unsigned int m_PatchRadius;
323 
327 
330  unsigned int m_NumberOfIterations;
331  unsigned int m_ElapsedIterations;
332 
337 
342 
346 
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 #ifndef ITK_MANUAL_INSTANTIATION
365 # include "itkPatchBasedDenoisingBaseImageFilter.hxx"
366 #endif
367 
368 #endif
369