// ========================================================================= // @author Leonardo Florez Valencia // @email florez-l@javeriana.edu.co // ========================================================================= #ifndef __fpa__Image__Skeleton__hxx__ #define __fpa__Image__Skeleton__hxx__ // ------------------------------------------------------------------------- template< unsigned int _VDim > void fpa::Image::Skeleton< _VDim >:: AddBranch( TPath* path ) { // Check inputs if( path == NULL ) return; unsigned long size = path->GetSize( ); if( size == 0 ) return; TIndex a = path->GetVertex( 0 ); TIndex b = path->GetVertex( size - 1 ); if( this->HasEdge( a, b ) ) return; // Add path this->SetVertex( a, a ); this->SetVertex( b, b ); this->AddEdge( a, b, path ); this->AddEdge( b, a, path ); this->Modified( ); } // ------------------------------------------------------------------------- template< unsigned int _VDim > const typename fpa::Image::Skeleton< _VDim >:: TPath* fpa::Image::Skeleton< _VDim >:: GetBranch( const TIndex& a, const TIndex& b ) const { static const TPath* null_path = NULL; if( this->HasEdge( a, b ) ) return( this->GetEdges( a, b ).front( ) ); else return( null_path ); } // ------------------------------------------------------------------------- template< unsigned int _VDim > std::vector< typename fpa::Image::Skeleton< _VDim >::TIndex > fpa::Image::Skeleton< _VDim >:: GetEndPoints( ) const { std::vector< TIndex > res; typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( ); for( ; mIt != this->EndEdgesRows( ); ++mIt ) { unsigned long count = mIt->second.size( ); if( count == 1 ) res.push_back( mIt->first ); } // rof return( res ); } // ------------------------------------------------------------------------- template< unsigned int _VDim > std::vector< typename fpa::Image::Skeleton< _VDim >::TIndex > fpa::Image::Skeleton< _VDim >:: GetBifurcations( ) const { std::vector< TIndex > res; typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( ); for( ; mIt != this->EndEdgesRows( ); ++mIt ) { unsigned long count = mIt->second.size( ); if( count > 1 ) res.push_back( mIt->first ); } // rof return( res ); } // ------------------------------------------------------------------------- template< unsigned int _VDim > fpa::Image::Skeleton< _VDim >:: Skeleton( ) : Superclass( ) { } // ------------------------------------------------------------------------- template< unsigned int _VDim > fpa::Image::Skeleton< _VDim >:: ~Skeleton( ) { } #endif // __fpa__Image__Skeleton__hxx__ // eof - $RCSfile$