From 463b1ec45c70ca63aa9f19f8cb58ae5d5134e56b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 30 Nov 2017 18:28:17 -0500 Subject: [PATCH] ... --- appli/CTBronchi/Process.sh | 15 ++- appli/CTBronchi/Skeleton.cxx | 8 +- lib/fpa/Filters/Image/ExtractSkeleton.hxx | 149 +++++++++++----------- 3 files changed, 93 insertions(+), 79 deletions(-) diff --git a/appli/CTBronchi/Process.sh b/appli/CTBronchi/Process.sh index 5f42202..aa98891 100755 --- a/appli/CTBronchi/Process.sh +++ b/appli/CTBronchi/Process.sh @@ -2,7 +2,7 @@ ## -- Command line options curr_dir=`dirname $0` -ext="mhd" +ext="mha" vesselness_sigma="0.5" vesselness_alpha1="0.5" vesselness_alpha2="2" @@ -122,7 +122,8 @@ fastrw=$base_name"_fastrw.$ext" slicerw=$base_name"_slicerw.$ext" skeleton_fastrw=$base_name"_fastrw_skeleton.txt" skeleton_slicerw=$base_name"_slicerw_skeleton.txt" -points=$base_name"_points.txt" +fastrw_points=$base_name"_fastrw_points.txt" +slicerw_points=$base_name"_slicerw_points.txt" echo "************************************************" (>&2 echo "Processing $input... ") @@ -182,9 +183,17 @@ if [ ! -f $skeleton_slicerw ] || [ -n "$force" ] ; then $curr_dir/fpa_CTBronchi_Skeleton \ -i $slicerw \ -o $skeleton_slicerw \ - -e $points \ + -e $slicerw_points \ -p "$seed" fi + +# if [ ! -f $skeleton_fastrw ] || [ -n "$force" ] ; then +# $curr_dir/fpa_CTBronchi_Skeleton \ +# -i $fastrw \ +# -o $skeleton_fastrw \ +# -e $fastrw_points \ +# -p "$seed" +# fi (>&2 echo "done.") echo "done." echo "************************************************" diff --git a/appli/CTBronchi/Skeleton.cxx b/appli/CTBronchi/Skeleton.cxx index 4110825..aa1bd37 100644 --- a/appli/CTBronchi/Skeleton.cxx +++ b/appli/CTBronchi/Skeleton.cxx @@ -88,12 +88,12 @@ int main( int argc, char* argv[] ) { std::stringstream eStr; auto pnts = filter->GetEndPoints( ); - for( unsigned int i = 0; i < 10; ++i ) + for( auto pnt: pnts ) { eStr - << pnts[ i ][ 0 ] << " " - << pnts[ i ][ 1 ] << " " - << pnts[ i ][ 2 ] << " " << i % 3 << std::endl; + << pnt[ 0 ] << " " + << pnt[ 1 ] << " " + << pnt[ 2 ] << std::endl; } // rof std::ofstream oStrE( oute.getValue( ).c_str( ) ); diff --git a/lib/fpa/Filters/Image/ExtractSkeleton.hxx b/lib/fpa/Filters/Image/ExtractSkeleton.hxx index 5904cd4..9d2dec0 100644 --- a/lib/fpa/Filters/Image/ExtractSkeleton.hxx +++ b/lib/fpa/Filters/Image/ExtractSkeleton.hxx @@ -159,6 +159,9 @@ GenerateData( ) } // fi + std::cout << int( this->GetInput( )->GetPixel( this->m_Seed ) ) << std::endl; + std::cout << this->m_DistanceMap->GetOutput( )->GetPixel( this->m_Seed ) << std::endl; + // Compute MST typename _TDijkstra::Pointer dijkstra = _TDijkstra::New( ); dijkstra->SetInput( this->m_DistanceMap->GetOutput( ) ); @@ -175,78 +178,80 @@ GenerateData( ) this->m_EndPoints = end_points; // Compute symbolic branches - typedef std::map< TIndex, TIndex, typename TIndex::LexicographicCompare > _TTags; - _TTags tags, branches; - typename std::vector< TIndex >::const_iterator eIt = end_points.begin( ); - for( ; eIt != end_points.end( ); ++eIt ) - { - // Tag path - TIndex it = *eIt; - TIndex p = mst->GetParent( it ); - typename _TTags::iterator bIt = tags.end( ); - while( it != p && bIt == tags.end( ) ) - { - typename _TTags::iterator tIt = tags.find( it ); - if( tIt != tags.end( ) ) - { - // Ok, a bifurcation point has been found - // branch1: tIt->second <-> it (ok) - branches[ tIt->second ] = it; - - // branch2: *eit <-> it (ok) - branches[ *eIt ] = it; - - // branch3: it <-> until next bifurcation - bIt = tIt; - } - else - tags[ it ] = *eIt; - it = p; - p = mst->GetParent( it ); - - } // elihw - if( bIt != tags.end( ) ) - { - TIndex pTag = bIt->second; - TIndex nTag = bIt->first; - it = bIt->first; - p = it; - while( tags[ it ] == pTag ) - { - tags[ it ] = nTag; - p = it; - it = mst->GetParent( it ); - - } // elihw - tags[ it ] = nTag; - branches[ bIt->first ] = p; - } - else - { - tags[ it ] = *eIt; - branches[ *eIt ] = it; - - } // fi - - } // rof - - // Fill full branches - typedef typename _TMST::TVertices _TVertices; - typedef typename TSkeleton::TPath _TPath; - - TSkeleton* sk = this->GetOutput( ); - typename _TTags::const_iterator bIt = branches.begin( ); - for( ; bIt != branches.end( ); ++bIt ) - { - _TVertices v = mst->GetAxis( bIt->first, bIt->second ); - typename _TPath::Pointer path = _TPath::New( ); - path->SetReferenceImage( this->GetInput( ) ); - typename _TVertices::const_reverse_iterator vIt = v.rbegin( ); - for( ; vIt != v.rend( ); ++vIt ) - path->AddVertex( *vIt ); - sk->AddBranch( path ); - - } // rof + /* TODO + typedef std::map< TIndex, TIndex, typename TIndex::LexicographicCompare > _TTags; + _TTags tags, branches; + typename std::vector< TIndex >::const_iterator eIt = end_points.begin( ); + for( ; eIt != end_points.end( ); ++eIt ) + { + // Tag path + TIndex it = *eIt; + TIndex p = mst->GetParent( it ); + typename _TTags::iterator bIt = tags.end( ); + while( it != p && bIt == tags.end( ) ) + { + typename _TTags::iterator tIt = tags.find( it ); + if( tIt != tags.end( ) ) + { + // Ok, a bifurcation point has been found + // branch1: tIt->second <-> it (ok) + branches[ tIt->second ] = it; + + // branch2: *eit <-> it (ok) + branches[ *eIt ] = it; + + // branch3: it <-> until next bifurcation + bIt = tIt; + } + else + tags[ it ] = *eIt; + it = p; + p = mst->GetParent( it ); + + } // elihw + if( bIt != tags.end( ) ) + { + TIndex pTag = bIt->second; + TIndex nTag = bIt->first; + it = bIt->first; + p = it; + while( tags[ it ] == pTag ) + { + tags[ it ] = nTag; + p = it; + it = mst->GetParent( it ); + + } // elihw + tags[ it ] = nTag; + branches[ bIt->first ] = p; + } + else + { + tags[ it ] = *eIt; + branches[ *eIt ] = it; + + } // fi + + } // rof + + // Fill full branches + typedef typename _TMST::TVertices _TVertices; + typedef typename TSkeleton::TPath _TPath; + + TSkeleton* sk = this->GetOutput( ); + typename _TTags::const_iterator bIt = branches.begin( ); + for( ; bIt != branches.end( ); ++bIt ) + { + _TVertices v = mst->GetAxis( bIt->first, bIt->second ); + typename _TPath::Pointer path = _TPath::New( ); + path->SetReferenceImage( this->GetInput( ) ); + typename _TVertices::const_reverse_iterator vIt = v.rbegin( ); + for( ; vIt != v.rend( ); ++vIt ) + path->AddVertex( *vIt ); + sk->AddBranch( path ); + + } // rof + */ } // ------------------------------------------------------------------------- -- 2.47.1