]> Creatis software - clitk.git/blob - registration/clitkMultiResolutionPyramidRegionFilter.txx
Remove vcl_math calls
[clitk.git] / registration / clitkMultiResolutionPyramidRegionFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkMultiResolutionPyramidRegionFilter_txx
19 #define clitkMultiResolutionPyramidRegionFilter_txx
20
21 /* =================================================
22  * @file   clitkMultiResolutionPyramidRegionFilter.txx
23  * @author 
24  * @date   
25  * 
26  * @brief 
27  * 
28  ===================================================*/
29
30
31 namespace clitk
32 {
33
34   //-------------------------------------------------------------------
35   // Update with the number of dimensions
36   //-------------------------------------------------------------------
37   template<class InputImageType>
38   MultiResolutionPyramidRegionFilter<InputImageType>::MultiResolutionPyramidRegionFilter()
39   {
40     ;
41   }
42
43
44   //-------------------------------------------------------------------
45   // Update with the number of dimensions and the pixeltype
46   //-------------------------------------------------------------------
47   template <class InputImageType> 
48   void 
49   MultiResolutionPyramidRegionFilter<InputImageType>::Update()
50   {
51
52     // Compute the FixedImageRegion corresponding to each level of the 
53     // pyramid. This uses the same algorithm of the ShrinkImageFilter 
54     // since the regions should be compatible. 
55     unsigned int numberOfLevels=m_Schedule.rows();
56     m_RegionPyramid.reserve( numberOfLevels );
57     m_RegionPyramid.resize( numberOfLevels );
58     SizeType inputSize =m_Region.GetSize();
59     IndexType inputStart =m_Region.GetIndex();
60
61     for ( unsigned int level=0; level < numberOfLevels; level++ )
62       {
63         
64         SizeType  size;
65         IndexType start;
66         for ( unsigned int dim = 0; dim < InputImageDimension; dim++)
67           {
68             const float scaleFactor = static_cast<float>( m_Schedule[ level ][ dim ] );
69             
70             size[ dim ] = static_cast<typename SizeType::SizeValueType>(
71                 std::floor(static_cast<float>( inputSize[ dim ] ) / scaleFactor ) );
72             if( size[ dim ] < 1 )
73               {
74                 size[ dim ] = 1;
75               }
76             
77             start[ dim ] = static_cast<typename IndexType::IndexValueType>(
78                   std::ceil(static_cast<float>( inputStart[ dim ] ) / scaleFactor ) );
79           }
80         m_RegionPyramid[ level ].SetSize( size );
81         m_RegionPyramid[ level ].SetIndex( start );
82     }
83   }
84
85
86 }//end clitk
87  
88 #endif //#define clitkMultiResolutionPyramidRegionFilter_txx