TInputValue CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
GetUpperThreshold( ) const
{
- return( this->m_LabelFunctor->GetUpperThreshold( ) );
+ return( this->m_Functor->GetUpperThreshold( ) );
}
// -------------------------------------------------------------------------
void CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
SetUpperThreshold( TInputValue t )
{
- this->m_LabelFunctor->SetUpperThreshold( t );
+ this->m_Functor->SetUpperThreshold( t );
}
// -------------------------------------------------------------------------
template< class _TInputImage, class _TLabelImage >
CTBronchi::MoriLabelling< _TInputImage, _TLabelImage >::
MoriLabelling( )
- : Superclass( )
+ : Superclass( ),
+ m_LastThreshold( TInputValue( 0 ) )
{
- this->m_LabelFunctor = TLabelFunctor::New( );
- this->SetPredicate( this->m_LabelFunctor );
+ fpaFilterInputConfigureMacro( InputLabels, TLabelImage );
+ this->m_Functor = TFunctor::New( );
+ this->SetPredicate( this->m_Functor );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+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 >::
-_UpdateOutputValue( TNode& n )
+_PostComputeOutputValue( TNode& n )
{
- this->TBase::_UpdateOutputValue( n );
- if( n.FrontId != 0 )
+ this->Superclass::_PostComputeOutputValue( n );
+ if( n.Value == this->GetInsideValue( ) )
{
- const TLabelImage* input_labels = this->GetInputLabels( );
- if( input_labels->GetPixel( n.Vertex ) != this->GetInputInsideValue( ) )
- n.Value = TOutputValue( 0 );
- else
- 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
- this->GetOutput( )->SetPixel( n.Vertex, n.Value );
}
+// -------------------------------------------------------------------------
+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$