From: Leonardo Florez-Valencia Date: Thu, 9 Apr 2015 00:33:30 +0000 (-0500) Subject: Some more tests X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=5e326afe442245572b6c3ec98ebeec8b45f9012f;p=FrontAlgorithms.git Some more tests --- diff --git a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx b/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx index 47585ad..b2d3e7c 100644 --- a/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx +++ b/appli/examples/example_Image_Dijkstra_EndPointDetection.cxx @@ -20,26 +20,11 @@ #include #include -/* - #include - #include - #include - #include - - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #include -*/ +#include +#include +#include +#include +#include // ------------------------------------------------------------------------- const unsigned int Dim = 3; @@ -54,6 +39,9 @@ typedef itk::ImageToVTKImageFilter< TImage > TVTKInputImage; template< class I > void ReadImage( typename I::Pointer& image, const std::string& filename ); +template< class I > +void SaveImage( const I* image, const std::string& filename ); + template< class I, class O > void DistanceMap( const typename I::Pointer& input, typename O::Pointer& output @@ -62,16 +50,19 @@ void DistanceMap( // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { - if( argc < 2 ) + if( argc < 5 ) { std::cerr << "Usage: " << argv[ 0 ] - << " input_image" + << " input_image distancemap output_costmap output_labels" << std::endl; return( 1 ); } // fi std::string input_image_fn = argv[ 1 ]; + std::string distancemap_fn = argv[ 2 ]; + std::string output_costmap_fn = argv[ 3 ]; + std::string output_labels_fn = argv[ 4 ]; // Read image TImage::Pointer input_image; @@ -88,6 +79,7 @@ int main( int argc, char* argv[] ) return( 1 ); } // yrt + TVTKInputImage::Pointer vtk_input_image = TVTKInputImage::New( ); vtk_input_image->SetInput( input_image ); vtk_input_image->Update( ); @@ -98,6 +90,13 @@ int main( int argc, char* argv[] ) view.SetSize( 800, 800 ); view.SetImage( vtk_input_image->GetOutput( ) ); + vtkSmartPointer< vtkImageMarchingCubes > mc = + vtkSmartPointer< vtkImageMarchingCubes >::New( ); + mc->SetInputData( vtk_input_image->GetOutput( ) ); + mc->SetValue( 0, 1e-1 ); + mc->Update( ); + view.AddPolyData( mc->GetOutput( ), 1, 1, 1, 0.4 ); + // Allow some interaction and wait for, at least, one seed view.Render( ); while( view.GetNumberOfSeeds( ) == 0 ) @@ -148,25 +147,142 @@ int main( int argc, char* argv[] ) << std::difftime( end, start ) << " s." << std::endl; - /* TODO - // Save final total cost map - itk::ImageFileWriter< TOutputImage >::Pointer output_image_writer = - itk::ImageFileWriter< TOutputImage >::New( ); - output_image_writer->SetFileName( output_image_fn ); - output_image_writer->SetInput( filter->GetOutput( ) ); - try + // Minimum spanning tree + const TFilter::TMinimumSpanningTree* mst = + filter->GetMinimumSpanningTree( ); + + // Build branches from endpoints to seed + vtkSmartPointer< vtkPoints > endpoints_points = + vtkSmartPointer< vtkPoints >::New( ); + vtkSmartPointer< vtkCellArray > endpoints_cells = + vtkSmartPointer< vtkCellArray >::New( ); + vtkSmartPointer< vtkCellArray > endpoints_vertices = + vtkSmartPointer< vtkCellArray >::New( ); + + const TFilter::TUniqueVertices& endpoints = filter->GetEndPoints( ); + TFilter::TUniqueVertices::const_iterator eIt = endpoints.begin( ); + for( ; eIt != endpoints.end( ); ++eIt ) { - output_image_writer->Update( ); - } - catch( itk::ExceptionObject& err ) + TFilter::TVertices path; + mst->GetPath( path, *eIt, filter->GetSeed( 0 ) ); + + std::cout << *eIt << std::endl; + TFilter::TVertices::const_iterator pIt = path.begin( ); + for( ; pIt != path.end( ); ++pIt ) + { + TImage::PointType pnt; + input_image->TransformIndexToPhysicalPoint( *pIt, pnt ); + endpoints_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); + + if( pIt != path.begin( ) ) + { + endpoints_cells->InsertNextCell( 2 ); + endpoints_cells->InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 2 ); + endpoints_cells->InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 1 ); + } + else + { + std::cout << "ok" << std::endl; + endpoints_vertices->InsertNextCell( 1 ); + endpoints_vertices->InsertCellPoint( endpoints_points->GetNumberOfPoints( ) - 1 ); + + } // fi + + + + + } // rof + + } // rof + std::cout << endpoints.size( ) << std::endl; + + vtkSmartPointer< vtkPolyData > endpoints_polydata = + vtkSmartPointer< vtkPolyData >::New( ); + endpoints_polydata->SetPoints( endpoints_points ); + endpoints_polydata->SetLines( endpoints_cells ); + endpoints_polydata->SetVerts( endpoints_vertices ); + + + + + + + + + + + + // Bifurcations + vtkSmartPointer< vtkPoints > bifurcations_points = + vtkSmartPointer< vtkPoints >::New( ); + vtkSmartPointer< vtkCellArray > bifurcations_vertices = + vtkSmartPointer< vtkCellArray >::New( ); + + const TFilter::TUniqueVertices& bifurcations = filter->GetBifurcationPoints( ); + TFilter::TUniqueVertices::const_iterator bIt = bifurcations.begin( ); + for( ; bIt != bifurcations.end( ); ++bIt ) { - std::cerr - << "Error while writing image to " << output_image_fn << ": " - << err << std::endl; - return( 1 ); + std::cout << *bIt << std::endl; - } // yrt - */ + TImage::PointType pnt; + input_image->TransformIndexToPhysicalPoint( *bIt, pnt ); + bifurcations_points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] ); + bifurcations_vertices->InsertNextCell( 1 ); + bifurcations_vertices->InsertCellPoint( bifurcations_points->GetNumberOfPoints( ) - 1 ); + + } // rof + + vtkSmartPointer< vtkPolyData > bifurcations_polydata = + vtkSmartPointer< vtkPolyData >::New( ); + bifurcations_polydata->SetPoints( bifurcations_points ); + bifurcations_polydata->SetVerts( bifurcations_vertices ); + + + + + + // Build branches from endpoints to seed + vtkSmartPointer< vtkPoints > branches_points = + vtkSmartPointer< vtkPoints >::New( ); + vtkSmartPointer< vtkCellArray > branches_cells = + vtkSmartPointer< vtkCellArray >::New( ); + + const TFilter::TBranches& branches = filter->GetBranches( ); + TFilter::TBranches::const_iterator brIt = branches.begin( ); + for( ; brIt != branches.end( ); ++brIt ) + { + TFilter::TBranch::const_iterator brsIt = brIt->second.begin( ); + for( ; brsIt != brIt->second.end( ); ++brsIt ) + { + TImage::PointType pnt0, pnt1; + input_image->TransformIndexToPhysicalPoint( brIt->first, pnt0 ); + input_image->TransformIndexToPhysicalPoint( brsIt->first, pnt1 ); + branches_points->InsertNextPoint( pnt0[ 0 ], pnt0[ 1 ], pnt0[ 2 ] ); + branches_points->InsertNextPoint( pnt1[ 0 ], pnt1[ 1 ], pnt1[ 2 ] ); + + branches_cells->InsertNextCell( 2 ); + branches_cells->InsertCellPoint( branches_points->GetNumberOfPoints( ) - 2 ); + branches_cells->InsertCellPoint( branches_points->GetNumberOfPoints( ) - 1 ); + + } // rof + + } // rof + + vtkSmartPointer< vtkPolyData > branches_polydata = + vtkSmartPointer< vtkPolyData >::New( ); + branches_polydata->SetPoints( branches_points ); + branches_polydata->SetLines( branches_cells ); + + view.AddPolyData( endpoints_polydata, 1, 0, 0, 1 ); + view.AddPolyData( bifurcations_polydata, 0, 0, 1, 1 ); + view.AddPolyData( branches_polydata, 0, 1, 0, 1 ); + view.Render( ); + view.Start( ); + + // Save final total cost map + SaveImage( filter->GetOutput( ), output_costmap_fn ); + SaveImage( dmap.GetPointer( ), distancemap_fn ); + SaveImage( filter->GetLabelImage( ), output_labels_fn ); return( 0 ); } @@ -197,6 +313,27 @@ void ReadImage( typename I::Pointer& image, const std::string& filename ) image->DisconnectPipeline( ); } +// ------------------------------------------------------------------------- +template< class I > +void SaveImage( const I* image, const std::string& filename ) +{ + typename itk::ImageFileWriter< I >::Pointer writer = + itk::ImageFileWriter< I >::New( ); + writer->SetInput( image ); + writer->SetFileName( filename ); + try + { + writer->Update( ); + } + catch( itk::ExceptionObject& err ) + { + std::cerr + << "Error saving \"" << filename << "\": " << err + << std::endl; + + } // yrt +} + // ------------------------------------------------------------------------- template< class I, class O > void DistanceMap( @@ -225,3 +362,13 @@ void DistanceMap( } // eof - $RCSfile$ + + + + + + + + + + diff --git a/lib/fpa/Base/MinimumSpanningTree.hxx b/lib/fpa/Base/MinimumSpanningTree.hxx index d932247..6c9c790 100644 --- a/lib/fpa/Base/MinimumSpanningTree.hxx +++ b/lib/fpa/Base/MinimumSpanningTree.hxx @@ -90,7 +90,6 @@ GetPath( std::vector< V >& path, const V& a, const V& b ) const } // elihw if( raIt != ap.rbegin( ) ) --raIt; - if( rbIt != bp.rbegin( ) ) --rbIt; // Add part from a typename std::vector< V >::const_iterator iaIt = ap.begin( ); diff --git a/lib/fpa/Image/Dijkstra.hxx b/lib/fpa/Image/Dijkstra.hxx index eca6ce3..4f7b60b 100644 --- a/lib/fpa/Image/Dijkstra.hxx +++ b/lib/fpa/Image/Dijkstra.hxx @@ -51,7 +51,7 @@ void fpa::Image::Dijkstra< I, O >:: _InitResults( ) { this->Superclass::_InitResults( ); - this->GetOutput( )->FillBuffer( std::numeric_limits< TResult >::max( ) ); + this->GetOutput( )->FillBuffer( TResult( 0 ) ); } #endif // __FPA__IMAGE__DIJKSTRA__HXX__ diff --git a/lib/fpa/Image/DijkstraWithEndPointDetection.h b/lib/fpa/Image/DijkstraWithEndPointDetection.h index 881b8f8..c63f4f1 100644 --- a/lib/fpa/Image/DijkstraWithEndPointDetection.h +++ b/lib/fpa/Image/DijkstraWithEndPointDetection.h @@ -1,6 +1,7 @@ #ifndef __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__ #define __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__H__ +#include #include #include @@ -40,13 +41,20 @@ namespace fpa typedef typename Superclass::TFrontEvent TFrontEvent; typedef typename Superclass::TFreezeEvent TFreezeEvent; - typedef typename Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; - typedef typename Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; - typedef typename Superclass::TBacktrackingEvent TBacktrackingEvent; + typedef typename + Superclass::TStartBacktrackingEvent TStartBacktrackingEvent; + typedef typename + Superclass::TEndBacktrackingEvent TEndBacktrackingEvent; + typedef typename + Superclass::TBacktrackingEvent TBacktrackingEvent; typedef unsigned short TLabel; typedef itk::Image< TLabel, I::ImageDimension > TLabelImage; + typedef std::set< TVertex, TVertexCompare > TUniqueVertices; + typedef std::map< TVertex, TLabel, TVertexCompare > TBranch; + typedef std::map< TVertex, TBranch, TVertexCompare > TBranches; + protected: typedef typename Superclass::_TVertices _TVertices; typedef typename Superclass::_TCollision _TCollision; @@ -66,9 +74,10 @@ namespace fpa itkNewMacro( Self ); itkTypeMacro( DijkstraWithEndPointDetection, Dijkstra ); - itkGetConstMacro( EndPoints, TVertices ); - itkGetConstMacro( BifurcationPoints, TVertices ); + itkGetConstMacro( EndPoints, TUniqueVertices ); + itkGetConstMacro( BifurcationPoints, TUniqueVertices ); itkGetConstMacro( NumberOfBranches, unsigned long ); + itkGetConstMacro( Branches, TBranches ); public: TLabelImage* GetLabelImage( ); @@ -85,6 +94,13 @@ namespace fpa _TRegion _Region( const TVertex& c, const double& r ); + template< class _T > + TVertex _MaxInRegion( + const _T* image, const TVertex& v, const double& r + ); + + void _Label( const TVertex& v, const TLabel& l ); + private: // Purposely not implemented DijkstraWithEndPointDetection( const Self& other ); @@ -93,10 +109,11 @@ namespace fpa protected: unsigned int m_LabelImageIndex; - _TCandidates m_Candidates; - TVertices m_BifurcationPoints; - TVertices m_EndPoints; - unsigned long m_NumberOfBranches; + _TCandidates m_Candidates; + TUniqueVertices m_BifurcationPoints; + TUniqueVertices m_EndPoints; + unsigned long m_NumberOfBranches; + TBranches m_Branches; }; } // ecapseman diff --git a/lib/fpa/Image/DijkstraWithEndPointDetection.hxx b/lib/fpa/Image/DijkstraWithEndPointDetection.hxx index d8e344a..8ddd9ba 100644 --- a/lib/fpa/Image/DijkstraWithEndPointDetection.hxx +++ b/lib/fpa/Image/DijkstraWithEndPointDetection.hxx @@ -105,13 +105,10 @@ template< class I, class O > void fpa::Image::DijkstraWithEndPointDetection< I, O >:: _AfterGenerateData( ) { + // Finish base algorithm this->Superclass::_AfterGenerateData( ); - // Finish base algorithm - /* TODO - this->m_FullTree.clear( ); - this->m_ReducedTree.clear( ); - */ + // Prepare backtracking objects this->m_EndPoints.clear( ); this->m_BifurcationPoints.clear( ); if( this->m_Candidates.size( ) == 0 ) @@ -122,27 +119,27 @@ _AfterGenerateData( ) // Get some input values const I* input = this->GetInput( ); typename I::SpacingType spac = input->GetSpacing( ); - double max_spac = spac[ 0 ]; + double ms = double( spac[ 0 ] ); for( unsigned int d = 1; d < I::ImageDimension; ++d ) - max_spac = - ( max_spac < double( spac[ d ] ) )? double( spac[ d ] ): max_spac; - max_spac *= double( 3 ); + ms =( ms < double( spac[ d ] ) )? double( spac[ d ] ): ms; + + // Prepare labels TLabelImage* label = this->GetLabelImage( ); label->FillBuffer( 0 ); - // Prepare an object to hold marks + // Object to hold marks std::set< TVertex, TVertexCompare > tree_marks; - /* TODO - typename TMarkImage::Pointer marks = this->GetOutputMarkImage( ); - marks->FillBuffer( 0 ); - */ + + // Object to hold all branches + this->m_Branches.clear( ); + + // First label + this->m_NumberOfBranches = 1; // Iterate over the candidates, starting from the candidates that // are near thin branches typename _TCandidates::const_reverse_iterator cIt = this->m_Candidates.rbegin( ); - this->m_NumberOfBranches = 1; - std::map< TLabel, std::pair< TVertex, TVertex > > branches; for( ; cIt != this->m_Candidates.rend( ); ++cIt ) { // If pixel has been already labelled, pass @@ -151,37 +148,31 @@ _AfterGenerateData( ) continue; // Compute nearest start candidate - _TRegion region = this->_Region( v, max_spac ); - itk::ImageRegionConstIteratorWithIndex< I > iIt( input, region ); - iIt.GoToBegin( ); - TVertex max_vertex = iIt.GetIndex( ); - _TPixel max_value = iIt.Get( ); - for( ++iIt; !iIt.IsAtEnd( ); ++iIt ) - { - _TPixel value = iIt.Get( ); - if( value > max_value ) - { - max_value = value; - max_vertex = iIt.GetIndex( ); - - } // fi - - } // rof + TVertex endpoint = + this->_MaxInRegion( + input, v, + double( std::sqrt( input->GetPixel( v ) ) ) * double( 1.5 ) + ); // Re-check labelling - if( label->GetPixel( max_vertex ) != 0 ) + if( this->_Node( endpoint ).Label == Self::FarLabel ) + continue; + if( label->GetPixel( endpoint ) != 0 ) continue; - this->m_EndPoints.push_back( max_vertex ); + if( this->m_EndPoints.find( endpoint ) != this->m_EndPoints.end( ) ) + continue; + this->m_EndPoints.insert( endpoint ); + std::cout << "endpoint " << endpoint << " inserted " << this->m_EndPoints.size( ) << std::endl; // Get the path all the way to seed std::vector< TVertex > path; this->GetMinimumSpanningTree( )-> - GetPath( path, max_vertex, this->GetSeed( 0 ) ); + GetPath( path, endpoint, this->GetSeed( 0 ) ); // Mark branches bool start = true; bool change = false; - TVertex last_start = max_vertex; + TVertex last_start = endpoint; typename std::vector< TVertex >::const_iterator pIt = path.begin( ); for( ; pIt != path.end( ); ++pIt ) { @@ -192,31 +183,23 @@ _AfterGenerateData( ) { if( tree_marks.find( *pIt ) == tree_marks.end( ) ) { + // Mark a region around current point as visited 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.5 ) ); - itk::ImageRegionIteratorWithIndex< TLabelImage > - lIt( label, region ); - for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt ) - 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 ); - */ + this->_Label( *pIt, TLabel( this->m_NumberOfBranches ) ); } else { // A bifurcation point has been reached! - branches[ this->m_NumberOfBranches ] = std::pair< TVertex, TVertex >( last_start, *pIt ); - last_start = *pIt; - this->m_BifurcationPoints.push_back( *pIt ); - this->m_NumberOfBranches++; - start = false; + if( *pIt != this->GetSeed( 0 ) ) + { + this->m_Branches[ *pIt ][ last_start ] = this->m_NumberOfBranches; + last_start = *pIt; + this->m_BifurcationPoints.insert( *pIt ); + std::cout << "bifurcation = " << *pIt << " " << this->GetSeed( 0 ) << std::endl; + this->m_NumberOfBranches++; + start = false; + + } // fi } // fi } @@ -231,33 +214,19 @@ _AfterGenerateData( ) ) { // 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.5 ) ); - itk::ImageRegionIteratorWithIndex< TLabelImage > - lIt( label, region ); - for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt ) - 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 ); - */ + this->_Label( *pIt, TLabel( this->m_NumberOfBranches ) ); change = true; } 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 ); + if( *pIt != this->GetSeed( 0 ) ) + { + this->m_Branches[ *pIt ][ last_start ] = this->m_NumberOfBranches; + last_start = *pIt; + this->m_NumberOfBranches++; - last_start = *pIt; - this->m_NumberOfBranches++; - /* TODO - this->m_FullTree[ max_vertex ] = - TTreeNode( this->_Parent( max_vertex ), this->m_NumberOfBranches ); - */ + } // fi } // fi @@ -268,14 +237,20 @@ _AfterGenerateData( ) this->m_NumberOfBranches++; this->InvokeEvent( TEndBacktrackingEvent( ) ); - - - /* - this->InvokeEvent( TEndBacktrackingEvent( ) ); - */ - } // rof + typename TBranches::const_iterator bIt = this->m_Branches.begin( ); + unsigned int leo = 0; + for( ; bIt != this->m_Branches.end( ); ++bIt ) + { + typename TBranch::const_iterator brIt = bIt->second.begin( ); + for( ; brIt != bIt->second.end( ); ++brIt ) + { + std::cout << bIt->first << " " << brIt->first << std::endl; + leo++; + } + } + // Re-enumerate labels std::map< TLabel, unsigned long > histo; for( @@ -285,24 +260,17 @@ _AfterGenerateData( ) ) 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 ) + std::map< TLabel, TLabel > changes; + TLabel last_change = 1; + for( TLabel i = 1; i <= this->m_NumberOfBranches; ++i ) { if( histo[ i ] != 0 ) changes[ i ] = last_change++; } // rof this->m_NumberOfBranches = changes.size( ); - */ + + std::cout << leo << " - " << this->m_EndPoints.size( ) << " - " << this->m_BifurcationPoints.size( ) << " - " << this->m_NumberOfBranches << std::endl; /* for( @@ -371,10 +339,7 @@ void fpa::Image::DijkstraWithEndPointDetection< I, O >:: _SetResult( const TVertex& v, const _TNode& n ) { this->Superclass::_SetResult( v, n ); - - TResult vv = TResult( this->_VertexValue( v ) ); - if( TResult( 0 ) < vv ) - this->m_Candidates.insert( _TCandidate( n.Result / vv, v ) ); + this->m_Candidates.insert( _TCandidate( n.Result, v ) ); } // ------------------------------------------------------------------------- @@ -394,7 +359,7 @@ _Region( const TVertex& c, const double& r ) _TSize size; for( unsigned int d = 0; d < I::ImageDimension; ++d ) { - long s = long( std::ceil( r / double( spac[ d ] ) ) ); + long s = long( std::ceil( r / double( spac[ d ] ) ) ) + 3; i0[ d ] = c[ d ] - s; i1[ d ] = c[ d ] + s; @@ -409,9 +374,56 @@ _Region( const TVertex& c, const double& r ) // Prepare region and return it region.SetIndex( i0 ); region.SetSize( size ); + return( region ); } +// ------------------------------------------------------------------------- +template< class I, class O > +template< class _T > +typename fpa::Image::DijkstraWithEndPointDetection< I, O >:: +TVertex fpa::Image::DijkstraWithEndPointDetection< I, O >:: +_MaxInRegion( const _T* image, const TVertex& v, const double& r ) +{ + typedef itk::ImageRegionConstIteratorWithIndex< _T > _TIt; + + _TIt iIt( image, this->_Region( v, r ) ); + iIt.GoToBegin( ); + TVertex max_vertex = iIt.GetIndex( ); + typename _T::PixelType max_value = iIt.Get( ); + for( ++iIt; !iIt.IsAtEnd( ); ++iIt ) + { + typename _T::PixelType value = iIt.Get( ); + if( value > max_value ) + { + max_value = value; + max_vertex = iIt.GetIndex( ); + + } // fi + + } // rof + return( max_vertex ); +} + +// ------------------------------------------------------------------------- +template< class I, class O > +void fpa::Image::DijkstraWithEndPointDetection< I, O >:: +_Label( const TVertex& v, const TLabel& l ) +{ + typedef itk::ImageRegionIteratorWithIndex< TLabelImage > _TIt; + + double d = std::sqrt( double( this->GetInput( )->GetPixel( v ) ) ); + _TRegion region = this->_Region( v, d ); + if( region.GetNumberOfPixels( ) > 0 ) + { + _TIt lIt( this->GetLabelImage( ), region ); + for( lIt.GoToBegin( ); !lIt.IsAtEnd( ); ++lIt ) + lIt.Set( l ); + } + else + this->GetLabelImage( )->SetPixel( v, l ); +} + #endif // __FPA__IMAGE__DIJKSTRAWITHENDPOINTDETECTION__HXX__ // eof - $RCSfile$ diff --git a/lib/fpa/VTK/ImageMPR.cxx b/lib/fpa/VTK/ImageMPR.cxx index 9acfa12..29f4dc4 100644 --- a/lib/fpa/VTK/ImageMPR.cxx +++ b/lib/fpa/VTK/ImageMPR.cxx @@ -252,6 +252,7 @@ AddPolyData( vtkPolyData* pd, double r, double g, double b, double opacity ) this->m_Actors[ i ]->SetMapper( this->m_Mappers[ i ] ); this->m_Actors[ i ]->GetProperty( )->SetColor( r, g, b ); this->m_Actors[ i ]->GetProperty( )->SetOpacity( opacity ); + this->m_Actors[ i ]->GetProperty( )->SetPointSize( 20 ); this->m_Renderer->AddActor( this->m_Actors[ i ] ); }