1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
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
21 /* =================================================
22 * @file clitkMultiResolutionPyramidRegionFilter.txx
28 ===================================================*/
34 //-------------------------------------------------------------------
35 // Update with the number of dimensions
36 //-------------------------------------------------------------------
37 template<class InputImageType>
38 MultiResolutionPyramidRegionFilter<InputImageType>::MultiResolutionPyramidRegionFilter()
44 //-------------------------------------------------------------------
45 // Update with the number of dimensions and the pixeltype
46 //-------------------------------------------------------------------
47 template <class InputImageType>
49 MultiResolutionPyramidRegionFilter<InputImageType>::Update()
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();
61 for ( unsigned int level=0; level < numberOfLevels; level++ )
66 for ( unsigned int dim = 0; dim < InputImageDimension; dim++)
68 const float scaleFactor = static_cast<float>( m_Schedule[ level ][ dim ] );
70 size[ dim ] = static_cast<typename SizeType::SizeValueType>(
71 vcl_floor(static_cast<float>( inputSize[ dim ] ) / scaleFactor ) );
77 start[ dim ] = static_cast<typename IndexType::IndexValueType>(
78 vcl_ceil(static_cast<float>( inputStart[ dim ] ) / scaleFactor ) );
80 m_RegionPyramid[ level ].SetSize( size );
81 m_RegionPyramid[ level ].SetIndex( start );
88 #endif //#define clitkMultiResolutionPyramidRegionFilter_txx