]> Creatis software - FrontAlgorithms.git/blob - appli/CTBronchi/Process.h
...
[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 <itkImage.h>
8
9 namespace CTBronchi
10 {
11   class Process
12   {
13     // Some types and values
14     static const unsigned int Dim = 3;
15     typedef short         TPixel;
16     typedef unsigned char TLabel;
17     typedef float         TScalar;
18
19     double MeasureTime( itk::ProcessObject* f );
20
21     template< class _TImagePtr >
22     void ReadImage( _TImagePtr& image, const std::string& fname );
23
24     template< class _TImage >
25     void WriteImage( const _TImage* image, const std::string& fname );
26   };
27
28 } // ecapseman
29
30 /* TODO
31    #include <string>
32    #include <tclap/CmdLine.h>
33    #include <itkImage.h>
34    #include <itkMinimumMaximumImageCalculator.h>
35    #include <itkInvertIntensityImageFilter.h>
36    #include <itkHessianRecursiveGaussianImageFilter.h>
37    #include <itkHessian3DToVesselnessMeasureImageFilter.h>
38    #include "Functions.h"
39
40    // -------------------------------------------------------------------------
41    const unsigned int Dim = 3;
42    typedef short                                  TPixel;
43    typedef itk::NumericTraits< TPixel >::RealType TScalar;
44    typedef itk::Image< TPixel, Dim >              TImage;
45    typedef itk::Image< TScalar, Dim >             TScalarImage;
46
47    // -------------------------------------------------------------------------
48    int main( int argc, char* argv[] )
49    {
50    typedef TCLAP::ValueArg< std::string > _TStringArg;
51    typedef TCLAP::ValueArg< TScalar > _TRealArg;
52
53    // Parse input line
54    _TStringArg in( "i", "input", "Input image", true, "", "file" );
55    _TStringArg out( "o", "output", "Output image", true, "", "file" );
56    _TRealArg s( "s", "sigma", "Sigma", false, 0.5, "value (0.5)" );
57    _TRealArg a1( "a", "alpha1", "Alpha1", false, 0.5, "value (0.5)" );
58    _TRealArg a2( "b", "alpha2", "Alpha2", false, 2, "value (2)" );
59    try
60    {
61    TCLAP::CmdLine cmd( "Vesselness computation", ' ', "1.0.0" );
62    cmd.add( a2 );
63    cmd.add( a1 );
64    cmd.add( s );
65    cmd.add( out );
66    cmd.add( in );
67    cmd.parse( argc, argv );
68    }
69    catch( TCLAP::ArgException& err )
70    {
71    std::cerr
72    << "===============================" << std::endl
73    << "Error caught: " << std::endl
74    << err.error( ) << " " << err.argId( )
75    << "===============================" << std::endl
76    << std::endl;
77    return( 1 );
78
79    } // yrt
80
81    try
82    {
83    // Read image
84    TImage::Pointer input_image;
85    CTBronchi::ReadImage( input_image, in.getValue( ) );
86
87    // Min-max
88    typedef itk::MinimumMaximumImageCalculator< TImage > _TMinMax;
89    _TMinMax::Pointer minMax = _TMinMax::New( );
90    minMax->SetImage( input_image );
91    minMax->Compute( );
92
93    // Invert intensities
94    typedef itk::InvertIntensityImageFilter< TImage > _TInverter;
95    _TInverter::Pointer inverter = _TInverter::New( );
96    inverter->SetInput( input_image );
97    inverter->SetMaximum( minMax->GetMaximum( ) );
98    double t = CTBronchi::MeasureTime( inverter );
99    std::cout << "Inversion executed in " << t << " s" << std::endl;
100
101    // Compute hessian image
102    typedef itk::HessianRecursiveGaussianImageFilter< TImage > _THessian;
103    _THessian::Pointer hessian = _THessian::New( );
104    hessian->SetInput( inverter->GetOutput( ) );
105    hessian->SetSigma( s.getValue( ) );
106    t = CTBronchi::MeasureTime( hessian );
107    std::cout << "Hessian executed in " << t << " s" << std::endl;
108
109    // Vesselness
110    typedef
111    itk::Hessian3DToVesselnessMeasureImageFilter< TScalar >
112    _TVesselness;
113    _TVesselness::Pointer vesselness = _TVesselness::New( );
114    vesselness->SetInput( hessian->GetOutput( ) );
115    vesselness->SetAlpha1( a1.getValue( ) );
116    vesselness->SetAlpha2( a2.getValue( ) );
117    t = CTBronchi::MeasureTime( vesselness );
118    std::cout << "Vesselness executed in " << t << " s" << std::endl;
119
120    // Write result
121    CTBronchi::WriteImage( vesselness->GetOutput( ), out.getValue( ) );
122    }
123    catch( std::exception& err )
124    {
125    std::cerr
126    << "===============================" << std::endl
127    << "Error caught: " << std::endl
128    << err.what( )
129    << "===============================" << std::endl
130    << std::endl;
131    return( 1 );
132
133    } // yrt
134    return( 0 );
135    }
136 */
137 #endif // __CTBronchi__Process__h__
138
139 // eof - $RCSfile$