]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Image/Algorithm.hxx
...
[FrontAlgorithms.git] / lib / fpa / Image / Algorithm.hxx
index 9eb2640cd9a2b80025916692959cfb03226efe5a..3c33e4e3ca90019e7ac77b58c1c8ae9b541948cc 100644 (file)
@@ -4,6 +4,7 @@
 // Send Piotr's code to Anna
 
 #include <itkImage.h>
+#include <fpa/Image/Functors/SimpleNeighborhood.h>
 
 // -------------------------------------------------------------------------
 template< class _TInputImage, class _TOutputImage >
@@ -11,11 +12,16 @@ fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
 Algorithm( )
   : Superclass( )
 {
+  typedef fpa::Image::Functors::SimpleNeighborhood< _TInputImage::ImageDimension > _TNeigh;
   typedef itk::Image< TFrontId, _TInputImage::ImageDimension > _TMarks;
+
   this->m_MarksIdx = this->GetNumberOfRequiredOutputs( );
   this->itk::ProcessObject::SetNumberOfRequiredOutputs( this->m_MarksIdx + 1 );
   typename _TMarks::Pointer marks = _TMarks::New( );
   this->SetNthOutput( this->m_MarksIdx, marks );
+
+  typename _TNeigh::Pointer neigh = _TNeigh::New( );
+  this->SetNeighborhoodFunction( neigh );
 }
 
 // -------------------------------------------------------------------------
@@ -34,10 +40,19 @@ _BeforeGenerateData( )
   this->AllocateOutputs( );
 
   TNeighborhoodFunction* neighFunc =
-    dynamic_cast< TNeighborhoodFunction* >( this->GetNeighborhoodFunction( ) );
+    dynamic_cast< TNeighborhoodFunction* >(
+      this->GetNeighborhoodFunction( )
+      );
   if( neighFunc == NULL )
     itkExceptionMacro( << "NeighborhoodFunction not well defined." );
   neighFunc->SetImage( this->GetInput( ) );
+
+  TVertexFunction* vertexFunc =
+    dynamic_cast< TVertexFunction* >(
+      this->GetVertexFunction( )
+      );
+  if( vertexFunc != NULL )
+    vertexFunc->SetImage( this->GetInput( ) );
 }
 
 // -------------------------------------------------------------------------
@@ -109,6 +124,26 @@ _UpdateResult( const _TQueueNode& n )
   this->GetOutput( )->SetPixel( n.Vertex, n.Result );
 }
 
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+typename fpa::Image::Algorithm< _TInputImage, _TOutputImage >::TOutput
+fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
+_GetResult( const TVertex& v ) const
+{
+  if( this->GetOutput( )->GetLargestPossibleRegion( ).IsInside( v ) )
+    return( this->GetOutput( )->GetPixel( v ) );
+  else
+    return( this->m_InitResult );
+}
+
+// -------------------------------------------------------------------------
+template< class _TInputImage, class _TOutputImage >
+unsigned int fpa::Image::Algorithm< _TInputImage, _TOutputImage >::
+_GetNumberOfDimensions( ) const
+{
+  return( _TInputImage::ImageDimension );
+}
+
 #endif // __fpa__Image__Algorithm__hxx__
 
 // eof - $RCSfile$