Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxHistoList.h

00001 /*
00002  *  Copyright (c) 1998, University of Amsterdam, The Netherlands.
00003  *  All rights reserved.
00004  *
00005  *  Author(s):
00006  *  Jan-Mark Geusebroek (mark@wins.uva.nl)
00007  */
00008 
00009 #ifndef HxHistoList_h
00010 #define HxHistoList_h
00011 
00012 #include <list>
00013 
00014 #include "HxHistogram.h"
00015 
00016 class HxHistoList {
00017 public:
00018     typedef std::list<HxHistogram>::const_iterator const_iterator;
00019     typedef std::list<HxHistogram>::iterator iterator;
00020 
00022                     HxHistoList();
00023                     HxHistoList(HxHistogram e);
00024                     HxHistoList(HxHistogram e1, HxHistogram e2);
00025                     HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3);
00026                     HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00027                         HxHistogram e4);
00028                     HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00029                         HxHistogram e4, HxHistogram e5);
00030 
00031                     /* add more elements with operator '+' */
00032                     
00034                     HxHistoList(const HxHistoList& l);
00035 
00037                     ~HxHistoList();
00038 
00039                     HxHistoList& operator=(const HxHistoList& l);
00040 
00042     int             size() const;
00043     iterator        begin();
00044     iterator        end();
00045     const_iterator  begin() const;
00046     const_iterator  end() const;
00047 
00048 
00049     friend HxHistoList operator+(HxHistoList l, HxHistogram& e);
00050     friend HxHistoList operator+(HxHistogram& e, HxHistoList l);
00051     friend HxHistoList operator+(HxHistoList& e, HxHistoList& l);
00052     void operator+=(HxHistogram& e);
00053 
00054     double          intersection(HxHistoList& l);
00055     void            normalize(double weight = 1.0);
00056 
00057 private:
00058     std::list<HxHistogram> _hists;
00059 };
00060 
00061 inline
00062 HxHistoList::HxHistoList()
00063 {
00064 }
00065 
00066 inline
00067 HxHistoList::HxHistoList(HxHistogram e)
00068 {
00069     _hists.push_back(e);
00070 }
00071 
00072 inline
00073 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2)
00074 {
00075     _hists.push_back(e1);
00076     _hists.push_back(e2);
00077 }
00078 
00079 inline
00080 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3)
00081 {
00082     _hists.push_back(e1);
00083     _hists.push_back(e2);
00084     _hists.push_back(e3);
00085 }
00086 
00087 inline
00088 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00089     HxHistogram e4)
00090 {
00091     _hists.push_back(e1);
00092     _hists.push_back(e2);
00093     _hists.push_back(e3);
00094     _hists.push_back(e4);
00095 }
00096 
00097 inline
00098 HxHistoList::HxHistoList(HxHistogram e1, HxHistogram e2, HxHistogram e3,
00099     HxHistogram e4, HxHistogram e5)
00100 {
00101     _hists.push_back(e1);
00102     _hists.push_back(e2);
00103     _hists.push_back(e3);
00104     _hists.push_back(e4);
00105     _hists.push_back(e5);
00106 }
00107 
00108 inline
00109 HxHistoList::HxHistoList(const HxHistoList& l)
00110 {
00111     _hists = l._hists;
00112 }
00113 
00114 inline
00115 HxHistoList::~HxHistoList()
00116 {
00117 }
00118 
00119 inline HxHistoList&
00120 HxHistoList::operator=(const HxHistoList& l)
00121 {
00122     if (&l != this)
00123         _hists = l._hists;
00124     return *this;
00125 }
00126 
00127 inline int
00128 HxHistoList::size() const
00129 {
00130     return _hists.size();
00131 }
00132 
00133 inline HxHistoList::iterator 
00134 HxHistoList::begin()
00135 {
00136     return _hists.begin();
00137 }
00138 
00139 inline HxHistoList::iterator 
00140 HxHistoList::end()
00141 {
00142     return _hists.end();
00143 }
00144 
00145 inline HxHistoList::const_iterator 
00146 HxHistoList::begin() const
00147 {
00148     return _hists.begin();
00149 }
00150 
00151 inline HxHistoList::const_iterator 
00152 HxHistoList::end() const
00153 {
00154     return _hists.end();
00155 }
00156 
00157 inline double
00158 HxHistoList::intersection(HxHistoList& l)
00159 {
00160     HxHistoList::iterator i;
00161     HxHistoList::iterator j;
00162     double res = 0.0;
00163     int    n = 0;
00164 
00165     for (i = begin(), j = l.begin();
00166             (i != end()) && (j != l.end()); i++, j++) {
00167         res += (*i).intersection(*j);
00168         n++;
00169     }
00170     if (n)
00171         res /= n;
00172 
00173     return res;
00174 }
00175 
00176 inline void
00177 HxHistoList::normalize(double weight)
00178 {
00179     HxHistoList::iterator i;
00180 
00181     for (i = _hists.begin(); i != _hists.end(); i++)
00182         (*i).normalize(weight);
00183 }
00184 
00185 
00186 inline HxHistoList
00187 operator+(HxHistoList l, HxHistogram& e)
00188 {
00189     l._hists.push_back(e);
00190     return l;
00191 }
00192 
00193 inline HxHistoList
00194 operator+(HxHistogram& e, HxHistoList l)
00195 {
00196     l._hists.push_front(e);
00197     return l;
00198 }
00199 
00200 inline void
00201 HxHistoList::operator+=(HxHistogram& e)
00202 {
00203     _hists.push_back(e);
00204 }
00205 
00206 inline HxHistoList
00207 operator+(HxHistoList& e, HxHistoList& l)
00208 {
00209     HxHistoList n;
00210     HxHistoList::const_iterator i;
00211 
00212     for (i = e._hists.begin(); i != e._hists.end(); i++)
00213         n._hists.push_back(*i);
00214     for (i = l._hists.begin(); i != l._hists.end(); i++)
00215         n._hists.push_back(*i);
00216 
00217     return n;
00218 }
00219 
00220 HxHistoList operator+(HxHistoList l, HxHistogram& e);
00221 HxHistoList operator+(HxHistogram& e, HxHistoList l);
00222 HxHistoList operator+(HxHistoList& e, HxHistoList& l);
00223 
00224 #endif

Generated on Tue Jan 8 13:59:12 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001