]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/SkeletonFilter.hxx
...
[FrontAlgorithms.git] / lib / fpa / Image / SkeletonFilter.hxx
index d8dc66a1f0841216b02c7ddeeeba8ee941a5ddac..bf63d8971b463daa5071f5b30bc472629228b5b8 100644 (file)
@@ -132,7 +132,6 @@ _EndPoints( std::vector< TIndex >& end_points, _TAdjacencies& A )
       continue;
     marks->SetPixel( n.second, 1 );
     end_points.push_back( n.second );
-    std::cout << this->m_SkeletonQueue.size( ) << std::endl;
 
     // Mark path
     TIndex it = n.second;
@@ -155,71 +154,67 @@ template< class _TImage >
 void fpa::Image::SkeletonFilter< _TImage >::
 _Skeleton( const std::vector< TIndex >& end_points, _TAdjacencies& A )
 {
-  std::cout << end_points.size( ) << " " << A.size( ) << std::endl;
-
-  /* TODO
-     typedef itk::Image< unsigned long, Self::Dimension > _TTagsImage;
-     typedef typename TMST::TPath _TPath;
-
-     auto mst = this->GetMinimumSpanningTree( );
-     auto skeleton = this->GetSkeleton( );
-
-     // Tag branches
-     typename _TTagsImage::Pointer tags = _TTagsImage::New( );
-     tags->SetLargestPossibleRegion( mst->GetLargestPossibleRegion( ) );
-     tags->SetRequestedRegion( mst->GetRequestedRegion( ) );
-     tags->SetBufferedRegion( mst->GetBufferedRegion( ) );
-     tags->Allocate( );
-     tags->FillBuffer( 0 );
-     for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
-     {
-     TIndex it = *eIt;
-     TIndex p = mst->GetParent( it );
-     while( it != p )
-     {
-     tags->SetPixel( it, tags->GetPixel( it ) + 1 );
-     it = p;
-     p = mst->GetParent( it );
-
-     } // elihw
-     tags->SetPixel( it, tags->GetPixel( it ) + 1 );
-
-     } // rof
-
-     // Build paths (branches)
-     for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
-     {
-     TIndex it = *eIt;
-     TIndex p = mst->GetParent( it );
-     TIndex sIdx = *eIt;
-     typename _TPath::Pointer path = _TPath::New( );
-     path->SetReferenceImage( mst );
-     while( it != p )
-     {
-     if( tags->GetPixel( sIdx ) != tags->GetPixel( it ) )
-     {
-     // Ok, a new branch has been added
-     path->AddVertex( it );
-     skeleton->AddBranch( path );
-
-     // Update a new starting index
-     path = _TPath::New( );
-     path->SetReferenceImage( mst );
-     sIdx = it;
-     }
-     else
-     path->AddVertex( it );
-     it = p;
-     p = mst->GetParent( it );
-
-     } // elihw
-
-     // Finally, add last branch
-     path->AddVertex( it );
-     skeleton->AddBranch( path );
-
-     } // rof
-  */
+  typedef itk::Image< unsigned long, Self::Dimension > _TTagsImage;
+  typedef typename TMST::TPath _TPath;
+
+  auto mst = this->GetMinimumSpanningTree( );
+  auto skeleton = this->GetSkeleton( );
+
+  // Tag branches
+  typename _TTagsImage::Pointer tags = _TTagsImage::New( );
+  tags->SetLargestPossibleRegion( mst->GetLargestPossibleRegion( ) );
+  tags->SetRequestedRegion( mst->GetRequestedRegion( ) );
+  tags->SetBufferedRegion( mst->GetBufferedRegion( ) );
+  tags->Allocate( );
+  tags->FillBuffer( 0 );
+  for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
+  {
+    TIndex it = *eIt;
+    TIndex p = mst->GetParent( it );
+    while( it != p )
+    {
+      tags->SetPixel( it, tags->GetPixel( it ) + 1 );
+      it = p;
+      p = mst->GetParent( it );
+
+    } // elihw
+    tags->SetPixel( it, tags->GetPixel( it ) + 1 );
+
+  } // rof
+
+  // Build paths (branches)
+  for( auto eIt = end_points.begin( ); eIt != end_points.end( ); ++eIt )
+  {
+    TIndex it = *eIt;
+    TIndex p = mst->GetParent( it );
+    TIndex sIdx = *eIt;
+    typename _TPath::Pointer path = _TPath::New( );
+    path->SetReferenceImage( mst );
+    while( it != p )
+    {
+      if( tags->GetPixel( sIdx ) != tags->GetPixel( it ) )
+      {
+        // Ok, a new branch has been added
+        path->AddVertex( it );
+        skeleton->AddBranch( path );
+
+        // Update a new starting index
+        path = _TPath::New( );
+        path->SetReferenceImage( mst );
+        sIdx = it;
+      }
+      else
+        path->AddVertex( it );
+      it = p;
+      p = mst->GetParent( it );
+
+    } // elihw
+
+    // Finally, add last branch
+    path->AddVertex( it );
+    skeleton->AddBranch( path );
+
+  } // rof
 }
 
 // -------------------------------------------------------------------------