Go to the documentation of this file.00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008 #include "vimt_image_pyramid.h"
00009
00010 #include <vcl_cassert.h>
00011 #include <vcl_iostream.h>
00012 #include <vsl/vsl_indent.h>
00013 #include <vimt/vimt_image.h>
00014
00015
00016
00017 vimt_image_pyramid::vimt_image_pyramid()
00018 : base_pixel_width_(1.0),scale_step_(2.0)
00019 {
00020 }
00021
00022
00023
00024 void vimt_image_pyramid::deleteImages()
00025 {
00026 for (unsigned int i=0;i<image_.size();++i)
00027 delete image_[i];
00028 image_.resize(0);
00029 }
00030
00031 vimt_image_pyramid::~vimt_image_pyramid()
00032 {
00033 deleteImages();
00034 }
00035
00036
00037
00038
00039
00040 const vimt_image_pyramid&
00041 vimt_image_pyramid::operator=(const vimt_image_pyramid& that)
00042 {
00043 if (&that == this) return *this;
00044
00045 base_pixel_width_ = that.base_pixel_width_;
00046 scale_step_ = that.scale_step_;
00047 image_.resize(that.image_.size(),0);
00048 for (unsigned int i=0;i<image_.size();++i)
00049 {
00050 delete image_[i];
00051 image_[i] = that.image_[i]->clone();
00052 }
00053
00054 return *this;
00055 }
00056
00057
00058 void vimt_image_pyramid::deep_copy(const vimt_image_pyramid& im_pyr)
00059 {
00060 if (&im_pyr==this) return;
00061
00062 base_pixel_width_ = im_pyr.base_pixel_width_;
00063 scale_step_ = im_pyr.scale_step_;
00064 image_.resize(im_pyr.image_.size(),0);
00065 for (unsigned int i=0;i<image_.size();++i)
00066 {
00067 delete image_[i];
00068 image_[i] = im_pyr.image_[i]->deep_clone();
00069 }
00070 }
00071
00072
00073
00074
00075 vimt_image_pyramid::vimt_image_pyramid(const vimt_image_pyramid &that)
00076 {
00077 this->operator=(that);
00078 }
00079
00080
00081 void vimt_image_pyramid::resize(int n_levels, const vimt_image& im_type)
00082 {
00083 if (int(image_.size())==n_levels && n_levels>0 && image_[0]->is_a()==im_type.is_a())
00084 return;
00085 deleteImages();
00086 image_.resize(n_levels,0);
00087 for (int i=0;i<n_levels;++i)
00088 image_[i]=im_type.clone();
00089 }
00090
00091
00092 int vimt_image_pyramid::lo() const
00093 {
00094 return 0;
00095 }
00096
00097
00098 int vimt_image_pyramid::hi() const
00099 {
00100 return ((int)image_.size())-1;
00101 }
00102
00103 int vimt_image_pyramid::n_levels() const
00104 {
00105 return image_.size();
00106 }
00107
00108
00109 vimt_image& vimt_image_pyramid::operator()(int L)
00110 {
00111 assert(L>=0 && (unsigned int)L<image_.size());
00112 return *image_[L];
00113 }
00114
00115
00116 const vimt_image& vimt_image_pyramid::operator()(int L) const
00117 {
00118 assert(L>=0 && (unsigned int)L<image_.size());
00119 return *image_[L];
00120 }
00121
00122
00123 double vimt_image_pyramid::base_pixel_width() const
00124 {
00125 return base_pixel_width_;
00126 }
00127
00128
00129
00130
00131 double vimt_image_pyramid::scale_step() const
00132 {
00133 return scale_step_;
00134 }
00135
00136
00137
00138 vcl_vector<vimt_image*>& vimt_image_pyramid::data()
00139 {
00140 return image_;
00141 }
00142
00143
00144 void vimt_image_pyramid::set_widths(double base_pixel_width,
00145 double scale_step)
00146 {
00147 base_pixel_width_ = base_pixel_width;
00148 scale_step_ = scale_step;
00149 }
00150
00151 void vimt_image_pyramid::print_summary(vcl_ostream& os) const
00152 {
00153 os<< vsl_indent() << "Levels: "<<image_.size()<<'\n';
00154 for (unsigned int i=0;i<image_.size();++i)
00155 os << vsl_indent() << "Image at level "<<i<<" : "<<image_[i]<<'\n';
00156 }
00157
00158
00159 void vimt_image_pyramid::print_all(vcl_ostream& os) const
00160 {
00161 os<<"Levels: "<<image_.size()<<'\n';
00162 for (unsigned int i=0;i<image_.size();++i)
00163 {
00164 os<<"Image at level "<<i<<" : ";
00165 image_[i]->print_all(os);
00166 os<<'\n';
00167 }
00168 }
00169
00170 vcl_ostream& operator<<(vcl_ostream& os, const vimt_image_pyramid& im_pyr)
00171 {
00172 im_pyr.print_summary(os);
00173 return os;
00174 }
00175
00176 vcl_ostream& operator<<(vcl_ostream& os, const vimt_image_pyramid* im_pyr)
00177 {
00178 if (im_pyr)
00179 im_pyr->print_summary(os);
00180 else
00181 os<<"NULL";
00182 return os;
00183 }
00184
00185 void vsl_print_summary(vcl_ostream& os, const vimt_image_pyramid& im_pyr)
00186 {
00187 os << im_pyr;
00188 }
00189
00190 void vsl_print_summary(vcl_ostream& os, const vimt_image_pyramid* im_pyr)
00191 {
00192 os << im_pyr;
00193 }