]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 28 Aug 2017 21:00:49 +0000 (16:00 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Mon, 28 Aug 2017 21:00:49 +0000 (16:00 -0500)
appli/CTBronchi/CMakeLists.txt
appli/CTBronchi/Functions.h [new file with mode: 0644]
appli/CTBronchi/Mori.h [new file with mode: 0644]
docs/fpa.dia

index 5044d58e37bb32d9101a6c222c9d5581b4b5f16b..27e869cb094c49ebec159ddc89c742e9ffbcea76 100644 (file)
@@ -1,25 +1,25 @@
 option(fpa_BUILD_CTBronchi "Build bronchi analysis from CT images applications?" OFF)
 if(fpa_BUILD_CTBronchi)
-  configure_file(
-    CTBronchi_process.sh
-    ${PROJECT_BINARY_DIR}/CTBronchi_process.sh
-    COPYONLY
-    )
-  include_directories(
-    ${PROJECT_SOURCE_DIR}/lib
-    ${PROJECT_BINARY_DIR}/lib
-    ${PROJECT_SOURCE_DIR}/appli
-    ${PROJECT_BINARY_DIR}/appli
-    )
-  set(_pfx fpa_CTBronchi_)
-  set(
-    _examples
-    Process
-    )
-  foreach(_e ${_examples})
-    add_executable(${_pfx}${_e} ${_e}.cxx)
-    target_link_libraries(${_pfx}${_e} fpa)
-  endforeach(_e)
+#  configure_file(
+#    CTBronchi_process.sh
+#    ${PROJECT_BINARY_DIR}/CTBronchi_process.sh
+#    COPYONLY
+#    )
+#  include_directories(
+#    ${PROJECT_SOURCE_DIR}/lib
+#    ${PROJECT_BINARY_DIR}/lib
+#    ${PROJECT_SOURCE_DIR}/appli
+#    ${PROJECT_BINARY_DIR}/appli
+#    )
+#  set(_pfx fpa_CTBronchi_)
+#  set(
+#    _examples
+#    Process
+#    )
+#  foreach(_e ${_examples})
+#    add_executable(${_pfx}${_e} ${_e}.cxx)
+#    target_link_libraries(${_pfx}${_e} fpa)
+#  endforeach(_e)
 endif(fpa_BUILD_CTBronchi)
 
 ## eof - $RCSfile$
diff --git a/appli/CTBronchi/Functions.h b/appli/CTBronchi/Functions.h
new file mode 100644 (file)
index 0000000..272c974
--- /dev/null
@@ -0,0 +1,57 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __CTBronchi__Functions__h__
+#define __CTBronchi__Functions__h__
+
+#include <chrono>
+#include <itkImageFileReader.h>
+#include <itkImageFileWriter.h>
+
+namespace CTBronchi
+{
+  // -----------------------------------------------------------------------
+  double MeasureTime( itk::ProcessObject* f )
+  {
+    std::chrono::time_point< std::chrono::high_resolution_clock > s, e;
+    std::chrono::duration< double > t;
+    s = std::chrono::high_resolution_clock::now( );
+    f->Update( );
+    e = std::chrono::high_resolution_clock::now( );
+    t = e - s;
+    return( t.count( ) );
+  }
+
+  // -----------------------------------------------------------------------
+  template< class _TImagePtr >
+  void ReadImage( _TImagePtr& image, const std::string& fname )
+  {
+    typedef typename _TImagePtr::ObjectType _TImage;
+    typedef itk::ImageFileReader< _TImage > _TReader;
+    typename _TReader::Pointer reader = _TReader::New( );
+    reader->SetFileName( fname );
+    double t = MeasureTime( reader );
+    std::cout << "Read " << fname << " in " << t << " s" << std::endl;
+    image = reader->GetOutput( );
+    image->DisconnectPipeline( );
+  }
+
+  // -----------------------------------------------------------------------
+  template< class _TImagePtr >
+  void WriteImage( const _TImagePtr& image, const std::string& fname )
+  {
+    typedef typename _TImagePtr::ObjectType _TImage;
+    typedef itk::ImageFileWriter< _TImage > _TWriter;
+    typename _TWriter::Pointer writer = _TWriter::New( );
+    writer->SetFileName( fname );
+    writer->SetInput( image );
+    double t = MeasureTime( writer );
+    std::cout << "Wrote " << fname << " in " << t << " s" << std::endl;
+  }
+
+} // ecapseman
+
+#endif // __CTBronchi__Functions__h__
+
+// eof - $RCSfile$
diff --git a/appli/CTBronchi/Mori.h b/appli/CTBronchi/Mori.h
new file mode 100644 (file)
index 0000000..a228fa5
--- /dev/null
@@ -0,0 +1,85 @@
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __CTBronchi__Mori__h__
+#define __CTBronchi__Mori__h__
+
+#include <map>
+#include <CTBronchi/Functions.h>
+#include <fpa/Filters/Image/Mori.h>
+
+namespace CTBronchi
+{
+  // -----------------------------------------------------------------------
+  template< class _TInputPtr, class _TOutputPtr >
+  void Mori(
+    _TOutputPtr& output, const _TInputPtr& input,
+    const std::map< std::string, std::string >& args
+    )
+  {
+    typedef typename _TInputPtr::ObjectType  _TInput;
+    typedef typename _TOutputPtr::ObjectType _TOutput;
+    typedef fpa::Filters::Image::Mori< _TInput, _TOutput > _TMori;
+    typedef typename _TInput::PixelType _TInputPixel;
+
+    typename _TMori::Pointer mori = _TMori::New( );
+    mori->SetInput( input );
+    mori->SetSeed( global_seed );
+    mori->SetInsideValue( inside_value );
+    mori->SetOutsideValue( outside_value );
+    mori->SetMinimumThreshold(
+      _TInputPixel( std::atof( args[ "mori_minimum_threshold" ].c_str( ) ) )
+      );
+    mori->SetSignalKernelSize(
+      std::atoi( args[ "mori_signal_kernel_size" ].c_str( ) )
+      );
+    mori->SetSignalThreshold(
+      std::atof( args[ "mori_signal_threshold" ].c_str( ) )
+      );
+    mori->SetSignalInfluence(
+      std::atof( args[ "mori_signal_influence" ].c_str( ) )
+      );
+    mori->SetThresholds(
+      _TInputPixel( std::atof( args[ "mori_lower_threshold" ].c_str( ) ) ),
+      _TInputPixel( std::atof( args[ "mori_upper_threshold" ].c_str( ) ) ),
+      _TInputPixel( std::atof( args[ "mori_delta_threshold" ].c_str( ) ) )
+      );
+    double t = CTBronchi::MeasureTime( mori );
+    std::cout << "Mori executed in " << t << " s" << std::endl;
+    output = mori->GetOutput( );
+
+    std::map< std::string, std::string >::const_iterator i =
+      args.find( "out_mori" );
+    if( i != args.end( ) )
+      CTBronchi::WriteImage( output, i->second );
+
+    i = args.find( "out_signal" );
+    if( i != args.end( ) )
+    {
+      std::stringstream signal;
+      unsigned long nthr = mori->GetNumberOfEvaluatedThresholds( );
+      signal << "# nThr = " << nthr << std::endl;
+      signal << "# Opt  = " << mori->GetOptimumThreshold( ) << std::endl;
+      for( unsigned long j = 0; j < nthr; ++j )
+      {
+        typename _TMori::TPeak p;
+        double x, y;
+        mori->GetSignalValues( j, x, y, p );
+        signal << x << " " << y << std::endl;
+
+      } // rof
+
+      std::ofstream signals_str( i->second.c_str( ) );
+      signals_str << signal.str( );
+      signals_str.close( );
+
+    } // fi
+    output->DisconnectPipeline( );
+  }
+
+} // ecapseman
+
+#endif // __CTBronchi__Functions__h__
+
+// eof - $RCSfile$
index 4f4d39993374ef189652b5bde38d76644328b45c..83fe75c387889ab34594b2f8cd3b8e9bc359ed27 100644 (file)
Binary files a/docs/fpa.dia and b/docs/fpa.dia differ