X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FImageFunctorFilter.h;h=d8a7ecac73ebebf40e0d1ffe9d8a09202fc82005;hb=8eaa2cf759c39233848cdd5b8346faccbea4c172;hp=782526f3998265f84c23c85bba98c26e4acd9f20;hpb=2361f4f97631e09d88d8a5510a369817dcaa19db;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/ImageFunctorFilter.h b/lib/cpExtensions/Algorithms/ImageFunctorFilter.h index 782526f..d8a7eca 100644 --- a/lib/cpExtensions/Algorithms/ImageFunctorFilter.h +++ b/lib/cpExtensions/Algorithms/ImageFunctorFilter.h @@ -11,89 +11,89 @@ #include namespace cpExtensions +{ + namespace Algorithms { - namespace Algorithms + /** + */ + template< class I, class O, class F > + class ImageFunctorFilter + : public itk::ImageToImageFilter< I, O > { - /** - */ - template< class I, class O, class F > - class ImageFunctorFilter - : public itk::ImageToImageFilter< I, O > - { - public: - typedef ImageFunctorFilter Self; - typedef itk::ImageToImageFilter< I, O > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef I TInputImage; - typedef O TOutputImage; - typedef F TFunctor; - - typedef typename O::RegionType TRegion; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageFunctorFilter, itkImageToImageFilter ); - - itkGetMacro( Functor, F ); - itkGetConstMacro( Functor, F ); - - protected: - ImageFunctorFilter( ) - : Superclass( ) + public: + typedef ImageFunctorFilter Self; + typedef itk::ImageToImageFilter< I, O > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef I TInputImage; + typedef O TOutputImage; + typedef F TFunctor; + + typedef typename O::RegionType TRegion; + + public: + itkNewMacro( Self ); + itkTypeMacro( ImageFunctorFilter, itkImageToImageFilter ); + + itkGetMacro( Functor, F ); + itkGetConstMacro( Functor, F ); + + protected: + ImageFunctorFilter( ) + : Superclass( ) + { + } + virtual ~ImageFunctorFilter( ) + { + } + + virtual void ThreadedGenerateData( + const TRegion& region, + itk::ThreadIdType threadId + ) + { + const typename TRegion::SizeType& regionSize = region.GetSize( ); + if( regionSize[ 0 ] == 0 ) + return; + const I* in = this->GetInput( ); + O* out = this->GetOutput( 0 ); + + const size_t nLines = region.GetNumberOfPixels( ) / regionSize[ 0 ]; + itk::ProgressReporter progress( this, threadId, nLines ); + + // Define the iterators + itk::ImageScanlineConstIterator< I > inIt( in, region ); + itk::ImageScanlineIterator< O > outIt( out, region ); + + inIt.GoToBegin( ); + outIt.GoToBegin( ); + while( !inIt.IsAtEnd( ) ) { - } - virtual ~ImageFunctorFilter( ) - { - } - - virtual void ThreadedGenerateData( - const TRegion& region, - itk::ThreadIdType threadId - ) - { - const typename TRegion::SizeType& regionSize = region.GetSize( ); - if( regionSize[ 0 ] == 0 ) - return; - const I* in = this->GetInput( ); - O* out = this->GetOutput( 0 ); - - const size_t nLines = region.GetNumberOfPixels( ) / regionSize[ 0 ]; - itk::ProgressReporter progress( this, threadId, nLines ); - - // Define the iterators - itk::ImageScanlineConstIterator< I > inIt( in, region ); - itk::ImageScanlineIterator< O > outIt( out, region ); - - inIt.GoToBegin( ); - outIt.GoToBegin( ); - while( !inIt.IsAtEnd( ) ) + while( !inIt.IsAtEndOfLine( ) ) { - while( !inIt.IsAtEndOfLine( ) ) - { - outIt.Set( this->m_Functor( inIt.Get( ) ) ); - ++inIt; - ++outIt; - - } // elihw - inIt.NextLine( ); - outIt.NextLine( ); - progress.CompletedPixel( ); + outIt.Set( this->m_Functor( inIt.Get( ) ) ); + ++inIt; + ++outIt; } // elihw - } + inIt.NextLine( ); + outIt.NextLine( ); + progress.CompletedPixel( ); + + } // elihw + } - private: - // Purposely not implemented. - ImageFunctorFilter( const Self& ); - void operator=( const Self& ); + private: + // Purposely not implemented. + ImageFunctorFilter( const Self& ); + void operator=( const Self& ); - protected: - F m_Functor; - }; + protected: + F m_Functor; + }; - } // ecapseman + } // ecapseman } // ecapseman