]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 4 Dec 2017 17:06:37 +0000 (12:06 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 4 Dec 2017 17:06:37 +0000 (12:06 -0500)
appli/CTBronchi/Image.h [new file with mode: 0644]
appli/CTBronchi/Image.hxx [new file with mode: 0644]
appli/CTBronchi/Process.cxx [new file with mode: 0644]
appli/CTBronchi/Process.h [new file with mode: 0644]

diff --git a/appli/CTBronchi/Image.h b/appli/CTBronchi/Image.h
new file mode 100644 (file)
index 0000000..8b243e6
--- /dev/null
@@ -0,0 +1,46 @@
+// =========================================================================
+// @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __CTBronchi__Image__h__
+#define __CTBronchi__Image__h__
+
+#include <itkImage.h>
+
+namespace CTBronchi
+{
+  /**
+   */
+  template< class _TPixel, unsigned int _VDim >
+  class Image
+  {
+  public:
+    static const unsigned int _VDim = VDim;
+    typedef _TPixel TPixel;
+    typedef itk::Image< TPixel, VDim > TImage;
+
+  public:
+    Image( );
+    virtual ~Image( );
+
+    bool IsNotNull( ) const;
+    bool IsNull( ) const;
+
+    TImage* Get( );
+    const TImage* Get( ) const;
+    void Set( TImage* image );
+    void Set( const TImage::Pointer& image );
+
+    void Load( const std::string& fname );
+    void Save( const std::string& fname );
+
+  protected:
+    typename TImage::Pointer m_Image;
+  };
+
+} // ecapseman
+
+#include "Image.hxx"
+
+#endif // __CTBronchi__Image__h__
+
+// eof - $RCSfile$
diff --git a/appli/CTBronchi/Image.hxx b/appli/CTBronchi/Image.hxx
new file mode 100644 (file)
index 0000000..4b6fa9b
--- /dev/null
@@ -0,0 +1,119 @@
+// =========================================================================
+// @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __CTBronchi__Image__hxx__
+#define __CTBronchi__Image__hxx__
+
+#include <itkImageFileReader.h>
+#include <itkImageFileWriter.h>
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+CTBronchi::Image< _TPixel, _VDim >::
+Image( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+CTBronchi::Image< _TPixel, _VDim >::
+~Image( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+bool CTBronchi::Image< _TPixel, _VDim >::
+IsNotNull( ) const
+{
+  return( this->m_Image.IsNotNull( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+bool CTBronchi::Image< _TPixel, _VDim >::
+IsNull( ) const
+{
+  return( this->m_Image.IsNull( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+typename CTBronchi::Image< _TPixel, _VDim >::
+TImage* CTBronchi::Image< _TPixel, _VDim >::
+Get( )
+{
+  return( this->m_Image.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+const typename CTBronchi::Image< _TPixel, _VDim >::
+TImage* CTBronchi::Image< _TPixel, _VDim >::
+Get( ) const
+{
+  return( this->m_Image.GetPointer( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void CTBronchi::Image< _TPixel, _VDim >::
+Set( TImage* image )
+{
+  this->m_Image = image;
+  this->m_Image->DisconnectPipeline( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void CTBronchi::Image< _TPixel, _VDim >::
+Set( const TImage::Pointer& image )
+{
+  this->m_Image = image.GetPointer( );
+  this->m_Image->DisconnectPipeline( );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void CTBronchi::Image< _TPixel, _VDim >::
+Load( const std::string& fname )
+{
+  typedef itk::ImageFileReader< TImage > _TReader;
+  typename _TReader::Pointer r = _TReader::New( );
+  r->SetFileName( fname );
+  try
+  {
+    r->Update( );
+    this->Set( r->GetOutput( ) );
+  }
+  catch( ... )
+  {
+    this->Set( NULL );
+
+  } // yrt
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void CTBronchi::Image< _TPixel, _VDim >::
+Save( const std::string& fname )
+{
+  typedef itk::ImageFileWriter< TImage > _TWriter;
+
+  if( this->IsNotNull( ) )
+  {
+    typename _TWriter::Pointer w = _TWriter::New( );
+    w->SetFileName( fname );
+    w->SetInput( this->m_Image );
+    try
+    {
+      w->Update( );
+    }
+    catch( ... ) { }
+
+  } // fi
+}
+
+#endif // __CTBronchi__Image__hxx__
+
+// eof - $RCSfile$
diff --git a/appli/CTBronchi/Process.cxx b/appli/CTBronchi/Process.cxx
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/appli/CTBronchi/Process.h b/appli/CTBronchi/Process.h
new file mode 100644 (file)
index 0000000..9daaf66
--- /dev/null
@@ -0,0 +1,139 @@
+// =========================================================================
+// @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
+// =========================================================================
+#ifndef __CTBronchi__Process__h__
+#define __CTBronchi__Process__h__
+
+#include <itkImage.h>
+
+namespace CTBronchi
+{
+  class Process
+  {
+    // Some types and values
+    static const unsigned int Dim = 3;
+    typedef short         TPixel;
+    typedef unsigned char TLabel;
+    typedef float         TScalar;
+
+    double MeasureTime( itk::ProcessObject* f );
+
+    template< class _TImagePtr >
+    void ReadImage( _TImagePtr& image, const std::string& fname );
+
+    template< class _TImage >
+    void WriteImage( const _TImage* image, const std::string& fname );
+  };
+
+} // ecapseman
+
+/* TODO
+   #include <string>
+   #include <tclap/CmdLine.h>
+   #include <itkImage.h>
+   #include <itkMinimumMaximumImageCalculator.h>
+   #include <itkInvertIntensityImageFilter.h>
+   #include <itkHessianRecursiveGaussianImageFilter.h>
+   #include <itkHessian3DToVesselnessMeasureImageFilter.h>
+   #include "Functions.h"
+
+   // -------------------------------------------------------------------------
+   const unsigned int Dim = 3;
+   typedef short                                  TPixel;
+   typedef itk::NumericTraits< TPixel >::RealType TScalar;
+   typedef itk::Image< TPixel, Dim >              TImage;
+   typedef itk::Image< TScalar, Dim >             TScalarImage;
+
+   // -------------------------------------------------------------------------
+   int main( int argc, char* argv[] )
+   {
+   typedef TCLAP::ValueArg< std::string > _TStringArg;
+   typedef TCLAP::ValueArg< TScalar > _TRealArg;
+
+   // Parse input line
+   _TStringArg in( "i", "input", "Input image", true, "", "file" );
+   _TStringArg out( "o", "output", "Output image", true, "", "file" );
+   _TRealArg s( "s", "sigma", "Sigma", false, 0.5, "value (0.5)" );
+   _TRealArg a1( "a", "alpha1", "Alpha1", false, 0.5, "value (0.5)" );
+   _TRealArg a2( "b", "alpha2", "Alpha2", false, 2, "value (2)" );
+   try
+   {
+   TCLAP::CmdLine cmd( "Vesselness computation", ' ', "1.0.0" );
+   cmd.add( a2 );
+   cmd.add( a1 );
+   cmd.add( s );
+   cmd.add( out );
+   cmd.add( in );
+   cmd.parse( argc, argv );
+   }
+   catch( TCLAP::ArgException& err )
+   {
+   std::cerr
+   << "===============================" << std::endl
+   << "Error caught: " << std::endl
+   << err.error( ) << " " << err.argId( )
+   << "===============================" << std::endl
+   << std::endl;
+   return( 1 );
+
+   } // yrt
+
+   try
+   {
+   // Read image
+   TImage::Pointer input_image;
+   CTBronchi::ReadImage( input_image, in.getValue( ) );
+
+   // Min-max
+   typedef itk::MinimumMaximumImageCalculator< TImage > _TMinMax;
+   _TMinMax::Pointer minMax = _TMinMax::New( );
+   minMax->SetImage( input_image );
+   minMax->Compute( );
+
+   // Invert intensities
+   typedef itk::InvertIntensityImageFilter< TImage > _TInverter;
+   _TInverter::Pointer inverter = _TInverter::New( );
+   inverter->SetInput( input_image );
+   inverter->SetMaximum( minMax->GetMaximum( ) );
+   double t = CTBronchi::MeasureTime( inverter );
+   std::cout << "Inversion executed in " << t << " s" << std::endl;
+
+   // Compute hessian image
+   typedef itk::HessianRecursiveGaussianImageFilter< TImage > _THessian;
+   _THessian::Pointer hessian = _THessian::New( );
+   hessian->SetInput( inverter->GetOutput( ) );
+   hessian->SetSigma( s.getValue( ) );
+   t = CTBronchi::MeasureTime( hessian );
+   std::cout << "Hessian executed in " << t << " s" << std::endl;
+
+   // Vesselness
+   typedef
+   itk::Hessian3DToVesselnessMeasureImageFilter< TScalar >
+   _TVesselness;
+   _TVesselness::Pointer vesselness = _TVesselness::New( );
+   vesselness->SetInput( hessian->GetOutput( ) );
+   vesselness->SetAlpha1( a1.getValue( ) );
+   vesselness->SetAlpha2( a2.getValue( ) );
+   t = CTBronchi::MeasureTime( vesselness );
+   std::cout << "Vesselness executed in " << t << " s" << std::endl;
+
+   // Write result
+   CTBronchi::WriteImage( vesselness->GetOutput( ), out.getValue( ) );
+   }
+   catch( std::exception& err )
+   {
+   std::cerr
+   << "===============================" << std::endl
+   << "Error caught: " << std::endl
+   << err.what( )
+   << "===============================" << std::endl
+   << std::endl;
+   return( 1 );
+
+   } // yrt
+   return( 0 );
+   }
+*/
+#endif // __CTBronchi__Process__h__
+
+// eof - $RCSfile$