1 #ifndef __fpa__Image__EndPointsFilter__hxx__
2 #define __fpa__Image__EndPointsFilter__hxx__
6 #include <itkImageRegionConstIteratorWithIndex.h>
8 // -------------------------------------------------------------------------
9 template< class _TDistanceMap, class _TCostMap >
10 const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
11 TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
12 GetBifurcations( ) const
14 return( this->m_Bifurcations );
17 // -------------------------------------------------------------------------
18 template< class _TDistanceMap, class _TCostMap >
19 const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
20 TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
23 return( this->m_EndPoints );
26 // -------------------------------------------------------------------------
27 template< class _TDistanceMap, class _TCostMap >
28 void fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
31 typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
32 typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
33 typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
34 typedef typename _TQueue::value_type _TQueueValue;
39 this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
42 this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
46 for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
48 double d = double( dIt.Get( ) );
51 double v = double( cIt.Get( ) ) * d;
52 queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
59 while( queue.size( ) > 0 )
61 auto nIt = queue.begin( );
65 if( marks.find( n.second ) == marks.end( ) )
67 std::cout << queue.size( ) << " " << n.first << std::endl;
68 marks.insert( n.second );
69 this->m_EndPoints.insert( n.second );
70 auto path = this->m_MST->GetPath( n.second );
71 std::cout << path.size( ) << std::endl;
72 for( auto pIt = path.begin( ); pIt != path.end( ); ++pIt )
74 double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
75 d = std::sqrt( std::fabs( d ) );
76 typename _TCostMap::PointType center;
77 this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
79 std::queue< TIndex > q;
82 while( q.size( ) > 0 )
84 TIndex idx = q.front( );
86 if( m.find( idx ) != m.end( ) )
90 for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
92 for( int y = -1; y <= 1; y += 2 )
96 typename _TCostMap::PointType c;
97 this->m_CostMap->TransformIndexToPhysicalPoint( idx2, c );
98 if( this->m_CostMap->GetRequestedRegion( ).IsInside( idx2 ) )
100 if( center.EuclideanDistanceTo( c ) <= ( d * 1.5 ) )
118 // -------------------------------------------------------------------------
119 template< class _TDistanceMap, class _TCostMap >
120 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
126 // -------------------------------------------------------------------------
127 template< class _TDistanceMap, class _TCostMap >
128 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
133 #endif // __fpa__Image__EndPointsFilter__hxx__