#ifndef itkTopologicalNumberImageFunction_txx #define itkTopologicalNumberImageFunction_txx #include #include "itkTopologicalNumberImageFunction.h" namespace itk { template TopologicalNumberImageFunction ::TopologicalNumberImageFunction() : m_ComputeForegroundTN(true), m_ComputeBackgroundTN(true) { } template std::pair TopologicalNumberImageFunction ::Evaluate(PointType const & point) const { typename TImage::IndexType index; ConvertPointToNearestIndex(point, index); return EvaluateAtIndex(index); } template std::pair TopologicalNumberImageFunction ::EvaluateAtIndex(IndexType const & index) const { unsigned int const imageSize = TFGConnectivity::GetInstance().GetNeighborhoodSize(); char* subImage = new char[imageSize]; // Get the sub-image for(unsigned int i=0; i offset; // Get current offset for(unsigned int j=0; jGetInputImage()->GetPixel(index+offset)!= itk::NumericTraits::Zero)? 255:0; } unsigned int const middle = imageSize/2; subImage[middle] = 0; // Topological number in the foreground m_ForegroundUnitCubeCCCounter.SetImage(subImage, subImage+imageSize); unsigned int const ccNumber = m_ComputeForegroundTN ? m_ForegroundUnitCubeCCCounter() : 0; // Invert the sub-image for(int bit = 0; bit(ccNumber, backgroundCcNumber); } template std::pair TopologicalNumberImageFunction ::EvaluateAtContinuousIndex(ContinuousIndexType const & contIndex) const { typename TImage::IndexType index; ConvertContinuousIndexToNearestIndex(contIndex, index); return EvaluateAtIndex(index); } template UnitCubeCCCounter< TFGConnectivity > TopologicalNumberImageFunction ::m_ForegroundUnitCubeCCCounter = UnitCubeCCCounter< TFGConnectivity >(); template UnitCubeCCCounter< TBGConnectivity > TopologicalNumberImageFunction ::m_BackgroundUnitCubeCCCounter = UnitCubeCCCounter< TBGConnectivity >(); } #endif // itkTopologicalNumberImageFunction_txx