X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FDataStructures%2FImage%2FSkeleton.hxx;fp=lib%2Ffpa%2FDataStructures%2FImage%2FSkeleton.hxx;h=c3316da357501a55042f9f922557b39f177aaeea;hb=2047276c8f1a02432fbcc7014722d460d6c1e60f;hp=0000000000000000000000000000000000000000;hpb=3c639e5da479c7216a0a302ffa156ac6762caeed;p=FrontAlgorithms.git diff --git a/lib/fpa/DataStructures/Image/Skeleton.hxx b/lib/fpa/DataStructures/Image/Skeleton.hxx new file mode 100644 index 0000000..c3316da --- /dev/null +++ b/lib/fpa/DataStructures/Image/Skeleton.hxx @@ -0,0 +1,98 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __fpa__DataStructures__Image__Skeleton__hxx__ +#define __fpa__DataStructures__Image__Skeleton__hxx__ + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void fpa::DataStructures::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::DataStructures::Image::Skeleton< _VDim >:: +TPath* fpa::DataStructures::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::DataStructures::Image::Skeleton< _VDim >::TIndex > +fpa::DataStructures::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::DataStructures::Image::Skeleton< _VDim >::TIndex > +fpa::DataStructures::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::DataStructures::Image::Skeleton< _VDim >:: +Skeleton( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +fpa::DataStructures::Image::Skeleton< _VDim >:: +~Skeleton( ) +{ +} + +#endif // __fpa__DataStructures__Image__Skeleton__hxx__ + +// eof - $RCSfile$