X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FImageFunctionFilter.h;h=39007a5988de88db127ff7fb4cc55743876702cc;hb=b6c7e73ebcce23619daced67f85d9e1364b33f30;hp=c025bcb30837580abecb12ddb8e7f18273ffa272;hpb=2361f4f97631e09d88d8a5510a369817dcaa19db;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h index c025bcb..39007a5 100644 --- a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h +++ b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h @@ -11,93 +11,95 @@ #include namespace cpExtensions +{ + namespace Algorithms { - namespace Algorithms + /** + */ + template< class I, class O, class F > + class ImageFunctionFilter + : public itk::ImageToImageFilter< I, O > { - /** - */ - template< class I, class O, class F > - class ImageFunctionFilter - : public itk::ImageToImageFilter< I, O > - { - public: - typedef ImageFunctionFilter 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 TFunction; - - typedef typename O::RegionType TRegion; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageFunctionFilter, itkImageToImageFilter ); - - itkGetObjectMacro( Function, F ); - itkSetObjectMacro( Function, F ); - - protected: - ImageFunctionFilter( ) - : Superclass( ) + public: + typedef ImageFunctionFilter 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 TFunction; + + typedef typename O::RegionType TRegion; + + public: + itkNewMacro( Self ); + itkTypeMacro( ImageFunctionFilter, itkImageToImageFilter ); + + itkGetObjectMacro( Function, F ); + itkSetObjectMacro( Function, F ); + + protected: + ImageFunctionFilter( ) + : Superclass( ) + { + } + virtual ~ImageFunctionFilter( ) + { + } + + 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 ~ImageFunctionFilter( ) - { - } - - 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_Function->EvaluateAtIndex( inIt.GetIndex( ) ) ); - ++inIt; - ++outIt; - - } // elihw - inIt.NextLine( ); - outIt.NextLine( ); - progress.CompletedPixel( ); + outIt.Set( this->m_Function->EvaluateAtIndex( inIt.GetIndex( ) ) ); + ++inIt; + ++outIt; } // elihw - } + inIt.NextLine( ); + outIt.NextLine( ); + progress.CompletedPixel( ); + + } // elihw + } - private: - // Purposely not implemented. - ImageFunctionFilter( const Self& ); - void operator=( const Self& ); + private: + // Purposely not implemented. + ImageFunctionFilter( const Self& ); + void operator=( const Self& ); - protected: - typename F::Pointer m_Function; - }; + protected: + typename F::Pointer m_Function; + }; - } // ecapseman + } // ecapseman } // ecapseman +#ifndef ITK_MANUAL_INSTANTIATION // TODO: #include +#endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__IMAGEFUNCTIONFILTER__H__