]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/Mori.hxx
...
[FrontAlgorithms.git] / lib / fpa / Image / Mori.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__Mori__hxx__
7 #define __fpa__Image__Mori__hxx__
8
9 #include <itkBinaryThresholdImageFilter.h>
10
11 // -------------------------------------------------------------------------
12 template< class _TInputImage, class _TOutputImage >
13 typename fpa::Image::Mori< _TInputImage, _TOutputImage >::
14 TOutputImage* fpa::Image::Mori< _TInputImage, _TOutputImage >::
15 GetThresholdedOutput( )
16 {
17   return(
18     dynamic_cast< TOutputImage* >(
19       this->itk::ProcessObject::GetOutput( this->m_ThresholdedOutputIdx )
20       )
21     );
22 }
23
24 // -------------------------------------------------------------------------
25 template< class _TInputImage, class _TOutputImage >
26 const typename fpa::Image::Mori< _TInputImage, _TOutputImage >::
27 TOutputImage* fpa::Image::Mori< _TInputImage, _TOutputImage >::
28 GetThresholdedOutput( ) const
29 {
30   return(
31     dynamic_cast< const TOutputImage* >(
32       this->itk::ProcessObject::GetOutput( this->m_ThresholdedOutputIdx )
33       )
34     );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TInputImage, class _TOutputImage >
39 fpa::Image::Mori< _TInputImage, _TOutputImage >::
40 Mori( )
41   : Superclass( )
42 {
43   this->m_ThresholdedOutputIdx = this->GetNumberOfRequiredOutputs( );
44   this->itk::ProcessObject::SetNumberOfRequiredOutputs(
45     this->m_ThresholdedOutputIdx + 1
46     );
47   this->SetNthOutput( this->m_ThresholdedOutputIdx, TOutputImage::New( ) );
48 }
49
50 // -------------------------------------------------------------------------
51 template< class _TInputImage, class _TOutputImage >
52 fpa::Image::Mori< _TInputImage, _TOutputImage >::
53 ~Mori( )
54 {
55 }
56
57 // -------------------------------------------------------------------------
58 template< class _TInputImage, class _TOutputImage >
59 void fpa::Image::Mori< _TInputImage, _TOutputImage >::
60 _AfterGenerateData( )
61 {
62   typedef itk::BinaryThresholdImageFilter< TMarks, TOutputImage > _TFilter;
63
64   this->Superclass::_AfterGenerateData( );
65
66   typename _TFilter::Pointer filter = _TFilter::New( );
67   filter->SetInput( this->GetMarks( ) );
68   filter->SetInsideValue( this->GetInsideValue( ) );
69   filter->SetOutsideValue( this->GetOutsideValue( ) );
70   filter->SetLowerThreshold( 1 );
71   filter->SetUpperThreshold( this->GetNumberOfEvaluatedThresholds( ) - 1 );
72   filter->Update( );
73   this->GetThresholdedOutput( )->Graft( filter->GetOutput( ) );
74 }
75
76 #endif // __fpa__Image__Mori__hxx__
77
78 // eof - $RCSfile$