Image Utilities (IU)
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Groups Pages
image.h
1 #pragma once
2 
3 #include "coredefs.h"
4 
5 #include <ostream>
6 #include <typeinfo>
7 
8 namespace iu{
9 
30 class Image
31 {
32 public:
34  Image() :
35  size_(0,0)
36  {
37  }
38 
40  virtual ~Image()
41  {
42  }
43 
48  Image( unsigned int width, unsigned int height) :
49  size_(width, height)
50  {
51  }
52 
56  Image( const iu::Size<2> &size) :
57  size_(size)
58  {
59  }
60 
64  iu::Size<2> size() const
65  {
66  return size_;
67  }
68 
72  unsigned int width() const
73  {
74  return size_.width;
75  }
76 
80  unsigned int height() const
81  {
82  return size_.height;
83  }
84 
89  bool sameType(const Image &from)
90  {
91  return typeid(from)==typeid(*this);
92  }
93 
95  size_t numel() const
96  {
97  return (size_.width * size_.height);
98  }
99 
101  virtual size_t bytes() const {return 0;};
102 
104  virtual size_t pitch() const {return 0;};
105 
107  virtual size_t stride() const {return 0;};
108 
110  virtual unsigned int bitDepth() const {return 0;};
111 
113  virtual bool onDevice() const {return false;};
114 
116  friend std::ostream& operator<<(std::ostream & out,
117  Image const& image)
118  {
119  out << "Image: " << image.size() << " stride="
120  << image.pitch() / double((image.bitDepth()/8)) << " onDevice=" << image.onDevice(); // stride may go fractional here
121  return out;
122  }
123 
124 protected:
127 
128 private:
130  Image(const Image&);
132  Image& operator=(const Image&);
133 };
134  // end of Image
136 
137 } // namespace iu
138 
iu::Size< 2 > size() const
Definition: image.h:64
friend std::ostream & operator<<(std::ostream &out, Image const &image)
Definition: image.h:116
Image(unsigned int width, unsigned int height)
Definition: image.h:48
bool sameType(const Image &from)
Definition: image.h:89
Base class for 2D images (pitched memory).
Definition: image.h:30
virtual bool onDevice() const
Definition: image.h:113
unsigned int & height
Definition: vector.h:531
virtual size_t stride() const
Definition: image.h:107
virtual size_t pitch() const
Definition: image.h:104
unsigned int & width
Definition: vector.h:529
size_t numel() const
Definition: image.h:95
virtual unsigned int bitDepth() const
Definition: image.h:110
virtual size_t bytes() const
Definition: image.h:101
iu::Size< 2 > size_
Definition: image.h:126
Image()
Definition: image.h:34
Template specialization for 2-d unsigned int vectors (size vectors).
Definition: vector.h:525
unsigned int width() const
Definition: image.h:72
virtual ~Image()
Definition: image.h:40
Image(const iu::Size< 2 > &size)
Definition: image.h:56
unsigned int height() const
Definition: image.h:80