// ------------------------------------------------------------------------- // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ------------------------------------------------------------------------- #ifndef __CPEXTENSIONS__ALGORITHMS__GAUSSIANDENSITYIMAGEFILTER__H__ #define __CPEXTENSIONS__ALGORITHMS__GAUSSIANDENSITYIMAGEFILTER__H__ #include #include #include #include namespace cpExtensions { namespace Algorithms { /** */ template< class _TInputImage, class _TEstimator > class GaussianDensityImageFilter : public itk::ImageToImageFilter< _TInputImage, itk::Image< typename _TEstimator::TScalar, _TInputImage::ImageDimension > > { public: typedef typename _TEstimator::TScalar TScalar; typedef itk::Image< TScalar, _TInputImage::ImageDimension > TOutputImage; typedef GaussianDensityImageFilter Self; typedef itk::ImageToImageFilter< _TInputImage, TOutputImage > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; typedef _TInputImage TInputImage; typedef _TEstimator TEstimator; typedef typename TOutputImage::RegionType TRegion; public: itkNewMacro( Self ); itkTypeMacro( GaussianDensityImageFilter, itkImageToImageFilter ); itkGetConstObjectMacro( Estimator, TEstimator ); itkSetConstObjectMacro( Estimator, TEstimator ); protected: GaussianDensityImageFilter( ) : Superclass( ) { } virtual ~GaussianDensityImageFilter( ) { } virtual void ThreadedGenerateData( const TRegion& region, itk::ThreadIdType threadId ) { 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 ); // Define the iterators itk::ImageScanlineConstIterator< TInputImage > inIt( in, region ); itk::ImageScanlineIterator< TOutputImage > outIt( out, region ); inIt.GoToBegin( ); outIt.GoToBegin( ); while( !inIt.IsAtEnd( ) ) { while( !inIt.IsAtEndOfLine( ) ) { if( this->m_Estimator.IsNotNull( ) ) outIt.Set( this->m_Estimator->Density( inIt.Get( ) ) ); ++inIt; ++outIt; } // elihw inIt.NextLine( ); outIt.NextLine( ); progress.CompletedPixel( ); } // elihw } private: // Purposely not implemented. GaussianDensityImageFilter( const Self& ); void operator=( const Self& ); protected: typename TEstimator::ConstPointer m_Estimator; }; } // ecapseman } // ecapseman #endif // __CPEXTENSIONS__ALGORITHMS__GAUSSIANDENSITYIMAGEFILTER__H__ // eof - $RCSfile$