ITK  6.0.0
Insight Toolkit
itkPatchBasedDenoisingBaseImageFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
22#include "itkArray.h"
23#include "itkSample.h"
24#include "itkNumericTraits.h"
28#include "itkRGBPixel.h"
29#include "itkRGBAPixel.h"
31#include "ITKDenoisingExport.h"
32
33namespace itk
34{
40{
41public:
46 enum class NoiseModel : uint8_t
47 {
48 NOMODEL = 0,
49 GAUSSIAN = 1,
50 RICIAN = 2,
51 POISSON = 3
52 };
53
60 enum class ComponentSpace : uint8_t
61 {
62 EUCLIDEAN = 0,
63 RIEMANNIAN = 1
64 };
65
70 enum class FilterState : uint8_t
71 {
72 UNINITIALIZED = 0,
73 INITIALIZED = 1
74 };
75};
76// Define how to print enumeration
77extern ITKDenoising_EXPORT std::ostream &
79extern ITKDenoising_EXPORT std::ostream &
81// Define how to print enumeration
82extern ITKDenoising_EXPORT std::ostream &
144template <typename TInputImage, typename TOutputImage>
145class ITK_TEMPLATE_EXPORT PatchBasedDenoisingBaseImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
146{
147public:
148 ITK_DISALLOW_COPY_AND_MOVE(PatchBasedDenoisingBaseImageFilter);
149
155
157 itkOverrideGetNameOfClassMacro(PatchBasedDenoisingBaseImageFilter);
158
160 using InputImageType = TInputImage;
161 using OutputImageType = TOutputImage;
162
164 static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
165
169 using InputPixelType = typename InputImageType::PixelType;
170 using OutputPixelType = typename OutputImageType::PixelType;
173
177#if !defined(ITK_LEGACY_REMOVE)
182 static constexpr NoiseModelEnum NOMODEL = NoiseModelEnum::NOMODEL;
183 static constexpr NoiseModelEnum GAUSSIAN = NoiseModelEnum::GAUSSIAN;
184 static constexpr NoiseModelEnum RICIAN = NoiseModelEnum::RICIAN;
185 static constexpr NoiseModelEnum POISSON = NoiseModelEnum::POISSON;
186
187 static constexpr ComponentSpaceEnum EUCLIDEAN = ComponentSpaceEnum::EUCLIDEAN;
188 static constexpr ComponentSpaceEnum RIEMANNIAN = ComponentSpaceEnum::RIEMANNIAN;
189
190 static constexpr FilterStateEnum UNINITIALIZED = FilterStateEnum::UNINITIALIZED;
191 static constexpr FilterStateEnum INITIALIZED = FilterStateEnum::INITIALIZED;
192#endif
193
198
205 using PatchRadiusType = typename ListAdaptorType::NeighborhoodRadiusType;
207
213 itkSetMacro(PatchRadius, unsigned int);
214 itkGetConstMacro(PatchRadius, unsigned int);
219
222
225
230 void
232
235
240 itkSetEnumMacro(NoiseModel, NoiseModelEnum);
241 itkGetConstMacro(NoiseModel, NoiseModelEnum);
249 itkSetClampMacro(SmoothingWeight, double, 0.0, 1.0);
250 itkGetConstMacro(SmoothingWeight, double);
258 itkSetClampMacro(NoiseModelFidelityWeight, double, 0.0, 1.0);
259 itkGetConstMacro(NoiseModelFidelityWeight, double);
266 itkSetMacro(KernelBandwidthEstimation, bool);
267 itkBooleanMacro(KernelBandwidthEstimation);
268 itkGetConstMacro(KernelBandwidthEstimation, bool);
277 itkSetClampMacro(KernelBandwidthUpdateFrequency, unsigned int, 1, NumericTraits<unsigned int>::max());
278 itkGetConstMacro(KernelBandwidthUpdateFrequency, unsigned int);
285 itkSetClampMacro(NumberOfIterations, unsigned int, 1, NumericTraits<unsigned int>::max());
286 itkGetConstReferenceMacro(NumberOfIterations, unsigned int);
290 itkGetConstReferenceMacro(ElapsedIterations, unsigned int);
291
296 itkSetMacro(AlwaysTreatComponentsAsEuclidean, bool);
297 itkBooleanMacro(AlwaysTreatComponentsAsEuclidean);
298 itkGetConstMacro(AlwaysTreatComponentsAsEuclidean, bool);
302 virtual void
304
306 virtual void
308
310#if !defined(ITK_WRAPPING_PARSER)
311 itkSetEnumMacro(State, FilterStateEnum);
312 itkGetConstReferenceMacro(State, FilterStateEnum);
313#endif
320 itkSetMacro(ManualReinitialization, bool);
321 itkGetConstReferenceMacro(ManualReinitialization, bool);
322 itkBooleanMacro(ManualReinitialization);
325protected:
328
329 void
330 PrintSelf(std::ostream & os, Indent indent) const override;
331
332 void
334
335 void
336 GenerateData() override;
337
338 virtual void
340
342 virtual void
344
345 virtual void
347 {}
348
350 virtual void
352
353 virtual void
355 {}
356
357 virtual void
359 {}
360
362 virtual void
364
366 virtual void
368
369 virtual void
371
372 virtual void
374 {}
375
377 virtual bool
379
380 virtual bool
381 ThreadedHalt(void * itkNotUsed(threadInfo))
382 {
383 return this->Halt();
384 }
385
386 itkSetMacro(ElapsedIterations, unsigned int);
387
391 {
392 return ComponentSpaceEnum::EUCLIDEAN;
393 }
394
395 ComponentSpaceEnum
397 {
398 return ComponentSpaceEnum::EUCLIDEAN;
399 }
400
401 ComponentSpaceEnum
403 {
404 return ComponentSpaceEnum::RIEMANNIAN;
405 }
406
407 template <typename PixelT>
408 ComponentSpaceEnum
409 DetermineComponentSpace(const PixelT & itkNotUsed(p))
410 {
411 return ComponentSpaceEnum::EUCLIDEAN;
412 }
413
415 itkSetEnumMacro(ComponentSpace, ComponentSpaceEnum);
416 itkGetConstMacro(ComponentSpace, ComponentSpaceEnum);
419 // Cache input and output pointer to get rid of thousands of calls
420 // to GetInput and GetOutput.
421 const InputImageType * m_InputImage{};
422 OutputImageType * m_OutputImage{};
423
424private:
426 unsigned int m_PatchRadius{ 4 };
427 PatchWeightsType m_PatchWeights{};
428
430 bool m_KernelBandwidthEstimation{ false };
431 unsigned int m_KernelBandwidthUpdateFrequency{ 3 };
432
435 unsigned int m_NumberOfIterations{ 1 };
436 unsigned int m_ElapsedIterations{ 0 };
437
439 NoiseModelEnum m_NoiseModel{ NoiseModelEnum::NOMODEL };
440 double m_SmoothingWeight{ 1.0 };
441 double m_NoiseModelFidelityWeight{ 0.0 };
442
445 bool m_AlwaysTreatComponentsAsEuclidean{ false };
446 ComponentSpaceEnum m_ComponentSpace{ ComponentSpaceEnum::EUCLIDEAN };
447
448 bool m_ManualReinitialization{ false };
449
450 FilterStateEnum m_State{ FilterStateEnum::UNINITIALIZED };
451};
452} // end namespace itk
453
454#ifndef ITK_MANUAL_INSTANTIATION
455# include "itkPatchBasedDenoisingBaseImageFilter.hxx"
456#endif
457
458#endif
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Represent a diffusion tensor as used in DTI images.
Base class for all process objects that output image data.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Define additional traits for native types such as int or float.
Contains all enum classes used by the PatchBasedDenoisingBaseImageFilter class.
Base class for patch-based denoising algorithms.
typename NumericTraits< PixelType >::ValueType PixelValueType
void PrintSelf(std::ostream &os, Indent indent) const override
PatchWeightsType GetPatchWeights() const
ComponentSpaceEnum DetermineComponentSpace(const RGBPixel< PixelValueType > &)
typename ListAdaptorType::NeighborhoodRadiusType PatchRadiusType
typename itk::Statistics::ImageToNeighborhoodSampleAdaptor< OutputImageType, BoundaryConditionType > ListAdaptorType
~PatchBasedDenoisingBaseImageFilter() override=default
PatchRadiusType GetPatchDiameterInVoxels() const
ComponentSpaceEnum DetermineComponentSpace(const RGBAPixel< PixelValueType > &)
PatchRadiusType::SizeValueType GetPatchLengthInVoxels() const
void SetPatchWeights(const PatchWeightsType &weights)
ComponentSpaceEnum DetermineComponentSpace(const DiffusionTensor3D< PixelValueType > &)
PatchRadiusType GetPatchRadiusInVoxels() const
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Represent Red, Green, Blue and Alpha components for color images.
Definition: itkRGBAPixel.h:60
Represent Red, Green and Blue components for color images.
Definition: itkRGBPixel.h:59
This class provides ListSample interface to ITK Image.
A function object that determines a neighborhood of values at an image boundary according to a Neuman...
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
unsigned long SizeValueType
Definition: itkIntTypes.h:86