]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 14:02:03 +0000 (09:02 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 10 Oct 2016 14:02:03 +0000 (09:02 -0500)
lib/Instances/fpa_DataObjects.i
lib/fpa/Image/EndPointsFilter.hxx
plugins/CMakeLists.txt

index 7cf6e6867e8d2394c5e1540016edf756603df027..231d59fb36df144b8c119fab1803efe8b1bdc555 100644 (file)
@@ -4,6 +4,6 @@ t fpa/Image/MinimumSpanningTree
 t fpa/Base/MinimumSpanningTree
 
 c fpa::Base::MinimumSpanningTree< itk::Index< #process_dims# >, cpExtensions::DataStructures::PolyLineParametricPath< #process_dims# >, itk::Image< itk::Offset< #process_dims# >, #process_dims# > >
-c fpa::Image::MinimumSpanningTree< #process_dims# >
+c fpa::Image::MinimumSpanningTree< #process_dims# >
 
 ** eof - $RCSfile$
index e2be58ffb1b3d89fe2da7e47c6c5807f43f29fbf..a4c170ef5b74af9a46b0df03d993da589fb8a2d2 100644 (file)
@@ -29,44 +29,76 @@ template< class _TDistanceMap, class _TCostMap >
 void fpa::Image::EndPointsFilter< _TDistanceMap, _TCostMap >::
 Compute( )
 {
-  /* TODO
-     typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
-     typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
-     typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
-     typedef typename _TQueue::value_type _TQueueValue;
-
-     // Create queue
-     _TQueue queue;
-     _TDistMapIt dIt(
-     this->m_DistanceMap, this->m_DistanceMap->GetRequestedRegion( )
-     );
-     _TCostMapIt cIt(
-     this->m_CostMap, this->m_CostMap->GetRequestedRegion( )
-     );
-     dIt.GoToBegin( );
-     cIt.GoToBegin( );
-     for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
-     {
-     double d = double( dIt.Get( ) );
-     if( d > 0 )
-     {
-     double v = double( cIt.Get( ) ) * d;
-     queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
+  typedef itk::ImageRegionConstIteratorWithIndex< _TDistanceMap > _TDistMapIt;
+  typedef itk::ImageRegionConstIteratorWithIndex< _TCostMap > _TCostMapIt;
+  typedef std::multimap< double, TIndex, std::greater< double > > _TQueue;
+  typedef typename _TQueue::value_type _TQueueValue;
+
+  // Some values
+  typename _TDistanceMap::RegionType region =
+    this->m_DistanceMap->GetRequestedRegion( );
+
+  // Create queue
+  _TQueue queue;
+  _TDistMapIt dIt( this->m_DistanceMap, region );
+  _TCostMapIt cIt( this->m_CostMap, region );
+  dIt.GoToBegin( );
+  cIt.GoToBegin( );
+  for( ; !dIt.IsAtEnd( ) && !cIt.IsAtEnd( ); ++dIt, ++cIt )
+  {
+    double d = double( dIt.Get( ) );
+    if( d > 0 )
+    {
+      double v = double( cIt.Get( ) ) / d;
+      queue.insert( _TQueueValue( v, dIt.GetIndex( ) ) );
+
+    } // fi
+
+  } // rof
+
+  // BFS from maximum queue
+  TIndices marks;
+  while( queue.size( ) > 0 )
+  {
+    // Get node
+    auto nIt = queue.begin( );
+    auto n = *nIt;
+    queue.erase( nIt );
+    if( marks.find( n.second ) != marks.end( ) )
+      continue;
+
+    // Mark it
+    marks.insert( n.second );
+    this->m_EndPoints.insert( n.second );
+
+    // Get path
+    typename TMST::TPath::Pointer path;
+    this->m_MST->GetPath( path, n.second );
+    for( unsigned long i = 0; i < path->GetSize( ); ++i )
+    {
+      typename TMST::TPath::TContinuousIndex cidx = path->GetVertex( i );
+      typename _TCostMap::PointType cnt;
+      this->m_CostMap->TransformContinuousIndexToPhysicalPoint( cidx, cnt );
+      TIndex idx;
+      this->m_CostMap->TransformPhysicalPointToIndex( cnt, idx );
+      double d = double( this->m_DistanceMap->GetPixel( idx ) );
+
+      /* TODO
+         TIndex idx;
+         for( unsigned int d = 0; d < _TCostMap::ImageDimension; ++d )
+         idx[ d ] = cidx[ d ];
+      */
+
+    } // rof
+
+    // TODO: temporary
+    queue.clear( );
+
+  } // elihw
 
-     } // fi
-
-     } // rof
-
-     TIndices marks;
+  /* TODO
      while( queue.size( ) > 0 )
      {
-     auto nIt = queue.begin( );
-     auto n = *nIt;
-     queue.erase( nIt );
-
-     if( marks.find( n.second ) == marks.end( ) )
-     {
-     std::cout << queue.size( ) << " " << n.first << std::endl;
      marks.insert( n.second );
      this->m_EndPoints.insert( n.second );
      auto path = this->m_MST->GetPath( n.second );
@@ -76,7 +108,7 @@ Compute( )
      double d = double( this->m_DistanceMap->GetPixel( *pIt ) );
      d = std::sqrt( std::fabs( d ) );
      typename _TCostMap::PointType center;
-     this->m_CostMap->TransformIndexToPhysicalPoint( *pIt, center );
+
 
      std::queue< TIndex > q;
      TIndices m;
index d771579c328a3191cd3878e26d6ba927b2e88c33..6900f775e6b34bee1a5af53348a6fa7f507159fa 100644 (file)
@@ -9,7 +9,7 @@ IF(USE_cpPlugins)
     ${prj_VERSION} ${prj_SHORT_VERSION}
     fpa
     )
-  TARGET_LINK_LIBRARIES(${_plugin} ${VTK_LIBRARIES} ${cpPlugins_LIB} ${cpPlugins_ImageIterators_LIB} ${fpa_Instances} )
+  TARGET_LINK_LIBRARIES(${_plugin} ${VTK_LIBRARIES} ${cpPlugins_LIB} ${cpPlugins_ImageIterators_LIB} ${fpa_Instances})
 ENDIF(USE_cpPlugins)
 
 ## eof - $RCSfile$
\ No newline at end of file