#ifndef TopologicalNumberFunction_txx #define TopologicalNumberFunction_txx #include 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 { char subImage[TFGConnectivity::GetInstance().GetNeighborhoodSize()]; // 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; } subImage[13] = 0; // Topological number in the foreground m_ForegroundUnitCubeCCCounter.SetImage(subImage, subImage+TFGConnectivity::GetInstance().GetNeighborhoodSize()); unsigned int const ccNumber = m_ComputeForegroundTN ? m_ForegroundUnitCubeCCCounter() : 0; // Invert the sub-image for(int bit = 0; bit<13; ++bit) { subImage[bit] = 255 - subImage[bit]; } for(int bit=13; bit<26; ++bit) { subImage[bit+1] = 255 - subImage[bit+1]; } // Topological number in the background m_BackgroundUnitCubeCCCounter.SetImage(subImage, subImage+TBGConnectivity::GetInstance().GetNeighborhoodSize()); assert(TFGConnectivity::GetInstance().GetNeighborsPoints()); unsigned int const backgroundCcNumber = m_ComputeBackgroundTN ? m_BackgroundUnitCubeCCCounter() : 0; return std::pair(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 // TopologicalNumberFunction_txx