Go to the documentation of this file.00001 #ifndef vil_pyramid_image_view_h_
00002 #define vil_pyramid_image_view_h_
00003 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00004 #pragma interface
00005 #endif
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <vcl_vector.h>
00021 #include <vil/vil_image_view.h>
00022 #include <vil/vil_image_view_base.h>
00023
00024 template <class T>
00025 class vil_pyramid_image_view
00026 {
00027 public:
00028
00029 vil_pyramid_image_view(): nlevels_(0), max_levels_(256) {}
00030
00031
00032 vil_pyramid_image_view(vil_image_view_base_sptr image): nlevels_(1), max_levels_(256)
00033 { images_.push_back(image); scales_.push_back(1.0); }
00034
00035
00036 vil_pyramid_image_view(const vil_image_view<T>& image): nlevels_(1), max_levels_(256)
00037 { images_.push_back(new vil_image_view<T>(image)); scales_.push_back(1.0); }
00038
00039
00040
00041
00042 vil_pyramid_image_view(vil_image_view_base_sptr image, unsigned nlevels);
00043
00044
00045 vil_pyramid_image_view(unsigned levels, unsigned ni, unsigned nj, unsigned n_planes=1);
00046
00047
00048
00049 vil_pyramid_image_view(vcl_vector<vil_image_view_base_sptr> const& images,
00050 vcl_vector<double> const& scales);
00051
00052
00053
00054 vil_pyramid_image_view(const vil_pyramid_image_view<T>& rhs);
00055
00056 virtual ~vil_pyramid_image_view() {}
00057
00058
00059 void add_view(vil_image_view_base_sptr &image, double scale);
00060
00061 vil_image_view_base_sptr get_view(unsigned level, double& scale) { scale=scales_[level]; return images_[level]; }
00062
00063 double scale(unsigned level){return scales_[level];}
00064
00065
00066 typedef T pixel_type;
00067
00068 void set_max_level(unsigned l) { max_levels_=l; }
00069
00070 unsigned max_levels() const { return max_levels_; }
00071
00072
00073 unsigned nlevels() const { return nlevels_; }
00074
00075 const vil_pyramid_image_view<T>& operator=(const vil_pyramid_image_view<T>& rhs);
00076
00077 vil_image_view<T>& operator()(unsigned l) { return static_cast<vil_image_view<T>&>(*images_[l]); }
00078
00079
00080 typedef vil_image_view_base_sptr iterator;
00081 inline iterator begin() { return images_[0]; }
00082 inline iterator end () { return images_[images_.size()-1]; }
00083
00084 protected:
00085
00086 vcl_vector<vil_image_view_base_sptr> images_;
00087
00088
00089 vcl_vector<double> scales_;
00090
00091
00092 unsigned nlevels_;
00093
00094
00095 unsigned max_levels_;
00096
00097
00098 inline bool limit_reached(unsigned i, unsigned j)
00099 { return i<2 || j<2 || nlevels_==max_levels_; }
00100
00101
00102
00103 void scale_down(const vil_image_view<T>&, vil_image_view_base_sptr& image_out);
00104 };
00105
00106 #endif