LArOpenCV  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Image2D.h
Go to the documentation of this file.
1 
15 #ifndef __LARCAFFE_Image2D_H__
16 #define __LARCAFFE_Image2D_H__
17 
18 #include <vector>
19 #include <cstdlib>
20 #include "ImageMeta.h"
21 namespace larcaffe {
22 
27  class Image2D : protected std::vector<float> {
28 
29  public:
30 
31  Image2D(size_t width_npixel=0, size_t height_npixel=0);
32  Image2D(const ImageMeta&);
33  Image2D(const Image2D&);
34  virtual ~Image2D(){}
35 
36  unsigned int height() const { return _meta._height_npixel; }
37  unsigned int width() const { return _meta._width_npixel; }
38  float pixel(size_t w, size_t h) const;
39  inline bool isInBounds( size_t w, size_t h ) const
40  { return ( h < _meta._height_npixel && w < _meta._width_npixel ); }
41  Image2D copy_compress(size_t width_npixel, size_t height_npixel) const;
42  size_t index( size_t w, size_t h ) const;
43 
44  void copy(size_t w, size_t h, const float* src, size_t num_pixel);
45  void copy(size_t w, size_t h, const std::vector<float>& src, size_t num_pixel=0);
46  void copy(size_t w, size_t h, const short* src, size_t num_pixel);
47  void copy(size_t w, size_t h, const std::vector<short>& src, size_t num_pixel=0);
48  const std::vector<float>& as_vector() const
49  { return (*this); }
50  const ImageMeta& meta_data() const { return _meta; }
51 
52  void resize( size_t width_npixel, size_t height_npixel );
53  void set_pixel( size_t w, size_t h, float value );
54  void paint(float value);
55  void clear_data();
56  void compress(size_t width_npixel, size_t height_npixel);
57 
58  private:
60  void clear();
61  };
62 }
63 namespace larcv {
69 
70 }
71 
72 #endif
73  // end of doxygen group