X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FImageFunctorFilter.hxx;fp=lib%2FcpExtensions%2FAlgorithms%2FImageFunctorFilter.hxx;h=73777daaa0fb55656d1c96a0cc92a834786f8bec;hb=9947c770b79585f718013305a956cf9473a4e0b2;hp=0000000000000000000000000000000000000000;hpb=9af34b55ea1d60eef3608aede00f9ef5a16dccdf;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/ImageFunctorFilter.hxx b/lib/cpExtensions/Algorithms/ImageFunctorFilter.hxx new file mode 100644 index 0000000..73777da --- /dev/null +++ b/lib/cpExtensions/Algorithms/ImageFunctorFilter.hxx @@ -0,0 +1,65 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpExtensions__Algorithms__ImageFunctorFilter__hxx__ +#define __cpExtensions__Algorithms__ImageFunctorFilter__hxx__ + +#include +#include +#include + +// ------------------------------------------------------------------------- +template< class _TInputImage, class _TOutputImage > +cpExtensions::Algorithms::ImageFunctorFilter< _TInputImage, _TOutputImage >:: +ImageFunctorFilter( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TInputImage, class _TOutputImage > +cpExtensions::Algorithms::ImageFunctorFilter< _TInputImage, _TOutputImage >:: +~ImageFunctorFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TInputImage, class _TOutputImage > +void +cpExtensions::Algorithms::ImageFunctorFilter< _TInputImage, _TOutputImage >:: +ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) +{ + // Configure data for this thread + const typename TRegion::SizeType& regionSize = region.GetSize( ); + if( regionSize[ 0 ] == 0 ) + return; + const TInputImage* in = this->GetInput( ); + TOutputImage* out = this->GetOutput( 0 ); + const size_t nLines = region.GetNumberOfPixels( ) / regionSize[ 0 ]; + itk::ProgressReporter progress( this, threadId, nLines ); + + // Iterate over this region + itk::ImageScanlineConstIterator< TInputImage > iIt( in, region ); + itk::ImageScanlineIterator< TOutputImage > oIt( out, region ); + iIt.GoToBegin( ); + oIt.GoToBegin( ); + while( !iIt.IsAtEnd( ) ) + { + while( !iIt.IsAtEndOfLine( ) ) + { + oIt.Set( this->m_Functor->Evaluate( iIt.Get( ) ) ); + ++iIt; + ++oIt; + + } // elihw + iIt.NextLine( ); + oIt.NextLine( ); + progress.CompletedPixel( ); + + } // elihw +} + +#endif // __cpExtensions__Algorithms__ImageFunctorFilter__hxx__ + +// eof - $RCSfile$