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?
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;