X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FImageFunctionFilter.h;h=731f0f5a9a6926fb784401201b1d333fc95bbad2;hb=201c5026430f9bcc33f9db6a39f5d03db096c860;hp=39007a5988de88db127ff7fb4cc55743876702cc;hpb=a3cae0375976d524c957493a3cc565b9f5b20bce;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h index 39007a5..731f0f5 100644 --- a/lib/cpExtensions/Algorithms/ImageFunctionFilter.h +++ b/lib/cpExtensions/Algorithms/ImageFunctionFilter.h @@ -6,9 +6,6 @@ #define __CPEXTENSIONS__ALGORITHMS__IMAGEFUNCTIONFILTER__H__ #include -#include -#include -#include namespace cpExtensions { @@ -16,73 +13,38 @@ namespace cpExtensions { /** */ - template< class I, class O, class F > + template< class _TInput, class _TOutput, class _TFunction > class ImageFunctionFilter - : public itk::ImageToImageFilter< I, O > + : public itk::ImageToImageFilter< _TInput, _TOutput > { public: - typedef ImageFunctionFilter Self; - typedef itk::ImageToImageFilter< I, O > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; + typedef ImageFunctionFilter Self; + typedef itk::ImageToImageFilter< _TInput, _TOutput > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; - typedef I TInputImage; - typedef O TOutputImage; - typedef F TFunction; + typedef _TInput TInput; + typedef _TOutput TOutput; + typedef _TFunction TFunction; - typedef typename O::RegionType TRegion; + typedef typename TOutput::RegionType TRegion; public: itkNewMacro( Self ); itkTypeMacro( ImageFunctionFilter, itkImageToImageFilter ); - itkGetObjectMacro( Function, F ); - itkSetObjectMacro( Function, F ); + itkGetObjectMacro( Function, TFunction ); + itkSetObjectMacro( Function, TFunction ); protected: - ImageFunctionFilter( ) - : Superclass( ) - { - } - virtual ~ImageFunctionFilter( ) - { - } + ImageFunctionFilter( ); + virtual ~ImageFunctionFilter( ); + virtual void BeforeThreadedGenerateData( ) ITK_OVERRIDE; 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( ) ) - { - outIt.Set( this->m_Function->EvaluateAtIndex( inIt.GetIndex( ) ) ); - ++inIt; - ++outIt; - - } // elihw - inIt.NextLine( ); - outIt.NextLine( ); - progress.CompletedPixel( ); - - } // elihw - } + ) ITK_OVERRIDE; private: // Purposely not implemented. @@ -90,7 +52,7 @@ namespace cpExtensions void operator=( const Self& ); protected: - typename F::Pointer m_Function; + typename TFunction::Pointer m_Function; }; } // ecapseman @@ -98,7 +60,7 @@ namespace cpExtensions } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION -// TODO: #include +#include #endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__IMAGEFUNCTIONFILTER__H__