- /**
- */
- 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( ) )