1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__HXX__
6 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__HXX__
8 #include <itkImageRegionConstIterator.h>
10 // -------------------------------------------------------------------------
12 cpPlugins::Extensions::Algorithms::ParallelImageMean< I >::
18 // -------------------------------------------------------------------------
20 cpPlugins::Extensions::Algorithms::ParallelImageMean< I >::
25 // -------------------------------------------------------------------------
27 void cpPlugins::Extensions::Algorithms::ParallelImageMean< I >::
28 BeforeThreadedExecution( )
30 this->m_Mean.SetSize( _TPixelTraits::GetLength( ) );
31 this->m_Mean.Fill( double( 0 ) );
35 // -------------------------------------------------------------------------
37 void cpPlugins::Extensions::Algorithms::ParallelImageMean< I >::
38 ThreadedExecution( const DomainType& region, const itk::ThreadIdType id )
40 itk::ImageRegionConstIterator< I > i( this->m_Associate, region );
41 for( i.GoToBegin( ); !i.IsAtEnd( ); ++i )
43 for( unsigned int d = 0; d < _TPixelTraits::GetLength( ); ++d )
45 this->m_Mean.SetElement(
46 d, this->m_Mean.GetElement( d ) + double( i.Get( )[ d ] )
55 // -------------------------------------------------------------------------
57 void cpPlugins::Extensions::Algorithms::ParallelImageMean< I >::
58 AfterThreadedExecution( )
60 this->m_Mean /= double( this->m_N );
63 #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__HXX__