]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Image/MoriFilter.hxx
9f822c9ea9d22bd6234ddd1a823266b2727c6680
[FrontAlgorithms.git] / libs / fpa / Image / MoriFilter.hxx
1 #ifndef __fpa__Image__MoriFilter__hxx__
2 #define __fpa__Image__MoriFilter__hxx__
3
4 // -------------------------------------------------------------------------
5 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
6 typename
7 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
8 TAuxImage*
9 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
10 GetAuxiliaryImage( )
11 {
12   return( this->m_Helper->GetOutput( ) );
13 }
14
15 // -------------------------------------------------------------------------
16 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
17 const typename
18 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
19 TAuxImage*
20 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
21 GetAuxiliaryImage( ) const
22 {
23   return( this->m_Helper->GetOutput( ) );
24 }
25
26 // -------------------------------------------------------------------------
27 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
28 typename
29 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
30 TInputPixel
31 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
32 GetLower( ) const
33 {
34   return( this->m_Helper->GetLower( ) );
35 }
36
37 // -------------------------------------------------------------------------
38 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
39 typename
40 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
41 TInputPixel
42 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
43 GetUpper( ) const
44 {
45   return( this->m_Helper->GetUpper( ) );
46 }
47
48 // -------------------------------------------------------------------------
49 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
50 typename
51 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
52 TInputPixel
53 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
54 GetStep( ) const
55 {
56   return( this->m_Helper->GetStep( ) );
57 }
58
59 // -------------------------------------------------------------------------
60 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
61 typename
62 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
63 TOutputPixel
64 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
65 GetInsideValue( ) const
66 {
67   return( this->m_Threshold->GetInsideValue( ) );
68 }
69
70 // -------------------------------------------------------------------------
71 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
72 typename
73 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
74 TOutputPixel
75 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
76 GetOutsideValue( ) const
77 {
78   return( this->m_Threshold->GetInsideValue( ) );
79 }
80
81 // -------------------------------------------------------------------------
82 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
83 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
84 SetLower( const TInputPixel& v )
85 {
86   this->m_Helper->SetLower( v );
87   this->Modified( );
88 }
89
90 // -------------------------------------------------------------------------
91 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
92 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
93 SetUpper( const TInputPixel& v )
94 {
95   this->m_Helper->SetUpper( v );
96   this->Modified( );
97 }
98
99 // -------------------------------------------------------------------------
100 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
101 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
102 SetStep( const TInputPixel& v )
103 {
104   this->m_Helper->SetStep( v );
105   this->Modified( );
106 }
107
108 // -------------------------------------------------------------------------
109 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
110 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
111 SetThresholdRange(
112   const TInputPixel& l, const TInputPixel& u, const TInputPixel& s
113   )
114 {
115   this->SetLower( l );
116   this->SetUpper( u );
117   this->SetStep( s );
118 }
119
120 // -------------------------------------------------------------------------
121 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
122 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
123 SetInsideValue( const TOutputPixel& v )
124 {
125   this->m_Threshold->SetInsideValue( v );
126   this->Modified( );
127 }
128
129 // -------------------------------------------------------------------------
130 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
131 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
132 SetOutsideValue( const TOutputPixel& v )
133 {
134   this->m_Threshold->SetOutsideValue( v );
135   this->Modified( );
136 }
137
138 // -------------------------------------------------------------------------
139 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
140 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
141 MoriFilter( )
142   : Superclass( )
143 {
144   this->m_Helper = THelper::New( );
145   this->m_Threshold = TThreshold::New( );
146 }
147
148 // -------------------------------------------------------------------------
149 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
150 fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
151 ~MoriFilter( )
152 {
153 }
154
155 // -------------------------------------------------------------------------
156 template< class _TInputImage, class _TOutputImage, class _TAuxPixel >
157 void fpa::Image::MoriFilter< _TInputImage, _TOutputImage, _TAuxPixel >::
158 GenerateData( )
159 {
160   this->m_Helper->ClearSeeds( );
161   this->m_Helper->AddSeed( this->m_Seed, this->GetOutsideValue( ) );
162   this->m_Helper->SetInput( this->GetInput( ) );
163   this->m_Helper->Update( );
164
165   this->m_Threshold->SetInput( this->m_Helper->GetOutput( ) );
166   this->m_Threshold->SetLowerThreshold( std::numeric_limits< _TAuxPixel >::min( ) );
167   this->m_Threshold->SetUpperThreshold( this->m_Helper->GetOptimumThreshold( ) );
168   this->m_Threshold->Update( );
169   this->GetOutput( )->Graft( this->m_Threshold->GetOutput( ) );
170 }
171
172 #endif // __fpa__Image__MoriFilter__hxx__
173
174 // eof - $RCSfile$