#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkRegionOfInterestImageFilter.h>
+#include <itkMinimumMaximumImageCalculator.h>
#include <fpa/Filters/BaseMarksInterface.h>
#include <fpa/Filters/Image/SeedsFromLabelsInterface.h>
// -------------------------------------------------------------------------
const unsigned int Dim = 3;
-typedef short TPixel;
-typedef unsigned char TLabel;
-typedef itk::Image< TPixel, Dim > TImage;
-typedef itk::Image< TLabel, Dim > TLabels;
+typedef short TPixel;
+typedef unsigned char TLabel;
+typedef itk::NumericTraits< TPixel >::RealType TScalar;
+typedef itk::Image< TPixel, Dim > TImage;
+typedef itk::Image< TLabel, Dim > TLabels;
+typedef itk::Image< TScalar, Dim > TScalarImage;
/**
*/
itkGetConstMacro( MaxVertex, TVertex );
fpaFilterInputMacro( InputLabels, TLabels );
+ fpaFilterInputMacro( InputVesselness, TScalarImage );
public:
TInputValue GetUpperThreshold( ) const
protected:
MoriLabelling( )
: Superclass( ),
- m_LastThreshold( TInputValue( 0 ) )
+ m_LastThreshold( TInputValue( 0 ) ),
+ m_VesselnessThr( TScalar( 0.05 ) )
{
fpaFilterInputConfigureMacro( InputLabels, TLabels );
+ fpaFilterInputConfigureMacro( InputVesselness, TScalarImage );
this->m_Functor = TFunctor::New( );
this->SetPredicate( this->m_Functor );
}
{
this->Superclass::_BeforeGenerateData( );
this->m_FirstVertex = true;
+
+ typedef itk::MinimumMaximumImageCalculator< TScalarImage > _TMinMax;
+ _TMinMax::Pointer minMax = _TMinMax::New( );
+ minMax->SetImage( this->GetInputVesselness( ) );
+ minMax->Compute( );
+ this->m_MaxVesselness = ( 1.0 - this->m_VesselnessThr ) * minMax->GetMaximum( );
}
virtual void _PostComputeOutputValue( TNode& n ) override
{
const TImage* input = this->GetInput( );
const TLabels* labels = this->GetInputLabels( );
+ const TScalarImage* vesselness = this->GetInputVesselness( );
double x = input->GetPixel( n.Vertex );
/* TODO
double a = std::fabs( x - double( this->m_Functor->GetUpperThreshold( ) ) );
double b = std::fabs( x - double( this->m_LastThreshold ) );
*/
- if( labels->GetPixel( n.Vertex ) == 0 /* && b < a*/ )
- n.Value = 0;
+ if( labels->GetPixel( n.Vertex ) == 0 )
+ {
+ if( vesselness->GetPixel( n.Vertex ) > this->m_MaxVesselness )
+ n.Value = this->GetInsideValue( );
+ else
+ n.Value = 0;
+
+ } // fi
if( !( this->m_FirstVertex ) )
{
bool m_FirstVertex;
TVertex m_MinVertex;
TVertex m_MaxVertex;
+
+ TScalar m_MaxVesselness;
+ TScalar m_VesselnessThr;
};
// -------------------------------------------------------------------------
mandatory.insert( "in" );
mandatory.insert( "out" );
mandatory.insert( "labels" );
+ mandatory.insert( "vesselness" );
- args[ "upper_threshold" ] = "-600";
+ args[ "upper_threshold" ] = "-650";
int i = 1;
while( i < argc )
<< "\t-in filename" << std::endl
<< "\t-out filename" << std::endl
<< "\t-labels filename" << std::endl
+ << "\t-vesselness filename" << std::endl
<< "\t[-roi] filename" << std::endl
<< "\t[-upper_threshold value]" << std::endl;
return( false );
TLabels::Pointer input_labels;
ReadImage( input_labels, args[ "labels" ] );
+ // Read vesselness image
+ TScalarImage::Pointer input_vesselness;
+ ReadImage( input_vesselness, args[ "vesselness" ] );
+
// Mori labelling
MoriLabelling::Pointer labelling = MoriLabelling::New( );
labelling->SetInput( input_image );
labelling->SetInputLabels( input_labels );
+ labelling->SetInputVesselness( input_vesselness );
labelling->SetOutsideValue( 2 );
+ labelling->SetFillValue( 2 );
labelling->SetInsideValue( 1 );
labelling->SetUpperThreshold(
TPixel( std::atof( args[ "upper_threshold" ].c_str( ) ) )