34 #ifndef AIMS_PYRAMID_SUBSAMPLINGPYRAMID_D_H
35 #define AIMS_PYRAMID_SUBSAMPLINGPYRAMID_D_H
50 _factor( 1,
Point4du(factor, factor, factor, factor) ),
79 _subsampler( other._subsampler ),
80 _factor( other._factor ),
82 _verbose( other._verbose )
108 template <
typename S>
114 template <
typename S>
120 template <
typename S>
123 _factor.assign( 1,
Point4du( r, r, r, r ) );
126 template <
typename S>
129 _factor.assign( 1, r );
132 template <
typename S>
138 template <
typename S>
144 template <
typename S>
147 _dir.assign( 4,
true );
149 for(
size_t i = 0; i < dir.size() && i < _dir.size(); ++i )
153 template <
typename S>
162 template <
typename S>
168 template <
typename S>
178 template <
typename S>
179 template <
typename T>
182 std::vector<Point4du> factors = computeFactors( vol.
getSize() );
183 std::vector<carto::VolumeRef<T> > pyramid;
184 pyramid.reserve( factors.size() + 1 );
185 _subsampler.setVerbose( _verbose - 1 );
189 std::cout <<
"Copy first level... " << std::endl;
193 std::vector<Point4du>::iterator f;
195 for( f = factors.begin(); f != factors.end(); ++f, ++l )
198 std::cout <<
"Compute subsampled level " << l <<
"... " << std::endl;
201 std::cout <<
"Moving average filter/subsampling: " << std::flush;
202 _subsampler.setFactor( *f );
203 _subsampler.setDirections( _dir[0] && (*f)[0] > 1,
204 _dir[1] && (*f)[1] > 1,
205 _dir[2] && (*f)[2] > 1,
206 _dir[3] && (*f)[3] > 1 );
207 pyramid.push_back( _subsampler.template execute<T,T>( pyramid[l-1] ) );
216 template <
typename S>
219 std::vector<Point4du> factors;
220 if( _factor.size() > 1 )
226 unsigned nlevels = 0;
227 Point4dl level_size( size[0], size[1], size[2], size[3] );
232 for(
int i = 0; i < 4; ++i )
235 level_size[i] /= _factor[0][i];
236 if( level_size[i] == 1 )
241 factors.assign( nlevels, _factor[0] );
244 Point4dl level_size( size[0], size[1], size[2], size[3] );
245 for( std::vector<Point4du>::iterator f = factors.begin();
246 f != factors.end(); ++f )
248 for(
int i = 0; i < 4; ++i )
252 if( level_size[i] / (*f)[i] == 0 )
255 level_size[i] /= (*f)[i];
262 factors.erase( f, factors.end() );
std::vector< Point4du > _factor
std::vector< carto::VolumeRef< T > > execute(const carto::VolumeRef< T > &vol)
Execution.
std::vector< Point4du > computeFactors(const std::vector< int > &size) const
void setVerbose(int verbose=1)
virtual ~SubSamplingPyramidBuilder()
const std::vector< Point4du > & factor() const
const std::vector< bool > & directions() const
Parameters.
void setFactor(unsigned r)
void setSubSampler(const SubSampler &f)
void setDirections(const std::vector< bool > &dir)
SubSamplingPyramidBuilder & operator=(const SubSamplingPyramidBuilder &other)
SubSamplingPyramidBuilder(const SubSampler &f, unsigned factor=2)
Constructors / Destructors / Copy.
std::vector< int > getSize() const
Volume< T > copy(const Volume< T > &src)