1 #ifndef __fpa__Image__EndPointsFilter__hxx__
2 #define __fpa__Image__EndPointsFilter__hxx__
7 #include <itkImageRegionConstIteratorWithIndex.h>
9 // -------------------------------------------------------------------------
10 template< class _TDistanceMap, class _TCostMap >
11 const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
12 TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
13 GetBifurcations( ) const
15 return( this->m_Bifurcations );
18 // -------------------------------------------------------------------------
19 template< class _TDistanceMap, class _TCostMap >
20 const typename fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
21 TIndices& fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
24 return( this->m_EndPoints );
27 // -------------------------------------------------------------------------
28 template< class _TDistanceMap, class _TCostMap >
29 void fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
32 typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
33 typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
34 typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
35 typedef typename _TQueue::value_type _TQueueValue;
40 this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
43 this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
47 for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
49 double d = double( dIt.Get( ) );
52 double v = double( cIt.Get( ) ) * d;
53 queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
60 while( queue.size( ) > 0 )
62 auto nIt = queue.begin( );
66 if( marks.find( n.second ) == marks.end( ) )
68 std::cout << queue.size( ) << " " << n.first << std::endl;
69 marks.insert( n.second );
70 this->m_EndPoints.insert( n.second );
71 auto path = this->m_MST->GetPath( n.second );
72 std::cout << path.size( ) << std::endl;
73 for( auto pIt = path.begin( ); pIt != path.end( ); ++pIt )
75 double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
76 d = std::sqrt( std::fabs( d ) );
77 typename _TCostMap::PointType center;
78 this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
80 std::queue< TIndex > q;
83 while( q.size( ) > 0 )
85 TIndex idx = q.front( );
87 if( m.find( idx ) != m.end( ) )
91 for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
93 for( int y = -1; y <= 1; y += 2 )
97 typename _TCostMap::PointType c;
98 this->m_CostMap->TransformIndexToPhysicalPoint( idx2, c );
99 if( this->m_CostMap->GetRequestedRegion( ).IsInside( idx2 ) )
101 if( center.EuclideanDistanceTo( c ) <= ( d * 1.5 ) )
119 // -------------------------------------------------------------------------
120 template< class _TDistanceMap, class _TCostMap >
121 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
127 // -------------------------------------------------------------------------
128 template< class _TDistanceMap, class _TCostMap >
129 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
134 #endif // __fpa__Image__EndPointsFilter__hxx__