www.pudn.com > firev0.01.rar > basehisto.hpp
/* This file is part of the FIRE -- Flexible Image Retrieval System FIRE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. FIRE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRE; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __basehisto_hpp #define __basehisto_hpp /** very basic histogram base class. * * within this class everything is abstract and it only provides */ #include#include "basefeature.hpp" using namespace std; class BaseHisto : public BaseFeature { public: /** * Default constructor, does nothing. Inherited objects using * pointers should override it. */ virtual ~BaseHisto() {}; /** * load a histogram from a file. * * @param filename the file to be read */ virtual void load(string filename)=0; /** * Save a histogram to a file. * * @param filename the name of the file to be written. */ virtual void save(string filename, string cmdline="")=0; /** * return the value of the bin number no. * * @param no the number of the bin where we want the value from. * * @return the value of bin number no. */ virtual const unsigned int bin(const unsigned int &no) const=0; /** * Histograms are features and thus inherited from * BaseFeature. Because of this we need this operator. * * @param idx the number of the bin to be returned * * @return the normalized histogram representation */ virtual const double operator[](const unsigned int idx) const { return double(bin(idx))/double(counter()); } /** * Histograms are features and thus inherited from BaseFeature. This * function is needed because of this. * * @return the number of bins */ virtual const unsigned int size() const { return nOfBins(); } /** * the same as size. * * * @return the number of bins */ virtual const unsigned int nOfBins() const=0; /** * for normalization the number of counted observations is * needed. This is given here. * * @return the number of observations counted. */ virtual const unsigned int counter() const=0; }; #endif