Go to the documentation of this file.00001 #ifndef vimt_image_2d_of_txx_
00002 #define vimt_image_2d_of_txx_
00003
00004
00005
00006
00007
00008 #include "vimt_image_2d_of.h"
00009 #include <vcl_string.h>
00010 #include <vcl_cassert.h>
00011 #include <vsl/vsl_indent.h>
00012 #include <vsl/vsl_vector_io.h>
00013 #include <vil/vil_print.h>
00014 #include <vil/io/vil_io_image_view.h>
00015
00016
00017
00018
00019 template<class T>
00020 void vimt_image_2d_of<T>::deep_copy(const vimt_image_2d_of& src)
00021 {
00022 world2im_ = src.world2im_;
00023 image_.deep_copy(src.image_);
00024 }
00025
00026
00027
00028 template<class T>
00029 bool vimt_image_2d_of<T>::equals(const vimt_image &im) const
00030 {
00031 assert(dynamic_cast<const vimt_image_2d_of<T> *>(&im));
00032 return operator==(static_cast<const vimt_image_2d_of<T> &>(im));
00033 }
00034
00035
00036
00037
00038 template<class T>
00039 void vimt_image_2d_of<T>::set_valid_region(int x0, unsigned nx, int y0, unsigned ny)
00040 {
00041 image_.set_size(nx,ny);
00042 world2im_.set_translation(-x0,-y0);
00043 }
00044
00045 template<class T>
00046 bool vimt_image_2d_of<T>::is_class(vcl_string const& s) const
00047 {
00048 return s==vimt_image_2d_of<T>::is_a() || vimt_image_2d::is_class(s);
00049 }
00050
00051
00052
00053 template<class T>
00054 short vimt_image_2d_of<T>::version_no() const
00055 {
00056 return 1;
00057 }
00058
00059
00060 template<class T>
00061 vimt_image* vimt_image_2d_of<T>::deep_clone() const
00062 {
00063 vimt_image_2d_of<T>* new_im = new vimt_image_2d_of<T>();
00064 new_im->deep_copy(*this);
00065 return new_im;
00066 }
00067
00068
00069
00070 template<class T>
00071 void vimt_image_2d_of<T>::print_summary(vcl_ostream& os) const
00072 {
00073 os<< vsl_indent() << "Transform: " << world2im_ << " Image: "
00074 << image_<< '\n';
00075 }
00076
00077
00078
00079 template<class T>
00080 void vimt_image_2d_of<T>::print_all(vcl_ostream& os) const
00081 {
00082 os<<vsl_indent();
00083 vil_print_all(os,image_);
00084 os<<'\n'<<vsl_indent() << "Transform: "<<world2im_<<'\n';
00085 }
00086
00087
00088
00089
00090 template<class T>
00091 void vimt_image_2d_of<T>::b_write(vsl_b_ostream& bfs) const
00092 {
00093 vsl_b_write(bfs,version_no());
00094 vsl_b_write(bfs,image_);
00095 vsl_b_write(bfs,world2im_);
00096 }
00097
00098
00099
00100 template<class T>
00101 void vimt_image_2d_of<T>::b_read(vsl_b_istream& bfs)
00102 {
00103 if (!bfs) return;
00104
00105 short version;
00106 vsl_b_read(bfs,version);
00107 switch (version)
00108 {
00109 case (1):
00110 vsl_b_read(bfs,image_);
00111 vsl_b_read(bfs,world2im_);
00112 break;
00113 default:
00114 vcl_cerr << "I/O ERROR: vimt_image_2d_of<T>::b_read(vsl_b_istream&)\n"
00115 << " Unknown version number "<< version << '\n';
00116 bfs.is().clear(vcl_ios::badbit);
00117 return;
00118 }
00119 }
00120
00121
00122
00123
00124
00125 template<class T>
00126 bool vimt_image_2d_of<T>::operator==(const vimt_image_2d_of<T> &other) const
00127 {
00128 return image_ == other.image_ &&
00129 world2im_ == other.world2im_;
00130 }
00131
00132 #define VIMT_IMAGE_2D_OF_INSTANTIATE(T) \
00133 VCL_DEFINE_SPECIALIZATION vcl_string vimt_image_2d_of<T >::is_a() const \
00134 { return vcl_string("vimt_image_2d_of<" #T ">"); }\
00135 template class vimt_image_2d_of<T >
00136
00137 #endif // vimt_image_2d_of_txx_