00001 // This is mul/vimt/vimt_image.h 00002 #ifndef vimt_image_h_ 00003 #define vimt_image_h_ 00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00005 #pragma interface 00006 #endif 00007 //: 00008 // \file 00009 // \brief A base class for images of any dimension and type 00010 // \author Tim Cootes 00011 00012 #include <vcl_string.h> 00013 #include <vcl_iosfwd.h> 00014 #include <vcl_vector.h> 00015 #include <vsl/vsl_fwd.h> 00016 00017 //: A base class for images of any dimension and type 00018 // Derived classes tend to have world to image transformations 00019 // attached to them, and to be able to act as `views' of 00020 // external data. 00021 class vimt_image 00022 { 00023 //: Shallow equality tester. 00024 // The parameter must be identical type to this. 00025 virtual bool equals(const vimt_image &) const =0; 00026 00027 public: 00028 //: Dflt ctor 00029 vimt_image() {} 00030 00031 //: Destructor 00032 virtual ~vimt_image() {} 00033 00034 //: Return dimensionality of image 00035 virtual unsigned n_dims() const = 0; 00036 00037 //: Return number of planes in images. 00038 virtual unsigned n_planes() const = 0; 00039 00040 //: Return vector indicating size of image in pixels 00041 // 2D image is v[0] x v[1], 3D image is v[0] x v[1] x v[2] 00042 // Somewhat inefficient: Only use when you absolutely have to. 00043 // Usually one only needs to know the size once one knows the exact type. 00044 virtual vcl_vector<unsigned> image_size() const = 0; 00045 00046 //: Return vectors defining bounding box containing image in world co-ords 00047 virtual void world_bounds(vcl_vector<double>& b_lo, 00048 vcl_vector<double>& b_hi) const = 0; 00049 00050 //: Version number for I/O 00051 short version_no() const; 00052 00053 //: Name of the class 00054 virtual vcl_string is_a() const = 0; 00055 00056 //: Does the name of the class match the argument? 00057 virtual bool is_class(vcl_string const&) const = 0; 00058 00059 //: Create a copy on the heap and return base class pointer 00060 // Note that this will make a shallow copy of any contained images 00061 virtual vimt_image* clone() const = 0; 00062 00063 //: Create a deep copy on the heap and return base class pointer 00064 // This will make a deep copy of any contained images 00065 virtual vimt_image* deep_clone() const = 0; 00066 00067 //: Shallow equality. 00068 // tests if the two images are the same type, have equal transforms, and point 00069 // to the same image data with equal step sizes, etc. 00070 bool operator==(const vimt_image &) const; 00071 00072 //: Print class to os 00073 virtual void print_summary(vcl_ostream& os) const = 0; 00074 00075 //: Print whole image to os 00076 virtual void print_all(vcl_ostream& os) const = 0; 00077 00078 //: Save class to binary file stream 00079 virtual void b_write(vsl_b_ostream& bfs) const = 0; 00080 00081 //: Load class from binary file stream 00082 virtual void b_read(vsl_b_istream& bfs) = 0; 00083 }; 00084 00085 //: Allows derived class to be loaded by base-class pointer 00086 // A loader object exists which is invoked by calls 00087 // of the form "vsl_b_read(bfs,base_ptr);". This loads derived class 00088 // objects from the disk, places them on the heap and 00089 // returns a base class pointer. 00090 // In order to work the loader object requires 00091 // an instance of each derived class that might be 00092 // found. This function gives the model class to 00093 // the appropriate loader. 00094 void vsl_add_to_binary_loader(const vimt_image& b); 00095 00096 //: Binary file stream output operator for class reference 00097 void vsl_b_write(vsl_b_ostream& bfs, const vimt_image& b); 00098 00099 //: Binary file stream input operator for class reference 00100 void vsl_b_read(vsl_b_istream& bfs, vimt_image& b); 00101 00102 //: Stream output operator for class reference 00103 vcl_ostream& operator<<(vcl_ostream& os,const vimt_image& b); 00104 00105 //: Stream output operator for class pointer 00106 vcl_ostream& operator<<(vcl_ostream& os,const vimt_image* b); 00107 00108 //: Print class to os 00109 void vsl_print_summary(vcl_ostream& os, const vimt_image& im); 00110 00111 #endif // vimt_image_h_
1.4.4