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