]> Creatis software - FrontAlgorithms.git/commitdiff
Minor bugs
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 24 Jun 2015 23:31:30 +0000 (18:31 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 24 Jun 2015 23:31:30 +0000 (18:31 -0500)
lib/fpa/Base/Functors/InvertCostFunction.h
lib/fpa/Base/MinimumSpanningTree.h
lib/fpa/Base/MinimumSpanningTree.hxx

index faf4fb2dbea2027c58874f75d77f9ff2df8fbb73..fa04ed4841625428bb0d84e4988e59040d5d8c68 100644 (file)
@@ -29,7 +29,10 @@ namespace fpa
       public:
         virtual C Evaluate( const C& input ) const
           {
-            return( C( 1 ) / ( C( 1 ) + C( input ) ) );
+            if( input < C( 0 ) )
+              return( C( -1 ) / ( C( 1 ) + C( input ) ) );
+            else
+              return( C( 1 ) / ( C( 1 ) + C( input ) ) );
           }
 
       protected:
index a020d4795d1f78e25f0d13fab1cc006971c63f46..40562678d23e2717c8793b32c59b6ec6a60caf8c 100644 (file)
@@ -56,6 +56,12 @@ namespace fpa
         std::vector< V >& path, const V& a, const V& b
         ) const;
 
+      template< class I, class P >
+      void GetPathFromImage(
+        std::vector< P >& path, const V& a, const V& b,
+        const I* image, unsigned int kernel = 0
+        ) const;
+
     protected:
       MinimumSpanningTree( );
       virtual ~MinimumSpanningTree( );
index d932247c7bc2dcbc739e5902848da20879509bb5..ad0d06bc00a315e654c77692f9fcef4e5ed4588d 100644 (file)
@@ -149,6 +149,59 @@ GetPath( std::vector< V >& path, const V& a, const V& b ) const
   } // fi
 }
 
+// -------------------------------------------------------------------------
+template< class V, class C, class B >
+template< class I, class P >
+void fpa::Base::MinimumSpanningTree< V, C, B >::
+GetPathFromImage(
+  std::vector< P >& path, const V& a, const V& b,
+  const I* image, unsigned int kernel
+  ) const
+{
+  std::vector< V > vertices;
+  this->GetPath( vertices, a, b );
+  path.clear( );
+  for( unsigned int i = 0; i < vertices.size( ); ++i )
+  {
+    P p;
+    image->TransformIndexToPhysicalPoint( vertices[ i ], p );
+    path.push_back( p );
+
+  } // rof
+
+  // Lowpass filter
+  if( kernel > 0 )
+  {
+    int k = int( kernel ) >> 1;
+    std::vector< P > lowpass_path;
+    for( unsigned int i = 0; i < path.size( ); ++i )
+    {
+      P p;
+      p.Fill( ( typename P::ValueType )( 0 ) );
+      unsigned int c = 0;
+      for( int j = -k; j <= k; ++j )
+      {
+        int l = int( i ) + j;
+        if( l >= 0 && l < path.size( ) )
+        {
+          p += path[ l ].GetVectorFromOrigin( );
+          c++;
+
+        } // fi
+
+      } // rof
+      if( c > 0 )
+        for( unsigned int d = 0; d < P::PointDimension; ++d )
+          p[ d ] /= ( typename P::ValueType )( c );
+      lowpass_path.push_back( p );
+
+    } // rof
+
+    path = lowpass_path;
+
+  } // fi
+}
+
 // -------------------------------------------------------------------------
 template< class V, class C, class B >
 fpa::Base::MinimumSpanningTree< V, C, B >::