123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- #ifndef CODEBOOKINCLUDE
- #define CODEBOOKINCLUDE
- #include <string>
- #include <core/basics/Config.h>
- #include "core/basics/Persistent.h"
- #include "core/image/ImageT.h"
- #include "core/imagedisplay/ImageDisplay.h"
- #include "core/vector/VectorT.h"
- #include "core/vector/MatrixT.h"
- #include "core/vector/SparseVectorT.h"
- namespace OBJREC {
-
- class Codebook : virtual public NICE::Persistent
- {
- protected:
- NICE::Vector thresholds;
- NICE::Vector informativeMeasure;
- NICE::VectorT<int> classnos;
-
-
- int i_noOfNearestClustersToConsidere;
-
- NICE::Config * p_conf;
- std::string s_section;
-
-
- bool b_hardAssignment;
- public:
-
- Codebook ( );
-
-
- Codebook ( const int & _noOfNearestClustersToConsidere);
-
- Codebook( NICE::Config * _conf, const std::string & _section);
-
- virtual ~Codebook();
-
-
-
-
- virtual void voteVQ ( const NICE::Vector & feature, int & codebookEntry,
- double & weight, double & distance ) const = 0;
-
-
-
- virtual void voteVQ (const NICE::Vector &feature, NICE::Vector &histogram, int & codebookEntry, double & weight, double & distance ) const;
-
-
-
- virtual void voteVQ (const NICE::Vector &feature, NICE::SparseVector &histogram, int &codebookEntry, double &weight, double &distance ) const;
-
-
-
- virtual void voteVA ( const NICE::Vector & feature, NICE::Vector & votes ) const = 0;
-
-
- virtual void voteVA ( const NICE::Vector & feature, NICE::SparseVector & votes ) const = 0;
-
-
-
- virtual void vote (const NICE::Vector &feature, NICE::Vector &histogram, int &codebookEntry , double &weight , double &distance ) const {
- this->voteVQ ( feature, histogram, codebookEntry, weight, distance );
- }
-
- virtual void vote (const NICE::Vector &feature, NICE::SparseVector &histogram ) const {
- int codebookEntry;
- double weight, distance;
- this->voteVQ ( feature, histogram, codebookEntry, weight, distance );
- }
-
-
-
-
- virtual void add ( const Codebook *codebook ) = 0;
- virtual void copy ( const Codebook *codebook );
- virtual Codebook *clone () const = 0;
- size_t getCodebookSize() const {
- return informativeMeasure.size();
- };
- void reinit ( int numCodebookEntries );
- const NICE::Vector & getThresholds () const {
- return thresholds;
- };
- const NICE::Vector & getInformativeMeasure () const {
- return informativeMeasure;
- };
- const NICE::VectorT<int> & getClassNos () const {
- return classnos;
- };
- void setThresholds ( const NICE::Vector & _thresholds ) {
- thresholds = _thresholds;
- };
- void setInformativeMeasure ( const NICE::Vector & _informativeMeasure ) {
- informativeMeasure = _informativeMeasure;
- };
- void setClassNos ( const NICE::VectorT<int> & _classnos ) {
- classnos = _classnos;
- };
-
- void setHardAssignment( const bool & _hardAssignment );
- bool getHardAssignment ( ) const ;
-
-
- virtual bool allowsMultipleVoting () const ;
-
- void setNoOfNearestClustersToConsidere ( const int & _noOfNearestClustersToConsidere );
- int getNoOfNearestClustersToConsidere ( ) const ;
- virtual void clear ();
- virtual void restore ( std::istream & is, int format );
- virtual void store ( std::ostream & os, int format ) const;
- };
- }
- #endif
|