X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FcpExtensions%2FAlgorithms%2FRGBImageToOtherChannelsFilter.hxx;h=74578d457c6a8bcf3bdd0514779dcf2ebc07a5ee;hb=8ebfdf11e4b5d2a5b3a0c2b4752d176888f0bb16;hp=3c8f49d016842d7854bf26a46743399c97ac6d17;hpb=2361f4f97631e09d88d8a5510a369817dcaa19db;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx index 3c8f49d..74578d4 100644 --- a/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx +++ b/lib/cpExtensions/Algorithms/RGBImageToOtherChannelsFilter.hxx @@ -12,99 +12,6 @@ #include #include -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel1( ) -{ - return( this->GetOutput( 0 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel2( ) -{ - return( this->GetOutput( 1 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel3( ) -{ - return( this->GetOutput( 2 ) ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel1( ) const -{ - if( this->GetNumberOfOutputs( ) > 0 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 0 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel2( ) const -{ - if( this->GetNumberOfOutputs( ) > 1 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 1 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -const O* cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GetChannel3( ) const -{ - if( this->GetNumberOfOutputs( ) > 2 ) - return( - dynamic_cast< const O* >( - this->itk::ProcessObject::GetOutput( 2 ) - ) - ); - else - return( NULL ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel1( O* hue ) -{ - this->GraftNthOutput( 0, hue ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel2( O* saturation ) -{ - this->GraftNthOutput( 1, saturation ); -} - -// ------------------------------------------------------------------------- -template< class I, class O, class C > -void cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: -GraftChannel3( O* value ) -{ - this->GraftNthOutput( 2, value ); -} - // ------------------------------------------------------------------------- template< class I, class O, class C > cpExtensions::Algorithms::RGBImageToOtherChannelsFilter< I, O, C >:: @@ -112,13 +19,10 @@ RGBImageToOtherChannelsFilter( ) : Superclass( ) { this->SetNumberOfRequiredInputs( 1 ); - this->SetNumberOfRequiredOutputs( 3 ); - for( unsigned int i = 0; i < 3; i++ ) - { - typename O::Pointer o = O::New( ); - this->SetNthOutput( i, o ); + this->SetNumberOfRequiredOutputs( 1 ); - } // rof + typename O::Pointer o = O::New( ); + this->SetNthOutput( 0, o ); } // ------------------------------------------------------------------------- @@ -153,24 +57,13 @@ ThreadedGenerateData( // typedef typename TInputPixel::ComponentType _TComponent; typedef itk::ImageRegionConstIterator< I > _TInIt; typedef itk::ImageRegionIterator< O > _TOutIt; - typedef typename C::TOutPixel _TOutPixel; _TInIt inIt( this->GetInput( ), region ); - _TOutIt hIt( this->GetChannel1( ), region ); - _TOutIt sIt( this->GetChannel2( ), region ); - _TOutIt vIt( this->GetChannel3( ), region ); + _TOutIt outIt( this->GetOutput( ), region ); inIt.GoToBegin( ); - hIt.GoToBegin( ); - sIt.GoToBegin( ); - vIt.GoToBegin( ); - for( ; !inIt.IsAtEnd( ); ++inIt, ++hIt, ++sIt, ++vIt ) - { - _TOutPixel other = this->Converter( inIt.Get( ) ); - hIt.Set( other[ 0 ] ); - sIt.Set( other[ 1 ] ); - vIt.Set( other[ 2 ] ); - - } // rof + outIt.GoToBegin( ); + for( ; !inIt.IsAtEnd( ); ++inIt, ++outIt ) + outIt.Set( this->Converter( inIt.Get( ) ) ); } #endif // __CPEXTENSIONS__ALGORITHMS__RGBIMAGETOOTHERCHANNELSFILTER__HXX__