1 // This is core/vil1/vil1_pyramid.cxx
2 //:
3 // \file
4 // \author fsm
5 
6 #include <iostream>
7 #include "vil1_pyramid.h"
8 #include <cassert>
9 #ifdef _MSC_VER
10 #  include "vcl_msvc_warnings.h"
11 #endif
12 #include "vil1/vil1_resample.h"
13 #include "vil1/vil1_memory_image.h"
14 
vil1_pyramid(vil1_image const & I,cache_strategy cs_)15 vil1_pyramid::vil1_pyramid(vil1_image const & I, cache_strategy cs_)
16 {
17   cs = cs_;
18   levels.push_back(I);
19 }
20 
21 vil1_pyramid::~vil1_pyramid() = default;
22 
operator [](unsigned i)23 vil1_image vil1_pyramid::operator[](unsigned i)
24 {
25   while (i >= levels.size())
26   {
27     std::cerr << "making pyramid level " << levels.size() << std::endl;
28     vil1_image I = levels.back();
29     I = vil1_resample(I, I.width() / 2, I.height() / 2);
30     switch (cs)
31     {
32       case none:
33         break;
34       case memory:
35         I = vil1_memory_image(I /*, "silly hack"*/);
36         break;
37       case blocked: /* not implemented yet */
38       default:
39         assert(!"not implemented");
40         break;
41     }
42     levels.push_back(I);
43   }
44   return levels[i];
45 }
46