#ifndef __CTBronchi__MoriLabelling__h__
#define __CTBronchi__MoriLabelling__h__
-#include <itkImageToImageFilter.h>
-#include <itkHessianRecursiveGaussianImageFilter.h>
-#include <itkHessian3DToVesselnessMeasureImageFilter.h>
-
-#include <itkImageFileWriter.h>
-
+#include <fpa/Base/RegionGrow.h>
+#include <fpa/Base/MarksInterface.h>
+#include <fpa/Base/Functors/RegionGrow/BinaryThreshold.h>
+#include <fpa/Image/Algorithm.h>
+#include <fpa/Image/LabelledSeedsInterface.h>
namespace CTBronchi
{
*/
template< class _TInputImage, class _TLabelImage >
class MoriLabelling
- : public itk::ImageToImageFilter< _TLabelImage, _TLabelImage >
+ : public fpa::Base::RegionGrow< fpa::Image::Algorithm< _TInputImage, _TLabelImage, fpa::Base::MarksInterface< typename _TInputImage::IndexType >, fpa::Image::LabelledSeedsInterface< typename _TInputImage::IndexType, typename _TInputImage::PointType, typename _TInputImage::PixelType, typename _TLabelImage::PixelType, typename _TLabelImage::PixelType, typename _TInputImage::IndexType::LexicographicCompare > > >
{
public:
- typedef MoriLabelling Self;
- typedef itk::ImageToImageFilter< _TLabelImage, _TLabelImage > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
typedef _TInputImage TInputImage;
typedef _TLabelImage TLabelImage;
- typedef typename TInputImage::PixelType TPixel;
- typedef typename TLabelImage::PixelType TLabel;
- typedef typename TLabelImage::RegionType TRegion;
+ typedef typename TInputImage::PixelType TInputValue;
+ typedef typename TInputImage::PointType TPoint;
+ typedef typename TInputImage::IndexType TVertex;
+ typedef typename TLabelImage::PixelType TOutputValue;
+ typedef typename TVertex::LexicographicCompare TVertexCompare;
- public:
- itkNewMacro( Self );
- itkTypeMacro( MoriLabelling, itk::ImageToImageFilter );
+ typedef fpa::Base::MarksInterface< TVertex > TMarksInterface;
+ typedef fpa::Image::LabelledSeedsInterface< TVertex, TPoint, TInputValue, TOutputValue, TOutputValue, TVertexCompare > TSeedsInterface;
+ typedef fpa::Image::Algorithm< TInputImage, TLabelImage, TMarksInterface, TSeedsInterface > TAlgorithm;
- itkGetConstMacro( UpperThreshold, TPixel );
- itkSetMacro( UpperThreshold, TPixel );
+ typedef MoriLabelling Self;
+ typedef fpa::Base::RegionGrow< TAlgorithm > Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
- itkGetConstMacro( InsideValue, TLabel );
- itkSetMacro( InsideValue, TLabel );
+ typedef typename TSeedsInterface::TNode TNode;
+ typedef typename TSeedsInterface::TNodes TNodes;
- itkGetConstMacro( InsideLabel, TLabel );
- itkSetMacro( InsideLabel, TLabel );
+ typedef fpa::Base::Functors::RegionGrow::BinaryThreshold< TInputValue > TThresholdFunction;
- itkGetConstMacro( OutsideLabel, TLabel );
- itkSetMacro( OutsideLabel, TLabel );
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( MoriLabelling, fpa::Base::RegionGrow );
+
+ itkGetConstMacro( InsideLabel, TOutputValue );
+ itkSetMacro( InsideLabel, TOutputValue );
+
+ itkGetConstMacro( OutsideLabel, TOutputValue );
+ itkSetMacro( OutsideLabel, TOutputValue );
public:
const TLabelImage* GetInputLabelImage( ) const;
const TInputImage* GetInputRawImage( ) const;
void SetInputRawImage( TInputImage* image );
+ TInputValue GetUpperThreshold( ) const;
+ void SetUpperThreshold( TInputValue t );
+
protected:
MoriLabelling( );
virtual ~MoriLabelling( );
- virtual void BeforeThreadedGenerateData( ) override
- {
- this->Superclass::BeforeThreadedGenerateData( );
-
- const TInputImage* raw = this->GetInputRawImage( );
- typename TInputImage::SpacingType spac = raw->GetSpacing( );
- double sigma = spac[ 0 ];
- for( unsigned int d = 1; d < TInputImage::ImageDimension; ++d )
- sigma = ( spac[ d ] < sigma )? spac[ d ]: sigma;
- sigma *= 1.5;
-
- typedef itk::HessianRecursiveGaussianImageFilter< TInputImage > _THessian;
- typename _THessian::Pointer hessian = _THessian::New( );
- hessian->SetInput( raw );
- hessian->SetSigma( sigma );
-
- typedef itk::Hessian3DToVesselnessMeasureImageFilter< double > _TVesselness;
- typename _TVesselness::Pointer vesselness = _TVesselness::New( );
- vesselness->SetInput( hessian->GetOutput( ) );
- vesselness->SetAlpha1( 0.5 );
- vesselness->SetAlpha2( 2.0 );
-
- typename itk::ImageFileWriter< typename _TVesselness::OutputImageType >::Pointer w =
- itk::ImageFileWriter< typename _TVesselness::OutputImageType >::New( );
- w->SetInput( vesselness->GetOutput( ) );
- w->SetFileName( "vessel.mhd" );
- w->Update( );
- }
-
- virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) override;
+ virtual TNodes _UnifySeeds( ) override;
+ virtual void _UpdateOutputValue( TNode& n ) override;
private:
// Purposely not implemented.
Self& operator=( const Self& other );
protected:
- TPixel m_UpperThreshold;
- TLabel m_InsideValue;
- TLabel m_InsideLabel;
- TLabel m_OutsideLabel;
+ TOutputValue m_InsideLabel;
+ TOutputValue m_OutsideLabel;
};
} // ecapseman