template< class I, class O >
fpa::Image::DijkstraWithEndPointDetection< I, O >::
DijkstraWithEndPointDetection( )
- : Superclass( )
+ : Superclass( ),
+ m_CorrectSeeds( true ),
+ m_CorrectEndPoints( true ),
+ m_SafetyNeighborhoodSize( 3 )
{
this->m_LabelImageIndex = this->GetNumberOfRequiredOutputs( );
this->m_EndPointsIndex = this->m_LabelImageIndex + 1;
void fpa::Image::DijkstraWithEndPointDetection< I, O >::
_BeforeGenerateData( )
{
- const I* input = this->GetInput( );
- typename I::SpacingType spac = input->GetSpacing( );
- double max_spac = double( spac[ 0 ] );
- for( unsigned int d = 1; d < I::ImageDimension; ++d )
- max_spac =
- ( double( spac[ d ] ) > max_spac )? double( spac[ d ] ): max_spac;
- max_spac *= double( 3 );
-
- // Correct seeds
- for( unsigned int s = 0; s < this->m_SeedVertices.size( ); ++s )
+ if( this->m_CorrectSeeds )
{
- TVertex seed = this->m_SeedVertices[ s ];
- _TNode n = this->m_Seeds[ seed ];
- _TRegion region = this->_Region( seed, max_spac );
- itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region );
-
- iIt.GoToBegin( );
- _TPixel max_value = iIt.Get( );
- for( ++iIt; !iIt.IsAtEnd( ); ++iIt )
+ const I* input = this->GetInput( );
+ typename I::SpacingType spac = input->GetSpacing( );
+ double max_spac = double( spac[ 0 ] );
+ for( unsigned int d = 1; d < I::ImageDimension; ++d )
+ max_spac =
+ ( double( spac[ d ] ) > max_spac )? double( spac[ d ] ): max_spac;
+ max_spac *= double( 3 );
+
+ // Correct seeds
+ for( unsigned int s = 0; s < this->m_SeedVertices.size( ); ++s )
{
- if( iIt.Get( ) > max_value )
+ TVertex seed = this->m_SeedVertices[ s ];
+ _TNode n = this->m_Seeds[ seed ];
+ _TRegion region = this->_Region( seed, max_spac );
+ itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region );
+
+ iIt.GoToBegin( );
+ _TPixel max_value = iIt.Get( );
+ for( ++iIt; !iIt.IsAtEnd( ); ++iIt )
{
- this->m_SeedVertices[ s ] = iIt.GetIndex( );
- max_value = iIt.Get( );
+ if( iIt.Get( ) > max_value )
+ {
+ this->m_SeedVertices[ s ] = iIt.GetIndex( );
+ max_value = iIt.Get( );
- } // fi
+ } // fi
+
+ } // rof
+ this->m_Seeds.erase( seed );
+ n.Parent = this->m_SeedVertices[ s ];
+ this->m_Seeds[ this->m_SeedVertices[ s ] ] = n;
} // rof
- this->m_Seeds.erase( seed );
- n.Parent = this->m_SeedVertices[ s ];
- this->m_Seeds[ this->m_SeedVertices[ s ] ] = n;
- } // rof
+ } // fi
// End initialization
this->Superclass::_BeforeGenerateData( );
// Correct it to nearest start candidate (high distance value)
double vr = std::sqrt( double( input->GetPixel( v ) ) );
- v = this->_MaxInRegion( input, v, vr * double( 1.5 ) );
+ if( this->m_CorrectEndPoints )
+ v = this->_MaxInRegion( input, v, vr * double( 1.5 ) );
// Now, check for real marking conditions
// 1. Has it been visited by dijkstra?
// Configure and obtain inputs
const I* input = this->GetInput( );
const TMinimumSpanningTree* mst = this->GetMinimumSpanningTree( );
+ const TUniqueVertices* bifurcations = this->GetBifurcations( );
TBranches* branches = this->GetBranches( );
TLabelImage* label = this->GetLabelImage( );
label->FillBuffer( 0 );
this->m_NumberOfBranches = actual_label;
// Label bifurcations
- /* TODO: Is this necessary?
- typename TUniqueVertices::const_iterator bifIt =
- this->m_Bifurcations.begin( );
- for( ; bifIt != this->m_Bifurcations.end( ); ++bifIt )
- {
- actual_label++;
- double d = std::sqrt( double( input->GetPixel( *bifIt ) ) );
- _TRegion region = this->_Region( *bifIt, d );
- itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region );
- itk::ImageRegionIteratorWithIndex< TLabelImage > lIt( label, region );
- iIt.GoToBegin( );
- lIt.GoToBegin( );
- for( ; !iIt.IsAtEnd( ); ++iIt, ++lIt )
- {
- // Mask real input image
- if( !( iIt.Get( ) < ( typename I::PixelType )( 0 ) ) )
- lIt.Set( actual_label );
-
- } // rof
-
- } // rof
- */
+ typename TUniqueVertices::ConstIterator bifIt =
+ bifurcations->Begin( );
+ for( ; bifIt != bifurcations->End( ); ++bifIt )
+ {
+ actual_label++;
+ double d = std::sqrt( double( input->GetPixel( *bifIt ) ) );
+ _TRegion region = this->_Region( *bifIt, d * 1.5 );
+ itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region );
+ itk::ImageRegionIteratorWithIndex< TLabelImage > lIt( label, region );
+ iIt.GoToBegin( );
+ lIt.GoToBegin( );
+ for( ; !iIt.IsAtEnd( ); ++iIt, ++lIt )
+ {
+ // Mask real input image
+ if( !( iIt.Get( ) < ( typename I::PixelType )( 0 ) ) )
+ lIt.Set( actual_label );
+
+ } // rof
+
+ } // rof
}
// -------------------------------------------------------------------------
for( unsigned int d = 0; d < I::ImageDimension; ++d )
{
// NOTE: 3 is a minimum neighborhood size
- long s = long( std::ceil( r / double( spac[ d ] ) ) ) + 3;
+ long s =
+ long( std::ceil( r / double( spac[ d ] ) ) ) +
+ long( this->m_SafetyNeighborhoodSize );
i0[ d ] = c[ d ] - s;
i1[ d ] = c[ d ] + s;