]> Creatis software - FrontAlgorithms.git/blobdiff - lib/fpa/Common/OriginalRandomWalker.h
...
[FrontAlgorithms.git] / lib / fpa / Common / OriginalRandomWalker.h
index 915cb1979c65012bf85c183086519dc8bb470b14..d4af732998028d0b9714391972d5432b098669c1 100644 (file)
@@ -6,9 +6,11 @@
 #define __fpa__Common__OriginalRandomWalker__h__
 
 #include <fpa/Config.h>
+#include <map>
 #include <vector>
 #include <itkImage.h>
 #include <itkImageToImageFilter.h>
+#include <itkSimpleFastMutexLock.h>
 
 namespace fpa
 {
@@ -36,6 +38,30 @@ namespace fpa
       typedef typename TImage::RegionType TRegion;
       typedef typename TLabels::PixelType TLabel;
 
+    protected:
+      struct _TBoundaryThreadStruct
+      {
+        Pointer Filter;
+        void* Triplets;
+        std::map< TLabel, unsigned long >* Labels;
+      };
+
+      struct _TLaplacianThreadStruct
+      {
+        Pointer Filter;
+        void* A;
+        void* R;
+        const void* B;
+      };
+
+      struct _TOutputThreadStruct
+      {
+        Pointer Filter;
+        const void* X;
+        const void* S;
+        const std::vector< TLabel >* InvLabels;
+      };
+
     public:
       itkNewMacro( Self );
       itkTypeMacro(
@@ -64,8 +90,70 @@ namespace fpa
 
       virtual void GenerateData( ) override;
 
+      virtual TScalar _W( const TIndex& i, const TIndex& j );
+      virtual TScalar _L( const TIndex& i, const TIndex& j );
+
+      // Boundary construction
+      template< class _TTriplets >
+      void _Boundary(
+        _TTriplets& B,
+        std::map< TLabel, unsigned long >& labels
+        );
+
+      template< class _TTriplets >
+      static ITK_THREAD_RETURN_TYPE _BoundaryCbk( void* arg );
+
+      template< class _TTriplets >
+      void _ThreadedBoundary(
+        const TRegion& region, const itk::ThreadIdType& id,
+        _TTriplets* B,
+        std::map< TLabel, unsigned long >* labels
+        );
+
+      // Laplacian construction
+      template< class _TTriplets >
+      void _Laplacian(
+        _TTriplets& A, _TTriplets& R, const _TTriplets& B
+        );
+
+      template< class _TTriplets >
+      static ITK_THREAD_RETURN_TYPE _LaplacianCbk( void* arg );
+
+      template< class _TTriplets >
+      void _ThreadedLaplacian(
+        const TRegion& region, const itk::ThreadIdType& id,
+        _TTriplets* A, _TTriplets* R, const _TTriplets* B
+        );
+
+      // Output filling
+      template< class _TMatrix, class _TTriplets >
+      void _Output(
+        const _TMatrix& X, const _TTriplets& S,
+        const std::vector< TLabel >& invLabels
+        );
+
+      template< class _TMatrix, class _TTriplets >
+      static ITK_THREAD_RETURN_TYPE _OutputCbk( void* arg );
+
+      template< class _TMatrix, class _TTriplets >
+      void _ThreadedOutput(
+        const TRegion& region, const itk::ThreadIdType& id,
+        const _TMatrix* X, const _TTriplets* S,
+        const std::vector< TLabel >* invLabels
+        );
+
+      // Array-Image conversion
       static unsigned long _1D( const TIndex& idx, const TRegion& region );
-      static TIndex _ND( const unsigned long& i, const TRegion& region );
+
+      template< class _TTriplets >
+      static unsigned long _SeedIndex(
+        const unsigned long& i, const _TTriplets& t
+        );
+
+      template< class _TTriplets >
+      static unsigned long _NearSeedIndex(
+        const unsigned long& i, const _TTriplets& t
+        );
 
     private:
       // Purposely not implemented
@@ -79,6 +167,8 @@ namespace fpa
       TScalar m_Beta;
       TScalar m_Epsilon;
       bool m_NormalizeWeights;
+
+      itk::SimpleFastMutexLock m_Mutex;
     };
 
   } // ecapseman