1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __CTBronchi__Mori__h__
6 #define __CTBronchi__Mori__h__
9 #include <CTBronchi/Functions.h>
10 #include <fpa/Filters/Image/Mori.h>
14 // -----------------------------------------------------------------------
15 template< class _TInputPtr, class _TOutputPtr >
17 _TOutputPtr& output, const _TInputPtr& input,
18 const std::map< std::string, std::string >& args
21 typedef typename _TInputPtr::ObjectType _TInput;
22 typedef typename _TOutputPtr::ObjectType _TOutput;
23 typedef fpa::Filters::Image::Mori< _TInput, _TOutput > _TMori;
24 typedef typename _TInput::PixelType _TInputPixel;
26 typename _TMori::Pointer mori = _TMori::New( );
27 mori->SetInput( input );
28 mori->SetSeed( global_seed );
29 mori->SetInsideValue( inside_value );
30 mori->SetOutsideValue( outside_value );
31 mori->SetMinimumThreshold(
32 _TInputPixel( std::atof( args[ "mori_minimum_threshold" ].c_str( ) ) )
34 mori->SetSignalKernelSize(
35 std::atoi( args[ "mori_signal_kernel_size" ].c_str( ) )
37 mori->SetSignalThreshold(
38 std::atof( args[ "mori_signal_threshold" ].c_str( ) )
40 mori->SetSignalInfluence(
41 std::atof( args[ "mori_signal_influence" ].c_str( ) )
44 _TInputPixel( std::atof( args[ "mori_lower_threshold" ].c_str( ) ) ),
45 _TInputPixel( std::atof( args[ "mori_upper_threshold" ].c_str( ) ) ),
46 _TInputPixel( std::atof( args[ "mori_delta_threshold" ].c_str( ) ) )
48 double t = CTBronchi::MeasureTime( mori );
49 std::cout << "Mori executed in " << t << " s" << std::endl;
50 output = mori->GetOutput( );
52 std::map< std::string, std::string >::const_iterator i =
53 args.find( "out_mori" );
54 if( i != args.end( ) )
55 CTBronchi::WriteImage( output, i->second );
57 i = args.find( "out_signal" );
58 if( i != args.end( ) )
60 std::stringstream signal;
61 unsigned long nthr = mori->GetNumberOfEvaluatedThresholds( );
62 signal << "# nThr = " << nthr << std::endl;
63 signal << "# Opt = " << mori->GetOptimumThreshold( ) << std::endl;
64 for( unsigned long j = 0; j < nthr; ++j )
66 typename _TMori::TPeak p;
68 mori->GetSignalValues( j, x, y, p );
69 signal << x << " " << y << std::endl;
73 std::ofstream signals_str( i->second.c_str( ) );
74 signals_str << signal.str( );
78 output->DisconnectPipeline( );
83 #endif // __CTBronchi__Functions__h__