]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/Process.h
bae6f4388b4d1752d4046173aac84d51e970dde3
[FrontAlgorithms.git] / appli / CTBronchi / Process.h
1 // =========================================================================
2 // @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __CTBronchi__Process__h__
5 #define __CTBronchi__Process__h__
6
7 #include <map>
8 #include <tuple>
9 #include <fpa_ctbronchi_export.h>
10 #include "Image.h"
11
12 namespace CTBronchi
13 {
14   class FPA_CTBRONCHI_EXPORT Process
15   {
16   public:
17     // Some types and values
18     static const unsigned int Dim = 3;
19     typedef short         TPixel;
20     typedef unsigned char TLabel;
21     typedef float         TScalar;
22
23     // Arguments
24     typedef std::tuple< std::string, bool > TArgument;
25     typedef std::map< std::string, TArgument > TArguments;
26
27     // Images
28     typedef CTBronchi::Image< TPixel, Dim >  TPixelImage;
29     typedef CTBronchi::Image< TLabel, Dim >  TLabelImage;
30     typedef CTBronchi::Image< TScalar, Dim > TScalarImage;
31
32     // Seed
33     typedef TPixelImage::TImage::PointType TPoint;
34     typedef TPixelImage::TImage::IndexType TIndex;
35     typedef std::pair< TIndex, TPoint >    TSeed;
36
37   public:
38     Process( );
39     virtual ~Process( );
40
41     void ParseArguments( int argc, char* argv[] );
42     void Update( );
43
44   protected:
45     void _Input( );
46     void _Vesselness( );
47     void _Mori( );
48     void _MoriLabelling( );
49
50   protected:
51     TArguments m_StrArg;
52     TArguments m_DblArg;
53
54     std::string  m_BaseFileName;
55     TSeed        m_Seed;
56     TLabel m_UndefinedLabel;
57     TLabel m_InsideLabel;
58     TLabel m_OutsideLabel;
59
60     TPixelImage  m_Input;
61     TScalarImage m_Vesselness;
62     TLabelImage  m_Mori;
63     TLabelImage  m_Labels;
64     TLabelImage  m_FastRW;
65     TLabelImage  m_SliceRW;
66   };
67
68 } // ecapseman
69
70 /* TODO
71    #include <string>
72    #include <tclap/CmdLine.h>
73    #include <itkImage.h>
74    #include <itkMinimumMaximumImageCalculator.h>
75    #include <itkInvertIntensityImageFilter.h>
76    #include <itkHessianRecursiveGaussianImageFilter.h>
77    #include <itkHessian3DToVesselnessMeasureImageFilter.h>
78    #include "Functions.h"
79
80    // -------------------------------------------------------------------------
81    const unsigned int Dim = 3;
82    typedef short                                  TPixel;
83    typedef itk::NumericTraits< TPixel >::RealType TScalar;
84    typedef itk::Image< TPixel, Dim >              TImage;
85    typedef itk::Image< TScalar, Dim >             TScalarImage;
86
87    // -------------------------------------------------------------------------
88    int main( int argc, char* argv[] )
89    {
90    typedef TCLAP::ValueArg< std::string > _TStringArg;
91    typedef TCLAP::ValueArg< TScalar > _TRealArg;
92
93    // Parse input line
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)" );
99    try
100    {
101    TCLAP::CmdLine cmd( "Vesselness computation", ' ', "1.0.0" );
102    cmd.add( a2 );
103    cmd.add( a1 );
104    cmd.add( s );
105    cmd.add( out );
106    cmd.add( in );
107    cmd.parse( argc, argv );
108    }
109    catch( TCLAP::ArgException& err )
110    {
111    std::cerr
112    << "===============================" << std::endl
113    << "Error caught: " << std::endl
114    << err.error( ) << " " << err.argId( )
115    << "===============================" << std::endl
116    << std::endl;
117    return( 1 );
118
119    } // yrt
120
121    try
122    {
123    // Read image
124    TImage::Pointer input_image;
125    CTBronchi::ReadImage( input_image, in.getValue( ) );
126
127    // Min-max
128    typedef itk::MinimumMaximumImageCalculator< TImage > _TMinMax;
129    _TMinMax::Pointer minMax = _TMinMax::New( );
130    minMax->SetImage( input_image );
131    minMax->Compute( );
132
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;
140
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;
148
149    // Vesselness
150    typedef
151    itk::Hessian3DToVesselnessMeasureImageFilter< TScalar >
152    _TVesselness;
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;
159
160    // Write result
161    CTBronchi::WriteImage( vesselness->GetOutput( ), out.getValue( ) );
162    }
163    catch( std::exception& err )
164    {
165    std::cerr
166    << "===============================" << std::endl
167    << "Error caught: " << std::endl
168    << err.what( )
169    << "===============================" << std::endl
170    << std::endl;
171    return( 1 );
172
173    } // yrt
174    return( 0 );
175    }
176 */
177 #endif // __CTBronchi__Process__h__
178
179 // eof - $RCSfile$