]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx
yet another refactoring
[cpPlugins.git] / lib / cpExtensions / Algorithms / RGBImageToOtherChannelsFilter.hxx
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
6 #define __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
7
8 #include <cmath>
9 #include <limits>
10 #include <vnl/vnl_math.h>
11
12 #include <itkImageRegionIterator.h>
13 #include <itkImageRegionConstIterator.h>
14
15 // -------------------------------------------------------------------------
16 template< class I, class O, class C >
17 cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
18 RGBImageToOtherChannelsFilter( )
19   : Superclass( )
20 {
21   this->SetNumberOfRequiredInputs( 1 );
22   this->SetNumberOfRequiredOutputs( 1 );
23
24   typename O::Pointer o = O::New( );
25   this->SetNthOutput( 0, o );
26 }
27
28 // -------------------------------------------------------------------------
29 template< class I, class O, class C >
30 cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
31 ~RGBImageToOtherChannelsFilter( )
32 {
33 }
34
35 // -------------------------------------------------------------------------
36 template< class I, class O, class C >
37 void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
38 BeforeThreadedGenerateData( )
39 {
40 }
41
42 // -------------------------------------------------------------------------
43 template< class I, class O, class C >
44 void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
45 AfterThreadedGenerateData( )
46 {
47 }
48
49 // -------------------------------------------------------------------------
50 template< class I, class O, class C >
51 void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >::
52 ThreadedGenerateData(
53   const typename Superclass::OutputImageRegionType& region,
54   itk::ThreadIdType threadId
55   )
56 {
57   // typedef typename TInputPixel::ComponentType _TComponent;
58   typedef itk::ImageRegionConstIterator< I > _TInIt;
59   typedef itk::ImageRegionIterator< O >      _TOutIt;
60
61   _TInIt inIt( this->GetInput( ), region );
62   _TOutIt outIt( this->GetOutput( ), region );
63   inIt.GoToBegin( );
64   outIt.GoToBegin( );
65   for( ; !inIt.IsAtEnd( ); ++inIt, ++outIt )
66     outIt.Set( this->Converter( inIt.Get( ) ) );
67 }
68
69 #endif // __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__
70
71 // eof - $RCSfile$