From 1bdade6efd914f81fadc135bac23e44933e3a897 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 22 Nov 2017 01:57:01 -0500 Subject: [PATCH] ... --- appli/CTBronchi/AndSegmentations.cxx | 81 ++++++++++++++++++++++++++++ appli/CTBronchi/CMakeLists.txt | 11 ++++ appli/CTBronchi/Process.sh | 26 +++++---- 3 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 appli/CTBronchi/AndSegmentations.cxx diff --git a/appli/CTBronchi/AndSegmentations.cxx b/appli/CTBronchi/AndSegmentations.cxx new file mode 100644 index 0000000..4bd76a7 --- /dev/null +++ b/appli/CTBronchi/AndSegmentations.cxx @@ -0,0 +1,81 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= + +#include +#include +#include +#include +#include "Functions.h" + +// ------------------------------------------------------------------------- +const unsigned int Dim = 3; +typedef unsigned char TPixel; +typedef itk::Image< TPixel, Dim > TImage; + +// ------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + typedef TCLAP::ValueArg< std::string > _TStringArg; + + // Parse input line + _TStringArg in1( "i", "input1", "Input image 1", true, "", "file" ); + _TStringArg in2( "j", "input2", "Input image 2", true, "", "file" ); + _TStringArg out( "o", "output", "Output image", true, "", "file" ); + try + { + TCLAP::CmdLine cmd( "FastRandomWalker", ' ', "1.0.0" ); + cmd.add( out ); + cmd.add( in2 ); + cmd.add( in1 ); + cmd.parse( argc, argv ); + } + catch( TCLAP::ArgException& err ) + { + std::cerr + << "===============================" << std::endl + << "Error caught: " << std::endl + << err.error( ) << " " << err.argId( ) << std::endl + << "===============================" << std::endl + << std::endl; + return( 1 ); + + } // yrt + + try + { + // Read input image 1 + TImage::Pointer input_image1; + CTBronchi::ReadImage( input_image1, in1.getValue( ) ); + + // Read input image 2 + TImage::Pointer input_image2; + CTBronchi::ReadImage( input_image2, in2.getValue( ) ); + + // And images + typedef itk::AndImageFilter< TImage, TImage, TImage > TFilter; + TFilter::Pointer filter = TFilter::New( ); + filter->SetInput1( input_image1 ); + filter->SetInput2( input_image2 ); + double t = CTBronchi::MeasureTime( filter ); + std::cout << "And filter executed in " << t << " s" << std::endl; + + // Write result + CTBronchi::WriteImage( filter->GetOutput( ), out.getValue( ) ); + } + catch( std::exception& err ) + { + std::cerr + << "===============================" << std::endl + << "Error caught: " << std::endl + << err.what( ) << std::endl + << "===============================" << std::endl + << std::endl; + return( 1 ); + + } // yrt + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/appli/CTBronchi/CMakeLists.txt b/appli/CTBronchi/CMakeLists.txt index 79a58ad..5f10a8e 100644 --- a/appli/CTBronchi/CMakeLists.txt +++ b/appli/CTBronchi/CMakeLists.txt @@ -12,6 +12,7 @@ if(fpa_BUILD_CTBronchi) MoriLabelling FastRandomWalker SliceBySliceRandomWalker + AndSegmentations ) foreach(_e ${_examples}) BuildApplication( @@ -22,6 +23,16 @@ if(fpa_BUILD_CTBronchi) LINKS fpa cpPlugins::tclap ) endforeach(_e) + + configure_file( + Process.sh + ${PROJECT_BINARY_DIR}/${_pfx}Process.sh + COPYONLY + ) + install( + FILES ${PROJECT_BINARY_DIR}/${_pfx}Process.sh + DESTINATION bin + ) endif(fpa_BUILD_CTBronchi) ## eof - $RCSfile$ diff --git a/appli/CTBronchi/Process.sh b/appli/CTBronchi/Process.sh index bebf539..47954b7 100755 --- a/appli/CTBronchi/Process.sh +++ b/appli/CTBronchi/Process.sh @@ -1,6 +1,7 @@ #!/bin/bash ## -- Command line options +exec_dir=`dirname $0` vesselness_sigma="0.5" vesselness_alpha1="0.5" vesselness_alpha2="2" @@ -11,7 +12,8 @@ mori_signal_influence="0.5" mori_lower="-1024" mori_upper="0" mori_delta="1" -labels_vesselness_thr="5" +slicebyslice_vesselness_thr="5" +fast_vesselness_thr="95" labels_upper_thr="-400" beta="2.5" epsilon="1e-5" @@ -65,8 +67,12 @@ while [[ "$#" -gt 0 ]]; do mori_delta="$2" shift ;; - -labels_vesselness_thr) - labels_vesselness_thr="$2" + -slicebyslice_vesselness_thr) + slicebyslice_vesselness_thr="$2" + shift + ;; + -fast_vesselness_thr) + fast_vesselness_thr="$2" shift ;; -labels_upper_thr) @@ -114,13 +120,13 @@ echo "************************************************" (>&2 echo "Processing $input... ") echo "Processing $input..." if [ ! -f $vesselness ] || [ -n "$force" ] ; then - ./fpa_CTBronchi_Vesselness \ + $exec_dir/fpa_CTBronchi_Vesselness \ -i $input -o $vesselness \ -s $vesselness_sigma -a $vesselness_alpha1 -b $vesselness_alpha2 fi if [ ! -f $mori ] || [ -n "$force" ] ; then - ./fpa_CTBronchi_MoriSegmentation \ + $exec_dir/fpa_CTBronchi_MoriSegmentation \ -i $input \ -o $mori \ -s $mori_signal \ @@ -135,17 +141,17 @@ if [ ! -f $mori ] || [ -n "$force" ] ; then fi if [ ! -f $labels ] || [ -n "$force" ] ; then - ./fpa_CTBronchi_MoriLabelling \ + $exec_dir/fpa_CTBronchi_MoriLabelling \ -i $input \ -l $mori \ -v $vesselness \ -o $labels \ - -a $labels_vesselness_thr \ + -a $fast_vesselness_thr \ -u $labels_upper_thr fi if [ ! -f $fastrw ] || [ -n "$force" ] ; then - ./fpa_CTBronchi_FastRandomWalker \ + $exec_dir/fpa_CTBronchi_FastRandomWalker \ -i $input \ -l $labels \ -o $fastrw \ @@ -154,12 +160,12 @@ if [ ! -f $fastrw ] || [ -n "$force" ] ; then fi if [ ! -f $slicerw ] || [ -n "$force" ] ; then - ./fpa_CTBronchi_SliceBySliceRandomWalker \ + $exec_dir/fpa_CTBronchi_SliceBySliceRandomWalker \ -i $input \ -l $mori \ -v $vesselness \ -o $slicerw \ - -t $labels_vesselness_thr \ + -t $slicebyslice_vesselness_thr \ -b $beta \ -e $epsilon fi -- 2.47.1