From b69a5d04d117c1fdd297999c4fb034db54911aca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Mon, 28 Aug 2017 16:00:49 -0500 Subject: [PATCH] ... --- appli/CTBronchi/CMakeLists.txt | 40 ++++++++-------- appli/CTBronchi/Functions.h | 57 ++++++++++++++++++++++ appli/CTBronchi/Mori.h | 85 +++++++++++++++++++++++++++++++++ docs/fpa.dia | Bin 3587 -> 3592 bytes 4 files changed, 162 insertions(+), 20 deletions(-) create mode 100644 appli/CTBronchi/Functions.h create mode 100644 appli/CTBronchi/Mori.h diff --git a/appli/CTBronchi/CMakeLists.txt b/appli/CTBronchi/CMakeLists.txt index 5044d58..27e869c 100644 --- a/appli/CTBronchi/CMakeLists.txt +++ b/appli/CTBronchi/CMakeLists.txt @@ -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 index 0000000..272c974 --- /dev/null +++ b/appli/CTBronchi/Functions.h @@ -0,0 +1,57 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __CTBronchi__Functions__h__ +#define __CTBronchi__Functions__h__ + +#include +#include +#include + +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 index 0000000..a228fa5 --- /dev/null +++ b/appli/CTBronchi/Mori.h @@ -0,0 +1,85 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __CTBronchi__Mori__h__ +#define __CTBronchi__Mori__h__ + +#include +#include +#include + +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$ diff --git a/docs/fpa.dia b/docs/fpa.dia index 4f4d39993374ef189652b5bde38d76644328b45c..83fe75c387889ab34594b2f8cd3b8e9bc359ed27 100644 GIT binary patch literal 3592 zcmZ|Pc{~%2AII@Ta%X%^5rs8J{^) zCKqoCf#n!M;wLEbx0*XI#Mn>vn{4zP?`H5kRlKhVq;=+JRT@rQUM0mI!9#71hYRcipzT36;_l*l$V5rn^$#Ja z>2}`U4T60O+~i=@690JNrXgu2UhyqGGQhU&pvzRH%SiJq%_(m5CnV{^9s>rY39tlX(=q#psYq?a;Z`D)LCg2p`mx#LAZuYo=?%8* zf23tkt46QyW%@Arm$&=`)}aT%7I{?%hdb8oN9*Za#|`i1#%rsqc7aM;QUJ^-5->Eu?O-ZJ8b9GL$@?RU=#*lu~wG@8C;7jg!TKm%$*dD}rQ!gNNt~o(l!&h@P z?bmLN7s6NMaQR(fm~HDus^ZY0Sq#4l8%Fx;k#nApnIGAdTB_?$AZD&C?03s-v8Mx? zrjH#Nuetrh-Z@5=^JybY(taw%@v|CXuIf!mq$@WrR#pWmm4I?*lSh5)pysO1U456! za@QdA+lB}M18^QeSS3LvX@2F+>vJDDc;ytv<-d)6t5AM?0M045NAxd+oi!uqexh<* zGh$po2vbyJTXdE`7uVWE1`~H-SwDlK{wB|)wRklmJS+-kH6mU*oXe=}MBB-nsRPpH z#K&qasIP4CI=uJ?;$DGm_N#BP_RS5mxynYt1oL+OKZt=0UD4ykl;A;d zlP70>d0&$naQ$lz1s4k`WN^#k{eJ+9=pOeNcX^+|daYFik%Yxtfx^oU6Qc0e|{{BIc>=2^?o`+M;6GBgkMOZUcRb8XCxT&W{<(bv#RS=`zCrK zo247nPS4J&#}bjF54I_O0!+es&wG=!!;swTo?F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