/usr/include/InsightToolkit/Common/itkMahalanobisDistanceThresholdImageFunction.txx is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkMahalanobisDistanceThresholdImageFunction.txx
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkMahalanobisDistanceThresholdImageFunction_txx
#define __itkMahalanobisDistanceThresholdImageFunction_txx
#include "itkMahalanobisDistanceThresholdImageFunction.h"
namespace itk
{
template <class TInputImage, class TCoordRep>
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::MahalanobisDistanceThresholdImageFunction()
{
m_Threshold = NumericTraits<double>::Zero;
m_MahalanobisDistanceMembershipFunction =
MahalanobisDistanceFunctionType::New();
}
template <class TInputImage, class TCoordRep>
void
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::SetMean(const MeanVectorType & mean)
{
m_MahalanobisDistanceMembershipFunction->SetMean( mean );
}
template <class TInputImage, class TCoordRep>
void
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::SetCovariance(const CovarianceMatrixType & covariance)
{
m_MahalanobisDistanceMembershipFunction->SetCovariance( covariance );
}
template <class TInputImage, class TCoordRep>
const typename
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>::MeanVectorType &
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::GetMean() const
{
return m_MahalanobisDistanceMembershipFunction->GetMean();
}
template <class TInputImage, class TCoordRep>
const typename
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>::CovarianceMatrixType &
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::GetCovariance() const
{
return m_MahalanobisDistanceMembershipFunction->GetCovariance();
}
template <class TInputImage, class TCoordRep>
bool
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::Evaluate( const PointType& point ) const
{
IndexType index;
this->ConvertPointToNearestIndex( point, index );
return ( this->EvaluateAtIndex( index ) );
}
template <class TInputImage, class TCoordRep>
bool
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::EvaluateAtContinuousIndex( const ContinuousIndexType & index ) const
{
IndexType nindex;
this->ConvertContinuousIndexToNearestIndex (index, nindex);
return this->EvaluateAtIndex(nindex);
}
template <class TInputImage, class TCoordRep>
bool
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::EvaluateAtIndex( const IndexType & index ) const
{
double mahalanobisDistance = this->EvaluateDistanceAtIndex( index );
return ( mahalanobisDistance <= m_Threshold );
}
template <class TInputImage, class TCoordRep>
double
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::EvaluateDistance( const PointType& point ) const
{
IndexType index;
this->ConvertPointToNearestIndex( point, index );
const double mahalanobisDistance = this->EvaluateDistanceAtIndex( index );
return mahalanobisDistance;
}
template <class TInputImage, class TCoordRep>
double
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::EvaluateDistanceAtIndex( const IndexType& index ) const
{
double mahalanobisDistanceSquared =
m_MahalanobisDistanceMembershipFunction->Evaluate(
this->GetInputImage()->GetPixel( index ) );
double mahalanobisDistance;
// Deal with cases that are barely negative.
// In theory they should never appear, but
// they may happen and would produce NaNs
// in the vcl_sqrt
if( mahalanobisDistanceSquared < 0.0 )
{
mahalanobisDistance = 0.0;
}
else
{
mahalanobisDistance = vcl_sqrt( mahalanobisDistanceSquared );
}
return mahalanobisDistance;
}
template <class TInputImage, class TCoordRep>
void
MahalanobisDistanceThresholdImageFunction<TInputImage,TCoordRep>
::PrintSelf(std::ostream& os, Indent indent) const
{
Superclass::PrintSelf( os, indent );
os << indent << "Threshold: " << m_Threshold << std::endl;
os << indent << "MahalanobisDistanceMembershipFunction: " << m_MahalanobisDistanceMembershipFunction << std::endl;
}
} // end namespace itk
#endif
|