iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImagePyramid.H
Go to the documentation of this file.
1 /*! @file
2  @author Randolph Voorhies
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 
36 #ifndef INCLUDE_NRT_IMAGEPROC_PYRAMID_IMAGEPYRAMID_H
37 #define INCLUDE_NRT_IMAGEPROC_PYRAMID_IMAGEPYRAMID_H
38 
39 #include <nrt/Core/Image/Image.H>
40 #include <nrt/External/cereal/types/vector.hpp>
41 
42 namespace nrt
43 {
44 
45  /*! \defgroup imagepyramid Multiresolution ImagePyramid class and functions
46 
47  An ImagePyramid represents a stack of various scales of a single Image
48 
49  \ingroup imagerel
50  \see image */
51 
52  /*! @{ */ // **********************************************************************
53 
54 
55  //! An ImagePyramid represents a stack of various scales of a single Image
56  /*! It is organized into separate "octaves," each of which is 50% the size of the previous octave. Furthermore,
57  each octave may have multiple "layers." Each layer within an octave should be at least as small as it's enclosing
58  octave, but the details are dependent on how the ImagePyramid was constructed. */
59  template <class PixType>
61  {
62  public:
63  class Octave
64  {
65  public:
66  //! Default constructor - creates an empty Octave
67  Octave();
68 
69  //! Create an Octave from a vector of Images.
70  Octave(std::vector<nrt::Image<PixType>> const& layers);
71 
72  //! Copy constructor
73  Octave(Octave const & other);
74 
75  //! Get the number of layers in this Octave
76  size_t const numLayers() const;
77 
78  //! Get a reference to the l'th layer in this Octave
79  nrt::Image<PixType> & layer(size_t const l);
80 
81  //! Get a reference to the l'th layer in this Octave (const version)
82  nrt::Image<PixType> const & layer(size_t const l) const;
83 
84  //! Get a reference to the underyling storage of layers
85  std::vector<nrt::Image<PixType>> & layers();
86 
87  //! Get a reference to the underyling storage of layers (const version)
88  std::vector<nrt::Image<PixType>> const & layers() const;
89 
90  protected:
91  friend class cereal::access;
92 
93  //! Serialization
94  template<class Archive> void serialize(Archive & ar)
95  {
96  ar( itsLayers );
97  }
98 
99  private:
100  std::vector<nrt::Image<PixType>> itsLayers;
101  };
102 
103  //! Default constructor
104  /*! Creates an empty ImagePyramid with 0 octaves*/
105  ImagePyramid();
106 
107  //! Create an ImagePyramid from a vector of Octaves
108  ImagePyramid(std::vector<Octave> const& octaves);
109 
110  //! Initialize a blank (but not empty!) ImagePyramid
111  /*! The new pyramid will have space allocated for numOctaves, with the given layersPerOctave, however each Image
112  contained within will be uninitialized (will have Dims of 0x0). */
113  ImagePyramid(size_t numOctaves, size_t layersPerOctave=1);
114 
115  //! Create an ImagePyramid from another with a possibly different colorspace/bitdepth
116  template<class OtherPix>
117  explicit ImagePyramid(ImagePyramid<OtherPix> const & other);
118 
119  //! Get the number of Octaves
120  size_t const numOctaves() const;
121 
122  //! Get a reference to the o'th octave
123  Octave & octave(size_t const o);
124 
125  //! Get a reference to the o'th octave (const version)
126  Octave const & octave(size_t const o) const;
127 
128  //! Get a reference to the underyling storage of octaves
129  std::vector<Octave> & octaves();
130 
131  //! Get a reference to the underyling storage of octaves (const version)
132  std::vector<Octave const> const & octaves() const;
133 
134  private:
135  std::vector<Octave> itsOctaves;
136 
137  friend class cereal::access;
138 
139  //! Serialization
140  template<class Archive>
141  void serialize(Archive & ar)
142  {
143  ar( itsOctaves );
144  }
145  };
146 
147  /*! @} */ // **********************************************************************
148 }
149 
151 
152 #endif // INCLUDE_NRT_IMAGEPROC_PYRAMID_IMAGEPYRAMID_H
153 
154