1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __RandomWalkSegmentation__h__
5 #define __RandomWalkSegmentation__h__
7 #include <itkImageToImageFilter.h>
8 #include <fpa/Config.h>
9 #include <fpa/DataStructures/Image/Path.h>
13 template< class _TInputImage, class _TOutputImage >
14 class RandomWalkSegmentation
15 : public itk::ImageToImageFilter< _TInputImage, _TOutputImage >
18 typedef _TInputImage TInputImage;
19 typedef _TOutputImage TOutputImage;
21 typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
22 typedef RandomWalkSegmentation Self;
23 typedef itk::SmartPointer< Self > Pointer;
24 typedef itk::SmartPointer< const Self > ConstPointer;
26 typedef typename TInputImage::IndexType TIndex;
27 typedef typename TInputImage::PointType TPoint;
35 typedef fpa::DataStructures::Image::Path< TInputImage::ImageDimension > TPath;
39 itkTypeMacro( RandomWalkSegmentation, itk::ImageToImageFilter );
41 itkGetConstMacro( StartSeed, TSeed );
42 itkGetConstMacro( EndSeed, TSeed );
44 itkGetConstMacro( Beta, double );
45 itkSetMacro( Beta, double );
47 itkGetConstMacro( Sigma, double );
48 itkSetMacro( Sigma, double );
50 itkGetConstMacro( Radius, double );
51 itkSetMacro( Radius, double );
53 fpaFilterOutputMacro( OutputAxis, TPath );
56 void AddSeed( const TIndex& s );
57 void AddSeed( const TPoint& s );
59 unsigned long GetNumberOfSeeds( ) const;
61 void SetStartSeed( const TIndex& s );
62 void SetStartSeed( const TPoint& s );
64 void SetEndSeed( const TIndex& s );
65 void SetEndSeed( const TPoint& s );
68 RandomWalkSegmentation( );
69 virtual ~RandomWalkSegmentation( );
71 virtual void GenerateData( ) override;
74 template< class _TIn, class _TSeed >
75 void _SynchSeed( const _TIn* in, _TSeed& seed );
77 template< class _TIn, class _TOutPtr >
78 void _Smooth( const _TIn* in, _TOutPtr& out );
80 template< class _TIn, class _TOutPtr, class _TAxisPtr, class _TSeeds >
81 typename _TIn::RegionType _RawSegmentation(
82 const _TIn* in, const _TSeeds& seeds,
83 const typename _TIn::IndexType& s0,
84 const typename _TIn::IndexType& s1,
85 const typename _TOutPtr::ObjectType::PixelType& beta,
86 _TOutPtr& out, _TAxisPtr& out_axis,
87 typename _TOutPtr::ObjectType::PixelType& oMean,
88 typename _TOutPtr::ObjectType::PixelType& oSTD
91 template< class _TIn, class _TOutPtr >
92 typename _TIn::RegionType _ROI(
93 const _TIn* in, const typename _TIn::RegionType& roi, unsigned int pad,
97 template< class _TAxisPtr, class _TRegion >
99 const typename _TAxisPtr::ObjectType* in, const _TRegion& roi,
103 template< class _TInRaw, class _TInCosts, class _TAxis, class _TScalar, class _TOutPtr >
105 const _TInRaw* raw, const _TInCosts* costs, const _TAxis* axis,
106 const _TScalar& mean, const _TScalar& dev, const _TScalar& radius,
110 template< class _TIn, class _TOutPtr >
112 const _TIn* in, const typename _TOutPtr::ObjectType* labels,
113 const typename _TIn::PixelType& beta,
117 template< class _TIn, class _TSeeds, class _TSeed, class _TOutPtr, class _TAxisPtr >
118 void _DistanceAndAxis(
119 const _TIn* in, const _TSeeds& seeds,
120 const _TSeed& p0, const _TSeed& p1,
121 _TOutPtr& out_dist, _TAxisPtr& out_axis
125 // Purposely not implemented
126 RandomWalkSegmentation( const Self& other );
127 Self& operator=( const Self& other );
132 std::vector< TSeed > m_Seeds;
139 #ifndef ITK_MANUAL_INSTANTIATION
140 # include "RandomWalkSegmentation.hxx"
141 #endif // ITK_MANUAL_INSTANTIATION
143 #endif // __RandomWalkSegmentation__h__