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 >::
33 typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
34 typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
35 typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
36 typedef typename _TQueue::value_type _TQueueValue;
41 this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
44 this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
48 for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
50 double d = double( dIt.Get( ) );
53 double v = double( cIt.Get( ) ) * d;
54 queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
61 while( queue.size( ) > 0 )
63 auto nIt = queue.begin( );
67 if( marks.find( n.second ) == marks.end( ) )
69 std::cout << queue.size( ) << " " << n.first << std::endl;
70 marks.insert( n.second );
71 this->m_EndPoints.insert( n.second );
72 auto path = this->m_MST->GetPath( n.second );
73 std::cout << path.size( ) << std::endl;
74 for( auto pIt = path.begin( ); pIt != path.end( ); ++pIt )
76 double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
77 d = std::sqrt( std::fabs( d ) );
78 typename _TCostMap::PointType center;
79 this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
81 std::queue< TIndex > q;
84 while( q.size( ) > 0 )
86 TIndex idx = q.front( );
88 if( m.find( idx ) != m.end( ) )
92 for( unsigned int x = 0; x < _TCostMap::ImageDimension; ++x )
94 for( int y = -1; y <= 1; y += 2 )
98 typename _TCostMap::PointType c;
99 this->m_CostMap->TransformIndexToPhysicalPoint( idx2, c );
100 if( this->m_CostMap->GetRequestedRegion( ).IsInside( idx2 ) )
102 if( center.EuclideanDistanceTo( c ) <= ( d * 1.5 ) )
121 // -------------------------------------------------------------------------
122 template< class _TDistanceMap, class _TCostMap >
123 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
129 // -------------------------------------------------------------------------
130 template< class _TDistanceMap, class _TCostMap >
131 fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
136 #endif // __fpa__Image__EndPointsFilter__hxx__