1 // =========================================================================
2 // @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __CTBronchi__Process__h__
5 #define __CTBronchi__Process__h__
9 #include <fpa_ctbronchi_export.h>
14 class FPA_CTBRONCHI_EXPORT Process
17 // Some types and values
18 static const unsigned int Dim = 3;
20 typedef unsigned char TLabel;
21 typedef float TScalar;
24 typedef std::tuple< std::string, bool > TArgument;
25 typedef std::map< std::string, TArgument > TArguments;
28 typedef CTBronchi::Image< TPixel, Dim > TPixelImage;
29 typedef CTBronchi::Image< TLabel, Dim > TLabelImage;
30 typedef CTBronchi::Image< TScalar, Dim > TScalarImage;
33 typedef TPixelImage::TImage::PointType TPoint;
34 typedef TPixelImage::TImage::IndexType TIndex;
35 typedef std::pair< TIndex, TPoint > TSeed;
41 void ParseArguments( int argc, char* argv[] );
48 void _MoriLabelling( );
54 std::string m_BaseFileName;
56 TLabel m_UndefinedLabel;
58 TLabel m_OutsideLabel;
61 TScalarImage m_Vesselness;
65 TLabelImage m_SliceRW;
72 #include <tclap/CmdLine.h>
74 #include <itkMinimumMaximumImageCalculator.h>
75 #include <itkInvertIntensityImageFilter.h>
76 #include <itkHessianRecursiveGaussianImageFilter.h>
77 #include <itkHessian3DToVesselnessMeasureImageFilter.h>
78 #include "Functions.h"
80 // -------------------------------------------------------------------------
81 const unsigned int Dim = 3;
83 typedef itk::NumericTraits< TPixel >::RealType TScalar;
84 typedef itk::Image< TPixel, Dim > TImage;
85 typedef itk::Image< TScalar, Dim > TScalarImage;
87 // -------------------------------------------------------------------------
88 int main( int argc, char* argv[] )
90 typedef TCLAP::ValueArg< std::string > _TStringArg;
91 typedef TCLAP::ValueArg< TScalar > _TRealArg;
94 _TStringArg in( "i", "input", "Input image", true, "", "file" );
95 _TStringArg out( "o", "output", "Output image", true, "", "file" );
96 _TRealArg s( "s", "sigma", "Sigma", false, 0.5, "value (0.5)" );
97 _TRealArg a1( "a", "alpha1", "Alpha1", false, 0.5, "value (0.5)" );
98 _TRealArg a2( "b", "alpha2", "Alpha2", false, 2, "value (2)" );
101 TCLAP::CmdLine cmd( "Vesselness computation", ' ', "1.0.0" );
107 cmd.parse( argc, argv );
109 catch( TCLAP::ArgException& err )
112 << "===============================" << std::endl
113 << "Error caught: " << std::endl
114 << err.error( ) << " " << err.argId( )
115 << "===============================" << std::endl
124 TImage::Pointer input_image;
125 CTBronchi::ReadImage( input_image, in.getValue( ) );
128 typedef itk::MinimumMaximumImageCalculator< TImage > _TMinMax;
129 _TMinMax::Pointer minMax = _TMinMax::New( );
130 minMax->SetImage( input_image );
133 // Invert intensities
134 typedef itk::InvertIntensityImageFilter< TImage > _TInverter;
135 _TInverter::Pointer inverter = _TInverter::New( );
136 inverter->SetInput( input_image );
137 inverter->SetMaximum( minMax->GetMaximum( ) );
138 double t = CTBronchi::MeasureTime( inverter );
139 std::cout << "Inversion executed in " << t << " s" << std::endl;
141 // Compute hessian image
142 typedef itk::HessianRecursiveGaussianImageFilter< TImage > _THessian;
143 _THessian::Pointer hessian = _THessian::New( );
144 hessian->SetInput( inverter->GetOutput( ) );
145 hessian->SetSigma( s.getValue( ) );
146 t = CTBronchi::MeasureTime( hessian );
147 std::cout << "Hessian executed in " << t << " s" << std::endl;
151 itk::Hessian3DToVesselnessMeasureImageFilter< TScalar >
153 _TVesselness::Pointer vesselness = _TVesselness::New( );
154 vesselness->SetInput( hessian->GetOutput( ) );
155 vesselness->SetAlpha1( a1.getValue( ) );
156 vesselness->SetAlpha2( a2.getValue( ) );
157 t = CTBronchi::MeasureTime( vesselness );
158 std::cout << "Vesselness executed in " << t << " s" << std::endl;
161 CTBronchi::WriteImage( vesselness->GetOutput( ), out.getValue( ) );
163 catch( std::exception& err )
166 << "===============================" << std::endl
167 << "Error caught: " << std::endl
169 << "===============================" << std::endl
177 #endif // __CTBronchi__Process__h__