#define __fpa__Common__OriginalRandomWalker__h__
#include <fpa/Config.h>
+#include <map>
#include <vector>
#include <itkImage.h>
#include <itkImageToImageFilter.h>
+#include <itkSimpleFastMutexLock.h>
+#include <fpa/Functors/VertexFunction.h>
namespace fpa
{
typedef typename TImage::RegionType TRegion;
typedef typename TLabels::PixelType TLabel;
+ typedef fpa::Functors::VertexFunction< TIndex, TScalar > TEdgeFunction;
+
+ 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(
fpa::Common::OriginalRandomWalker, itk::ImageToImageFilter
);
- itkGetConstMacro( Beta, TScalar );
- itkSetMacro( Beta, TScalar );
-
- itkGetConstMacro( Epsilon, TScalar );
- itkSetMacro( Epsilon, TScalar );
-
- itkBooleanMacro( NormalizeWeights );
- itkGetConstMacro( NormalizeWeights, bool );
- itkSetMacro( NormalizeWeights, bool );
+ itkGetConstObjectMacro( EdgeFunction, TEdgeFunction );
+ itkGetObjectMacro( EdgeFunction, TEdgeFunction );
+ itkSetObjectMacro( EdgeFunction, TEdgeFunction );
fpaFilterInputMacro( InputLabels, TLabels );
fpaFilterOutputMacro( OutputProbabilities, TScalarImage );
- public:
- void AddSeed( const TIndex& seed, const TLabel& label );
+ /* TODO
+ public:
+ void AddSeed( const TIndex& seed, const TLabel& label );
+ */
protected:
OriginalRandomWalker( );
virtual void GenerateData( ) override;
+ 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
Self& operator=( const Self& other );
protected:
- std::vector< TIndex > m_Seeds;
- std::vector< TLabel > m_Labels;
+ /* TODO
+ std::vector< TIndex > m_Seeds;
+ std::vector< TLabel > m_Labels;
+ */
+
+ typename TEdgeFunction::Pointer m_EdgeFunction;
- TScalar m_Beta;
- TScalar m_Epsilon;
- bool m_NormalizeWeights;
+ itk::SimpleFastMutexLock m_Mutex;
};
} // ecapseman