18 #ifndef itkPatchBasedDenoisingImageFilter_h
19 #define itkPatchBasedDenoisingImageFilter_h
60 template <
typename TInputImage,
typename TOutputImage>
84 itkStaticConstMacro(ImageDimension,
unsigned int,
85 Superclass::ImageDimension);
145 itkSetMacro(UseSmoothDiscPatchWeights,
bool);
146 itkBooleanMacro(UseSmoothDiscPatchWeights);
147 itkGetConstMacro(UseSmoothDiscPatchWeights,
bool);
154 void SetKernelBandwidthSigma(
const RealArrayType& kernelSigma);
162 itkSetClampMacro(KernelBandwidthFractionPixelsForEstimation,
double, 0.01, 1.0);
163 itkGetConstReferenceMacro(KernelBandwidthFractionPixelsForEstimation,
double);
168 itkSetMacro(ComputeConditionalDerivatives,
bool);
169 itkBooleanMacro(ComputeConditionalDerivatives);
170 itkGetConstMacro(ComputeConditionalDerivatives,
bool);
186 itkSetMacro(UseFastTensorComputations,
bool);
187 itkBooleanMacro(UseFastTensorComputations);
188 itkGetConstMacro(UseFastTensorComputations,
bool);
192 itkStaticConstMacro(MaxSigmaUpdateIterations,
unsigned int,
201 itkSetClampMacro(KernelBandwidthMultiplicationFactor,
double, 0.01, 100);
202 itkGetConstReferenceMacro(KernelBandwidthMultiplicationFactor,
double);
208 void SetNoiseSigma(
const RealType& sigma);
210 itkGetConstMacro(NoiseSigma,
RealType);
218 itkGetConstMacro(NumIndependentComponents,
unsigned int);
223 virtual
void PrintSelf(std::ostream& os,
Indent indent) const ITK_OVERRIDE;
226 virtual
void EmptyCaches();
229 virtual
void AllocateUpdateBuffer() ITK_OVERRIDE;
231 virtual
void CopyInputToOutput() ITK_OVERRIDE;
233 virtual
void GenerateInputRequestedRegion() ITK_OVERRIDE;
241 template< typename T>
245 GetComponent(const T pix,
246 unsigned int itkNotUsed( idx ) )
const
257 template<
typename T>
259 IsSame<T, typename NumericTraits<T>::ValueType>::Value,
262 unsigned int idx )
const
268 template<
typename T >
271 unsigned int itkNotUsed( idx ),
272 typename EnableIfC< IsSame<T,
278 template<
typename T >
294 if( this->GetComponentSpace() == Superclass::RIEMANNIAN )
296 DispatchedRiemannianMinMax(img);
300 DispatchedArrayMinMax(img);
304 template<
typename TImageType>
306 IsSame<typename TImageType::PixelType, typename NumericTraits<typename TImageType::PixelType>::ValueType>::Value
310 DispatchedMinMax(img);
313 template<
typename TImageType>
315 IsSame<typename TImageType::PixelType, typename NumericTraits<typename TImageType::PixelType>::ValueType>::Value
319 DispatchedArrayMinMax(img);
333 bool useCachedComputations,
339 if( this->GetComponentSpace() == Superclass::RIEMANNIAN )
341 ComputeLogMapAndWeightedSquaredGeodesicDifference(a, b, weight,
342 useCachedComputations, cacheIndex,
343 eigenValsCache, eigenVecsCache,
348 ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(a, b, weight,
349 useCachedComputations, cacheIndex,
350 eigenValsCache, eigenVecsCache,
356 template <
typename PixelT>
360 bool useCachedComputations,
366 ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(a, b, weight,
367 useCachedComputations, cacheIndex,
368 eigenValsCache, eigenVecsCache,
378 if( this->GetComponentSpace() == Superclass::RIEMANNIAN )
380 return this->AddExponentialMapUpdate(a, b);
384 return this->AddEuclideanUpdate(a, b);
389 template <
typename RealT>
393 return this->AddEuclideanUpdate(a, b);
396 virtual void EnforceConstraints();
398 virtual void Initialize() ITK_OVERRIDE;
400 virtual
void InitializeKernelSigma();
402 virtual
void InitializePatchWeights() ITK_OVERRIDE;
404 virtual
void InitializePatchWeightsSmoothDisc();
406 virtual
void InitializeIteration() ITK_OVERRIDE;
408 virtual
void ComputeKernelBandwidthUpdate() ITK_OVERRIDE;
412 virtual ThreadDataStruct ThreadedComputeSigmaUpdate(const InputImageRegionType& regionToProcess,
413 const
int itkNotUsed(threadId),
414 ThreadDataStruct threadData);
416 virtual RealArrayType ResolveSigmaUpdate();
418 virtual
void ComputeImageUpdate() ITK_OVERRIDE;
420 virtual ThreadDataStruct ThreadedComputeImageUpdate(const InputImageRegionType& regionToProcess,
422 ThreadDataStruct threadData);
424 virtual RealType ComputeGradientJointEntropy(InstanceIdentifier
id,
425 typename ListAdaptorType::Pointer& inList,
426 BaseSamplerPointer& sampler,
427 ThreadDataStruct& threadData);
429 virtual
void ApplyUpdate() ITK_OVERRIDE;
431 virtual
void ThreadedApplyUpdate(const InputImageRegionType& regionToProcess,
432 const
int itkNotUsed(threadId) );
434 virtual
void PostProcessOutput() ITK_OVERRIDE;
436 virtual
void SetThreadData(
int threadId, const ThreadDataStruct& data);
438 virtual ThreadDataStruct GetThreadData(
int threadId);
455 template <typename TInputImageType>
456 void DispatchedMinMax(const TInputImageType* img);
458 template <typename TInputImageType>
459 void DispatchedArrayMinMax(const TInputImageType* img);
461 template <typename TInputImageType>
462 void DispatchedVectorMinMax(const TInputImageType* img);
464 template <typename TInputImageType>
465 void DispatchedRiemannianMinMax(const TInputImageType* img);
471 ThreadDataStruct ThreadedRiemannianMinMax(const InputImageRegionType& regionToProcess,
472 const
int itkNotUsed(threadId),
473 const InputImageType* img,
474 ThreadDataStruct threadData);
476 virtual
void ResolveRiemannianMinMax();
478 void ComputeSignedEuclideanDifferenceAndWeightedSquaredNorm(const PixelType& a, const PixelType& b,
479 const RealArrayType& weight,
480 bool useCachedComputations,
482 EigenValuesCacheType& eigenValsCache,
483 EigenVectorsCacheType& eigenVecsCache,
484 RealType& diff, RealArrayType& norm);
487 void ComputeLogMapAndWeightedSquaredGeodesicDifference(const
DiffusionTensor3D<PixelValueType>& spdMatrixA,
489 const RealArrayType& weight,
490 bool useCachedComputations,
492 EigenValuesCacheType& eigenValsCache,
493 EigenVectorsCacheType& eigenVecsCache,
494 RealType& symMatrixLogMap, RealArrayType& geodesicDist);
496 template <typename TensorValueT>
499 Matrix< TensorValueT, 3, 3 >& eigenVecs);
501 RealType AddEuclideanUpdate(const RealType& a, const RealType& b);
504 RealType AddExponentialMapUpdate(const
DiffusionTensor3D<RealValueType>& spdMatrix,
550 #ifndef ITK_MANUAL_INSTANTIATION
551 #include "itkPatchBasedDenoisingImageFilter.hxx"
ListAdaptorType::Pointer m_SearchSpaceList
unsigned int m_TotalNumberPixels
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
BaseSamplerPointer m_Sampler
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)
OutputImageType::Pointer m_UpdateBuffer
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
RealArrayType m_IntensityRescaleInvFactor
bool m_UseFastTensorComputations
double m_KernelBandwidthMultiplicationFactor
double m_SigmaUpdateConvergenceTolerance
std::vector< EigenVectorsMatrixType > EigenVectorsCacheType
Superclass::PixelValueType PixelValueType
TInputImage InputImageType
Base class for all process objects that output image data.
unsigned long SizeValueType
EigenValuesCacheType eigenValsCache
RealArrayType m_KernelBandwidthSigma
#define ITK_THREAD_RETURN_TYPE
unsigned int m_NumIndependentComponents
Superclass::PatchWeightsType PatchWeightsType
Simulate a standard C array with copy semnatics.
Superclass::PixelType PixelType
OutputPixelType PixelType
PixelArrayType m_ImageMin
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
bool m_ComputeConditionalDerivatives
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.
RealType m_NoiseSigmaSquared
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
std::vector< ThreadDataStruct > m_ThreadData
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
ImageRegionIterator< OutputImageType > OutputImageRegionIteratorType
ShortArrayType validNorms
bool m_KernelBandwidthSigmaIsSet
NumericTraits< PixelValueType >::RealType RealValueType
ImageRegionConstIterator< InputImageType > InputImageRegionConstIteratorType
Control indentation during Print() invocation.
PatchBasedDenoisingImageFilter Self
ListAdaptorType PatchSampleType
ShortArrayType m_SigmaConverged
InputImageType::RegionType InputImageRegionType
unsigned int m_NumPixelComponents
Define additional traits for native types such as int or float.
PixelArrayType m_ImageMax
EnableIfC< IsSame< typename TImageType::PixelType, typename NumericTraits< typename TImageType::PixelType >::ValueType >::Value >::Type ComputeMinMax(const TImageType *img)
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)
bool m_UseSmoothDiscPatchWeights
Represent a diffusion tensor as used in DTI images.
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
unsigned int m_SigmaUpdateDecimationFactor
double m_KernelBandwidthFractionPixelsForEstimation
RealType AddUpdate(const RealT &a, const RealType &b)