// ========================================================================= // @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, class _TSeed > typename _TInputPtr::ObjectType::PixelType Mori( _TOutputPtr& output, const _TInputPtr& input, _TSeed& seed, 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; typedef typename _TOutput::PixelType _TOutputPixel; _TOutputPixel i_val = _TOutputPixel( 1 ); _TOutputPixel o_val = _TOutputPixel( 0 ); typename _TMori::Pointer mori = _TMori::New( ); mori->SetInput( input ); mori->SetSeed( seed ); mori->SetInsideValue( i_val ); mori->SetOutsideValue( o_val ); 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( ); return( mori->GetOptimumThreshold( ) ); } } // ecapseman #endif // __CTBronchi__Functions__h__ // eof - $RCSfile$