]> Creatis software - FrontAlgorithms.git/blob - libs/fpa/Image/MinimumSpanningTreeToImageFilter.hxx
...
[FrontAlgorithms.git] / libs / fpa / Image / MinimumSpanningTreeToImageFilter.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
7 #define __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
8
9 // -------------------------------------------------------------------------
10 template< class _TMST, class _TOutputPixelValue >
11 void fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
12 AddPath(
13   const TIndex& start, const TIndex& end,
14   const TOutputPixelValue& r,
15   const TOutputPixelValue& g,
16   const TOutputPixelValue& b
17   )
18 {
19   if( start != end )
20   {
21     TPathData d;
22     d.Start = start;
23     d.End = end;
24     d.Red = r;
25     d.Green = g;
26     d.Blue = b;
27     this->m_Paths.push_back( d );
28     this->Modified( );
29
30   } // fi
31 }
32
33 // -------------------------------------------------------------------------
34 template< class _TMST, class _TOutputPixelValue >
35 fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
36 MinimumSpanningTreeToImageFilter( )
37   : Superclass( )
38 {
39 }
40
41 // -------------------------------------------------------------------------
42 template< class _TMST, class _TOutputPixelValue >
43 fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
44 ~MinimumSpanningTreeToImageFilter( )
45 {
46 }
47
48 // -------------------------------------------------------------------------
49 template< class _TMST, class _TOutputPixelValue >
50 void fpa::Image::MinimumSpanningTreeToImageFilter< _TMST, _TOutputPixelValue >::
51 GenerateData( )
52 {
53   TOutputPixel color;
54   color.Fill( 0 );
55
56   const TMST* mst = this->GetInput( );
57   TOutputImage* output = this->GetOutput( );
58   output->SetBufferedRegion( mst->GetBufferedRegion( ) );
59   output->Allocate( );
60   output->FillBuffer( color );
61
62   for( TPathData d: this->m_Paths )
63   {
64     typename TMST::TVertices path = mst->GetPath( d.Start, d.End );
65     color[ 0 ] = d.Red;
66     color[ 1 ] = d.Green;
67     color[ 2 ] = d.Blue;
68     color[ 3 ] = std::numeric_limits< TOutputPixelValue >::max( );
69     for( TIndex i: path )
70       output->SetPixel( i, color );
71
72   } // rof
73 }
74
75 #endif // __fpa__Image__MinimumSpanningTreeToImageFilter__hxx__
76
77 // eof - $RCSfile$