filter->ThrowEventsOn( );
// Go!
- std::clock_t start = std::clock( );
+ std::time_t start, end;
+ std::time( &start );
filter->Update( );
- std::clock_t end = std::clock( );
+ std::time( &end );
std::cout
<< "Extraction time = "
- << ( double( end - start ) / double( CLOCKS_PER_SEC ) )
+ << std::difftime( end, start )
<< " s." << std::endl;
/* TODO
dmap->SquaredDistanceOn( );
dmap->UseImageSpacingOn( );
- std::clock_t start = std::clock( );
+ std::time_t start, end;
+ std::time( &start );
dmap->Update( );
- std::clock_t end = std::clock( );
+ std::time( &end );
std::cout
<< "Distance map time = "
- << ( double( end - start ) / double( CLOCKS_PER_SEC ) )
+ << std::difftime( end, start )
<< " s." << std::endl;
output = dmap->GetOutput( );
#define __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__HXX__
#include <vector>
+#include <set>
#include <itkImageRegionConstIteratorWithIndex.h>
// -------------------------------------------------------------------------
label->FillBuffer( 0 );
// Prepare an object to hold marks
+ std::set< TVertex, TVertexCompare > tree_marks;
/* TODO
typename TMarkImage::Pointer marks = this->GetOutputMarkImage( );
marks->FillBuffer( 0 );
std::map< TLabel, std::pair< TVertex, TVertex > > branches;
for( ; cIt != this->m_Candidates.rend( ); ++cIt )
{
- // If pixel hasn't been visited, continue
+ // If pixel has been already labelled, pass
TVertex v = cIt->second;
if( label->GetPixel( v ) != 0 )
continue;
} // rof
- // Keep endpoint
+ // Re-check labelling
if( label->GetPixel( max_vertex ) != 0 )
continue;
this->m_EndPoints.push_back( max_vertex );
);
if( start )
{
- TLabel lbl = label->GetPixel( *pIt );
- if( lbl == 0 || lbl == this->m_NumberOfBranches )
+ if( tree_marks.find( *pIt ) == tree_marks.end( ) )
{
+ tree_marks.insert( *pIt );
+
// Mark a sphere around current point as visited
double dist = std::sqrt( double( input->GetPixel( *pIt ) ) );
- region = this->_Region( max_vertex, dist * double( 1.1 ) );
+ region = this->_Region( max_vertex, dist * double( 1.5 ) );
itk::ImageRegionIteratorWithIndex< TLabelImage >
lIt( label, region );
for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
- {
- if( lIt.Get( ) == 0 )
- lIt.Set( this->m_NumberOfBranches );
-
- } // rof
+ lIt.Set( this->m_NumberOfBranches );
// Next vertex in current path
// TODO: this->InvokeEvent( TBacktrackingEvent( max_vertex, this->m_NumberOfBranches ) );
/*
this->m_FullTree[ max_vertex ] =
TTreeNode( this->_Parent( max_vertex ), this->m_NumberOfBranches );
- std::cout << "New: " << this->m_NumberOfBranches << std::endl;
*/
}
else
{
// A bifurcation point has been reached!
branches[ this->m_NumberOfBranches ] = std::pair< TVertex, TVertex >( last_start, *pIt );
- std::cout << "bif " << this->m_NumberOfBranches << std::endl;
last_start = *pIt;
this->m_BifurcationPoints.push_back( *pIt );
this->m_NumberOfBranches++;
{
// Mark a sphere around current point as visited
double dist = std::sqrt( double( input->GetPixel( max_vertex ) ) );
- region = this->_Region( max_vertex, dist * double( 1.1 ) );
+ region = this->_Region( max_vertex, dist * double( 1.5 ) );
itk::ImageRegionIteratorWithIndex< TLabelImage >
lIt( label, region );
for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt )
TTreeNode( this->_Parent( max_vertex ), this->m_NumberOfBranches );
*/
change = true;
- // std::cout << "Change: " << this->m_NumberOfBranches << std::endl;
}
else
{
// A bifurcation point has been reached!
// TODO: this->m_BifurcationPoints.push_back( max_vertex );
branches[ this->m_NumberOfBranches ] = std::pair< TVertex, TVertex >( last_start, *pIt );
- std::cout << "change " << this->m_NumberOfBranches << std::endl;
last_start = *pIt;
this->m_NumberOfBranches++;
this->m_FullTree[ max_vertex ] =
TTreeNode( this->_Parent( max_vertex ), this->m_NumberOfBranches );
*/
- // std::cout << "Change bifurcation: " << this->m_NumberOfBranches << std::endl;
} // fi
} // rof
- std::cout << this->m_NumberOfBranches << " " << branches.size( ) << std::endl;
- std::cout << this->m_EndPoints.size( ) << " " << this->m_BifurcationPoints.size( ) << std::endl;
-
-
// Re-enumerate labels
- /*
std::map< TLabel, unsigned long > histo;
for(
- typename TTree::iterator treeIt = this->m_FullTree.begin( );
- treeIt != this->m_FullTree.end( );
+ typename std::set< TVertex, TVertexCompare >::iterator treeIt = tree_marks.begin( );
+ treeIt != tree_marks.end( );
++treeIt
)
- histo[ treeIt->second.second ]++;
+ histo[ label->GetPixel( *treeIt ) ]++;
+
+ for(
+ typename std::map< TLabel, unsigned long >::iterator hIt = histo.begin( );
+ hIt != histo.end( );
+ ++hIt
+ )
+ std::cout << hIt->first << " " << hIt->second << std::endl;
+ /*
std::map< TMark, TMark > changes;
TMark last_change = 1;
for( TMark i = 1; i <= this->m_NumberOfBranches; ++i )