7 template <
class ImageType,
class DataImageType>
8 NonLocalMeansPatchSearcher <ImageType, DataImageType>
11 m_BetaParameter = 1.0;
12 m_NoiseCovariance = 1.0;
14 m_MeanMinThreshold = 0.95;
15 m_VarMinThreshold = 0.5;
18 template <
class ImageType,
class DataImageType>
21 ::TestPatchConformity(
unsigned int index,
const IndexType &refIndex,
const IndexType &movingIndex)
23 double refMeanValue = m_MeanImage->GetPixel(refIndex);
24 double floMeanValue = m_MeanImage->GetPixel(movingIndex);
26 double refVarValue = m_VarImage->GetPixel(refIndex);
27 double floVarValue = m_VarImage->GetPixel(movingIndex);
29 double meanRate = refMeanValue / floMeanValue;
30 double varianceRate = refVarValue / floVarValue;
33 if ( ( meanRate > m_MeanMinThreshold ) && ( meanRate < ( 1.0 / m_MeanMinThreshold ) ) &&
34 ( varianceRate > m_VarMinThreshold ) && ( varianceRate < ( 1.0 / m_VarMinThreshold ) ) )
40 template <
class ImageType,
class DataImageType>
45 typedef itk::ImageRegionConstIteratorWithIndex< ImageType > InIteratorType;
47 InIteratorType tmpIt (this->GetInputImage(), refPatch);
48 InIteratorType tmpMovingIt (this->GetComparisonImage(index), movingPatch);
52 double weightValue = 0.0;
53 unsigned int numVoxels = 0;
55 while (!tmpIt.IsAtEnd())
57 tmpDiffValue = (double)tmpIt.Get() - (double)tmpMovingIt.Get();
58 weightValue += tmpDiffValue * tmpDiffValue;
65 weightValue = std::exp(- weightValue / (2.0 * m_BetaParameter * m_NoiseCovariance * numVoxels));
Superclass::IndexType IndexType
Superclass::ImageRegionType ImageRegionType