]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/ParallelImageMean.h
f34ca6e5f2cf7bb9cc62179c44851625f1dc2786
[cpPlugins.git] / lib / cpExtensions / Algorithms / ParallelImageMean.h
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #ifndef __CPEXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__H__
6 #define __CPEXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__H__
7
8 #include <itkDomainThreader.h>
9 #include <itkThreadedImageRegionPartitioner.h>
10 #include <itkArray.h>
11 #include <itkNumericTraits.h>
12
13 namespace cpExtensions
14   {
15     namespace Algorithms
16     {
17       /**
18        */
19       template< class I >
20       class ParallelImageMean
21         : public itk::DomainThreader< itk::ThreadedImageRegionPartitioner< I::ImageDimension >, I >
22       {
23       public:
24         // Standard ITK typedefs.
25         typedef itk::DomainThreader< itk::ThreadedImageRegionPartitioner< I::ImageDimension >, I > Superclass;
26         typedef ParallelImageMean               Self;
27         typedef itk::SmartPointer< Self >       Pointer;
28         typedef itk::SmartPointer< const Self > ConstPointer;
29
30         typedef typename Superclass::DomainType DomainType;
31
32         typedef itk::Array< double > TMean;
33
34       protected:
35         typedef itk::NumericTraits< typename I::PixelType > _TPixelTraits;
36
37
38       public:
39         itkNewMacro( Self );
40         itkTypeMacro( ParallelImageMean, itkDomainThreader );
41
42         itkGetConstMacro( Mean, TMean );
43
44       protected:
45         ParallelImageMean( );
46         virtual ~ParallelImageMean( );
47
48       private:
49         virtual void BeforeThreadedExecution( );
50         virtual void ThreadedExecution(
51           const DomainType& region, const itk::ThreadIdType id
52           );
53         virtual void AfterThreadedExecution( );
54
55       protected:
56         itk::Array< double > m_Mean;
57         unsigned long m_N;
58       };
59
60     } // ecapseman
61
62 } // ecapseman
63
64 #include <cpExtensions/Algorithms/ParallelImageMean.hxx>
65
66 #endif // __CPEXTENSIONS__ALGORITHMS__PARALLELIMAGEMEAN__H__
67
68 // eof - $RCSfile$