From: Leonardo Flórez-Valencia Date: Fri, 21 Jul 2017 12:36:20 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=81c4e503782b69a433de83ffbe942eb774ac4a3f;hp=09046275d77a6f1bb9e6a309f22f9510fba13550;p=FrontAlgorithms.git ... --- diff --git a/lib/fpa/Image/ExtractAxisFilter.h b/lib/fpa/Image/ExtractAxisFilter.h index 25eee47..01efc75 100644 --- a/lib/fpa/Image/ExtractAxisFilter.h +++ b/lib/fpa/Image/ExtractAxisFilter.h @@ -39,6 +39,7 @@ namespace fpa typedef typename TCenterness::OutputImageType TOutputImage; typedef typename TInputImage::IndexType TIndex; + typedef typename TInputImage::PointType TPoint; typedef fpa::Image::PolyLineParametricPath< Self::Dimension > TPath; typedef fpa::Image::Dijkstra< TOutputImage, TOutputImage > TDijkstra; @@ -50,10 +51,16 @@ namespace fpa itkGetConstObjectMacro( Centerness, TCenterness ); itkGetObjectMacro( Centerness, TCenterness ); + itkGetConstMacro( StartIndex, TIndex ); + itkGetConstMacro( EndIndex, TIndex ); + + itkSetMacro( StartIndex, TIndex ); + itkSetMacro( EndIndex, TIndex ); + public: virtual itk::ModifiedTimeType GetMTime( ) const override; - virtual void AddSeed( const TVertex& seed ); + virtual void AddSeed( const TIndex& seed ); virtual void AddSeed( const TPoint& seed ); virtual void ClearSeeds( ); @@ -78,6 +85,9 @@ namespace fpa protected: typename TCenterness::Pointer m_Centerness; typename TDijkstra::Pointer m_Dijkstra; + + TIndex m_StartIndex; + TIndex m_EndIndex; }; } // ecapseman diff --git a/lib/fpa/Image/ExtractAxisFilter.hxx b/lib/fpa/Image/ExtractAxisFilter.hxx index 6f91ade..809306a 100644 --- a/lib/fpa/Image/ExtractAxisFilter.hxx +++ b/lib/fpa/Image/ExtractAxisFilter.hxx @@ -16,7 +16,7 @@ GetMTime( ) const { itk::ModifiedTimeType a = this->Superclass::GetMTime( ); itk::ModifiedTimeType b = this->m_Centerness->GetMTime( ); - itk::ModifiedTimeType c = this->m_Dijsktra->GetMTime( ); + itk::ModifiedTimeType c = this->m_Dijkstra->GetMTime( ); a = ( a < b )? a: b; return( ( a < c )? a: c ); } @@ -24,7 +24,7 @@ GetMTime( ) const // ------------------------------------------------------------------------- template< class _TInputImage, class _TScalar, class _TCenterness > void fpa::Image::ExtractAxisFilter< _TInputImage, _TScalar, _TCenterness >:: -AddSeed( const TVertex& seed ) +AddSeed( const TIndex& seed ) { this->m_Dijkstra->AddSeed( seed ); } @@ -141,9 +141,12 @@ GenerateData( ) this->m_Dijkstra->Update( ); // Extract axis - typename TInputImage::IndexType a = this->m_Dijkstra->GetSeeds( )[ 0 ]; - typename TInputImage::IndexType b = this->m_Dijkstra->GetSeeds( )[ 1 ]; - this->m_Dijkstra->GetMinimumSpanningTree( )->GetPolyLineParametricPath( this->GetOutput( ), a, b ); + typename TPath::Pointer out = this->GetOutput( ); + this->m_Dijkstra->GetMinimumSpanningTree( )->GetPolyLineParametricPath( + out, + this->m_StartIndex, + this->m_EndIndex + ); } #endif // __fpa__Image__ExtractAxisFilter__hxx__ diff --git a/lib/fpa/Image/MinimumSpanningTree.hxx b/lib/fpa/Image/MinimumSpanningTree.hxx index b6161ee..9bd7083 100644 --- a/lib/fpa/Image/MinimumSpanningTree.hxx +++ b/lib/fpa/Image/MinimumSpanningTree.hxx @@ -32,7 +32,8 @@ GetPolyLineParametricPath( ) const { TVertices v = this->GetPath( a ); - path = TPolyLineParametricPath::New( ); + if( path.IsNull( ) ) + path = TPolyLineParametricPath::New( ); path->SetReferenceImage( this ); typename TVertices::const_iterator vIt = v.begin( ); for( ; vIt != v.end( ); ++vIt ) @@ -48,7 +49,8 @@ GetPolyLineParametricPath( ) const { TVertices v = this->GetPath( a, b ); - path = TPolyLineParametricPath::New( ); + if( path.IsNull( ) ) + path = TPolyLineParametricPath::New( ); path->SetReferenceImage( this ); typename TVertices::const_iterator vIt = v.begin( ); for( ; vIt != v.end( ); ++vIt ) diff --git a/lib/fpa/Image/PolyLineParametricPath.h b/lib/fpa/Image/PolyLineParametricPath.h index 7fd6489..83a6c05 100644 --- a/lib/fpa/Image/PolyLineParametricPath.h +++ b/lib/fpa/Image/PolyLineParametricPath.h @@ -64,6 +64,8 @@ namespace fpa this->SetDirection( image->GetDirection( ) ); } + virtual void Graft( itk::DataObject* o ); + protected: PolyLineParametricPath( ); virtual ~PolyLineParametricPath( ); diff --git a/lib/fpa/Image/PolyLineParametricPath.hxx b/lib/fpa/Image/PolyLineParametricPath.hxx index 4616dcf..3093a99 100644 --- a/lib/fpa/Image/PolyLineParametricPath.hxx +++ b/lib/fpa/Image/PolyLineParametricPath.hxx @@ -141,6 +141,29 @@ SetDirection( const TDirection& dir ) } // fi } +// ------------------------------------------------------------------------- +template< unsigned int _VDim > +void fpa::Image::PolyLineParametricPath< _VDim >:: +Graft( itk::DataObject* o ) +{ + this->Superclass::Graft( o ); + Self* other = dynamic_cast< Self* >( o ); + if( other != NULL ) + { + this->m_DefaultInputStepSize = other->m_DefaultInputStepSize; + this->Initialize( ); + for( unsigned long i = 0; i < other->GetSize( ); ++i ) + this->AddVertex( other->GetContinuousVertex( i ) ); + this->m_Spacing = other->m_Spacing; + this->m_Origin = other->m_Origin; + this->m_Direction = other->m_Direction; + this->m_InverseDirection = other->m_InverseDirection; + this->m_IndexToPhysicalPoint = other->m_IndexToPhysicalPoint; + this->m_PhysicalPointToIndex = other->m_PhysicalPointToIndex; + + } // fi +} + // ------------------------------------------------------------------------- template< unsigned int _VDim > fpa::Image::PolyLineParametricPath< _VDim >::