18 #ifndef itkPatchBasedDenoisingImageFilter_h
19 #define itkPatchBasedDenoisingImageFilter_h
60 template <
typename TInputImage,
typename TOutputImage>
83 itkStaticConstMacro(ImageDimension,
unsigned int,
84 Superclass::ImageDimension);
144 itkSetMacro(UseSmoothDiscPatchWeights,
bool);
145 itkBooleanMacro(UseSmoothDiscPatchWeights);
146 itkGetConstMacro(UseSmoothDiscPatchWeights,
bool);
153 void SetKernelBandwidthSigma(
const RealArrayType& kernelSigma);
161 itkSetClampMacro(KernelBandwidthFractionPixelsForEstimation,
double, 0.01, 1.0);
162 itkGetConstReferenceMacro(KernelBandwidthFractionPixelsForEstimation,
double);
167 itkSetMacro(ComputeConditionalDerivatives,
bool);
168 itkBooleanMacro(ComputeConditionalDerivatives);
169 itkGetConstMacro(ComputeConditionalDerivatives,
bool);
185 itkSetMacro(UseFastTensorComputations,
bool);
186 itkBooleanMacro(UseFastTensorComputations);
187 itkGetConstMacro(UseFastTensorComputations,
bool);
191 itkStaticConstMacro(MaxSigmaUpdateIterations,
unsigned int,
200 itkSetClampMacro(KernelBandwidthMultiplicationFactor,
double, 0.01, 100);
201 itkGetConstReferenceMacro(KernelBandwidthMultiplicationFactor,
double);
207 void SetNoiseSigma(
const RealType& sigma);
209 itkGetConstMacro(NoiseSigma,
RealType);
219 virtual void PrintSelf(std::ostream& os,
Indent indent)
const ITK_OVERRIDE;
222 virtual void EmptyCaches();
225 virtual void AllocateUpdateBuffer() ITK_OVERRIDE;
227 virtual
void CopyInputToOutput() ITK_OVERRIDE;
229 virtual
void GenerateInputRequestedRegion() ITK_OVERRIDE;
237 template< typename T>
241 GetComponent(const T pix,
242 unsigned int itkNotUsed( idx ) )
const
253 template<
typename T>
255 IsSame<T, typename NumericTraits<T>::ValueType>::Value,
258 unsigned int idx )
const
264 template<
typename T >
267 unsigned int itkNotUsed( idx ),
268 typename EnableIfC< IsSame<T,
274 template<
typename T >
290 if (this->m_ComponentSpace == Superclass::RIEMANNIAN)
292 DispatchedRiemannianMinMax(img);
296 DispatchedArrayMinMax(img);
300 template<
typename TImageType>
302 IsSame<typename TImageType::PixelType, typename NumericTraits<typename TImageType::PixelType>::ValueType>::Value
306 DispatchedMinMax(img);
309 template<
typename TImageType>
311 IsSame<typename TImageType::PixelType, typename NumericTraits<typename TImageType::PixelType>::ValueType>::Value
315 DispatchedArrayMinMax(img);
329 bool useCachedComputations,
335 if (this->m_ComponentSpace == Superclass::RIEMANNIAN)
337 ComputeLogMapAndWeightedSquaredGeodesicDifference(a, b, weight,
338 useCachedComputations, cacheIndex,
339 eigenValsCache, eigenVecsCache,
344 ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(a, b, weight,
345 useCachedComputations, cacheIndex,
346 eigenValsCache, eigenVecsCache,
352 template <
typename PixelT>
356 bool useCachedComputations,
362 ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(a, b, weight,
363 useCachedComputations, cacheIndex,
364 eigenValsCache, eigenVecsCache,
374 if (this->m_ComponentSpace == Superclass::RIEMANNIAN)
376 return this->AddExponentialMapUpdate(a, b);
380 return this->AddEuclideanUpdate(a, b);
385 template <
typename RealT>
389 return this->AddEuclideanUpdate(a, b);
392 virtual void EnforceConstraints();
394 virtual void Initialize() ITK_OVERRIDE;
396 virtual
void InitializeKernelSigma();
398 virtual
void InitializePatchWeights() ITK_OVERRIDE;
400 virtual
void InitializePatchWeightsSmoothDisc();
402 virtual
void InitializeIteration() ITK_OVERRIDE;
404 virtual
void ComputeKernelBandwidthUpdate() ITK_OVERRIDE;
408 virtual ThreadDataStruct ThreadedComputeSigmaUpdate(const InputImageRegionType& regionToProcess,
409 const
int itkNotUsed(threadId),
410 ThreadDataStruct threadData);
412 virtual RealArrayType ResolveSigmaUpdate();
414 virtual
void ComputeImageUpdate() ITK_OVERRIDE;
416 virtual ThreadDataStruct ThreadedComputeImageUpdate(const InputImageRegionType& regionToProcess,
418 ThreadDataStruct threadData);
420 virtual RealType ComputeGradientJointEntropy(InstanceIdentifier
id,
421 typename ListAdaptorType::Pointer& inList,
422 BaseSamplerPointer& sampler,
423 ThreadDataStruct& threadData);
425 virtual
void ApplyUpdate() ITK_OVERRIDE;
427 virtual
void ThreadedApplyUpdate(const InputImageRegionType& regionToProcess,
428 const
int itkNotUsed(threadId) );
430 virtual
void PostProcessOutput() ITK_OVERRIDE;
432 virtual
void SetThreadData(
int threadId, const ThreadDataStruct& data);
434 virtual ThreadDataStruct GetThreadData(
int threadId);
441 unsigned int m_NumPixelComponents;
442 unsigned int m_NumIndependentComponents;
443 unsigned int m_TotalNumberPixels;
445 bool m_UseSmoothDiscPatchWeights;
447 bool m_UseFastTensorComputations;
450 bool m_KernelBandwidthSigmaIsSet;
455 double m_KernelBandwidthFractionPixelsForEstimation;
456 bool m_ComputeConditionalDerivatives;
458 double m_MinProbability;
459 unsigned int m_SigmaUpdateDecimationFactor;
460 double m_SigmaUpdateConvergenceTolerance;
462 double m_KernelBandwidthMultiplicationFactor;
466 bool m_NoiseSigmaIsSet;
486 template <typename TInputImageType>
487 void DispatchedMinMax(const TInputImageType* img);
489 template <typename TInputImageType>
490 void DispatchedArrayMinMax(const TInputImageType* img);
492 template <typename TInputImageType>
493 void DispatchedVectorMinMax(const TInputImageType* img);
495 template <typename TInputImageType>
496 void DispatchedRiemannianMinMax(const TInputImageType* img);
503 const
int itkNotUsed(threadId),
507 virtual
void ResolveRiemannianMinMax();
509 void ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(const
PixelType& a, const
PixelType& b,
511 bool useCachedComputations,
521 bool useCachedComputations,
527 template <typename TensorValueT>
530 Matrix< TensorValueT, 3, 3 >& eigenVecs);
548 #ifndef ITK_MANUAL_INSTANTIATION
549 # include "itkPatchBasedDenoisingImageFilter.hxx"
A templated class holding a M x N size Matrix.
Derived class implementing a specific patch-based denoising algorithm, as detailed below...
PatchBasedDenoisingImageFilter * Filter
Array< RealValueType > RealArrayType
BaseSamplerType::InstanceIdentifier InstanceIdentifier
Superclass::OutputImageType OutputImageType
RealArrayType entropyFirstDerivative
BaseSamplerType::Pointer BaseSamplerPointer
void ComputeDifferenceAndWeightedSquaredNorm(const PixelT &a, const PixelT &b, const RealArrayType &weight, bool useCachedComputations, SizeValueType cacheIndex, EigenValuesCacheType &eigenValsCache, EigenVectorsCacheType &eigenVecsCache, RealType &diff, RealArrayType &norm)
Superclass::InputImagePatchIterator InputImagePatchIterator
Base class for patch-based denoising algorithms.
DisableIfC< IsSame< T, typename NumericTraits< T >::ValueType >::Value, typename NumericTraits< T >::ValueType >::Type GetComponent(const T &pix, unsigned int idx) const
std::vector< EigenVectorsMatrixType > EigenVectorsCacheType
Superclass::PixelValueType PixelValueType
TInputImage InputImageType
Base class for all process objects that output image data.
unsigned long SizeValueType
EigenValuesCacheType eigenValsCache
#define ITK_THREAD_RETURN_TYPE
Superclass::PatchWeightsType PatchWeightsType
Simulate a standard C array with copy semnatics.
Superclass::PixelType PixelType
OutputPixelType PixelType
std::vector< EigenValuesArrayType > EigenValuesCacheType
PatchBasedDenoisingBaseImageFilter< TInputImage, TOutputImage > Superclass
TOutputImage OutputImageType
RealType AddUpdate(const DiffusionTensor3D< RealValueType > &a, const RealType &b)
typename::itk::Statistics::ImageToNeighborhoodSampleAdaptor< OutputImageType, BoundaryConditionType > ListAdaptorType
Superclass::OutputImagePointer OutputImagePointer
Array< unsigned short > ShortArrayType
EigenVectorsCacheType eigenVecsCache
TSample::InstanceIdentifier InstanceIdentifier
Superclass::PatchRadiusType PatchRadiusType
void ComputeMinMax(const Image< DiffusionTensor3D< PixelValueType >, ImageDimension > *img)
InputImageType::RegionType InputImageRegionType
This an abstract subsampler that constrains subsamples to be contained within a given image region...
A multi-dimensional iterator templated over image type that walks a region of pixels.
TInputImage InputImageType
void SetComponent(T &pix, unsigned int, typename EnableIfC< IsSame< T, typename NumericTraits< T >::ValueType >::Value, RealValueType >::Type val) const
A method to generically set a component.
SmartPointer< const Self > ConstPointer
ShortArrayType validDerivatives
SmartPointer< Self > Pointer
Array< PixelValueType > PixelArrayType
BaseSamplerPointer sampler
Superclass::ListAdaptorType ListAdaptorType
Superclass::InputImageType InputImageType
FixedArray< PixelValueType, 3 > EigenValuesArrayType
Matrix< PixelValueType, 3, 3 > EigenVectorsMatrixType
void SetComponent(T &pix, unsigned int idx, typename DisableIfC< IsSame< T, typename NumericTraits< T >::ValueType >::Value, RealValueType >::Type val) const
RealArrayType entropySecondDerivative
NumericTraits< PixelType >::RealType RealType
Base class for filters that take an image as input and produce an image as output.
ImageRegionIterator< OutputImageType > OutputImageRegionIteratorType
ShortArrayType validNorms
NumericTraits< PixelValueType >::RealType RealValueType
ImageRegionConstIterator< InputImageType > InputImageRegionConstIteratorType
Control indentation during Print() invocation.
PatchBasedDenoisingImageFilter Self
ListAdaptorType PatchSampleType
InputImageType::RegionType InputImageRegionType
Define additional traits for native types such as int or float.
EnableIfC< IsSame< typename TImageType::PixelType, typename NumericTraits< typename TImageType::PixelType >::ValueType >::Value >::Type ComputeMinMax(const TImageType *img)
TOutputImage OutputImageType
DisableIfC< IsSame< typename TImageType::PixelType, typename NumericTraits< typename TImageType::PixelType >::ValueType >::Value >::Type ComputeMinMax(const TImageType *img)
void ComputeDifferenceAndWeightedSquaredNorm(const DiffusionTensor3D< PixelValueType > &a, const DiffusionTensor3D< PixelValueType > &b, const RealArrayType &weight, bool useCachedComputations, SizeValueType cacheIndex, EigenValuesCacheType &eigenValsCache, EigenVectorsCacheType &eigenVecsCache, RealType &diff, RealArrayType &norm)
Represent a diffusion tensor as used in DTI images.
NumericTraits< PixelType >::ValueType PixelValueType
An implementation of the negation of the enable if idiom.
Templated n-dimensional image class.
A multi-dimensional iterator templated over image type that walks a region of pixels.
itk::Statistics::RegionConstrainedSubsampler< PatchSampleType, InputImageRegionType > BaseSamplerType
RealType AddUpdate(const RealT &a, const RealType &b)