-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __CTBronchi__MoriLabelling__hxx__
-#define __CTBronchi__MoriLabelling__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-typename CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-TInputValue CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-GetUpperThreshold( ) const
-{
- return( this->m_Functor->GetUpperThreshold( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-SetUpperThreshold( TInputValue t )
-{
- this->m_Functor->SetUpperThreshold( t );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-MoriLabelling( )
- : Superclass( ),
- m_LastThreshold( TInputValue( 0 ) )
-{
- fpaFilterInputConfigureMacro( InputLabels, TLabelImage );
- this->m_Functor = TFunctor::New( );
- this->SetPredicate( this->m_Functor );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-~MoriLabelling( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-const itk::DataObject*
-CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-_GetReferenceInput( ) const
-{
- return( this->GetInputLabels( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TInputImage, class _TLabelImage >
-void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
-_PostComputeOutputValue( TNode& n )
-{
- this->Superclass::_PostComputeOutputValue( n );
- if( n.Value == this->GetInsideValue( ) )
- {
- const _TInputImage* input = this->GetInput( );
- const TLabelImage* labels = this->GetInputLabels( );
- double x = input->GetPixel( n.Vertex );
- /* TODO
- double a = std::fabs( x - double( this->m_Functor->GetUpperThreshold( ) ) );
- double b = std::fabs( x - double( this->m_LastThreshold ) );
- */
- if( labels->GetPixel( n.Vertex ) == 0 /* && b < a*/ )
- n.Value = 0;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-namespace CTBronchi
-{
- template< class _TInputPtr, class _TOutputPtr, class _TInputValue >
- void Label(
- _TOutputPtr& output,
- const _TInputPtr& input, const _TOutputPtr& input_labels,
- const _TInputValue& last_thr,
- std::map< std::string, std::string >& args
- )
- {
- typedef typename _TInputPtr::ObjectType _TInput;
- typedef typename _TOutputPtr::ObjectType _TOutput;
- typedef CTBronchi::MoriLabelling< _TInput, _TOutput > _TLabelling;
-
- typename _TLabelling::Pointer labelling = _TLabelling::New( );
- labelling->SetInput( input );
- labelling->SetInputLabels( input_labels );
- labelling->SetOutsideValue( 2 );
- labelling->SetInsideValue( 1 );
- labelling->SetUpperThreshold(
- _TInputValue( std::atof( args[ "labelling_upper_threshold" ].c_str( ) ) )
- );
- labelling->SetLastThreshold( last_thr );
- double t = MeasureTime( labelling );
- std::cout << "Labelling executed in " << t << " s" << std::endl;
- output = labelling->GetOutput( );
- std::map< std::string, std::string >::const_iterator i =
- args.find( "out_labels" );
- if( i != args.end( ) )
- WriteImage( output, i->second );
- output->DisconnectPipeline( );
- }
-
-} // ecapseman
-#endif // __CTBronchi__MoriLabelling__hxx__
-
-// eof - $RCSfile$