NDCodebookLevelImagePooling.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "NDCodebookLevelImagePooling.h"
  2. //STL
  3. #include <iostream>
  4. //core
  5. #include <core/vector/VectorT.h>
  6. using namespace std;
  7. using namespace NICE;
  8. using namespace OBJREC;
  9. //**********************************************
  10. //
  11. // PROTECTED METHODS
  12. //
  13. //**********************************************
  14. //**********************************************
  15. //
  16. // PUBLIC METHODS
  17. //
  18. //**********************************************
  19. NDCodebookLevelImagePooling::NDCodebookLevelImagePooling ( const Config *_conf,
  20. const MultiDataset *_md, const std::string & _section )
  21. : NoveltyDetectorCodebookLevel ( _conf, _md, _section )
  22. {
  23. this->section = _section;
  24. // d_noveltyThreshold = conf->gD ( section , "noveltyThreshold", 0.0064 );
  25. d_noveltyThreshold = conf->gD ( section , "stupidNoveltyThreshold", 0.0064 );
  26. }
  27. NDCodebookLevelImagePooling::~NDCodebookLevelImagePooling()
  28. {
  29. }
  30. bool NDCodebookLevelImagePooling::evaluateNoveltyOfImage ( const std::string & _filename )
  31. {
  32. ROADWORKSNOVDET;
  33. }
  34. bool NDCodebookLevelImagePooling::evaluateNoveltyOfImage ( const NICE::FloatImage & _noveltyImage )
  35. {
  36. double meanNovelty ( 0.0 );
  37. for ( uint y = 0 ; y < ( uint ) _noveltyImage.height() ; y++ )
  38. {
  39. for ( uint x = 0 ; x < ( uint ) _noveltyImage.width(); x++ )
  40. {
  41. meanNovelty += _noveltyImage(x,y);
  42. }
  43. }
  44. int imageSize ( _noveltyImage.height() * _noveltyImage.width() );
  45. meanNovelty /= imageSize;
  46. std::cerr << " NOVELTY SCORE FOR CURRENT IMAGE: " << meanNovelty << " -- threshold: " << d_noveltyThreshold << std::endl;
  47. if ( meanNovelty < d_noveltyThreshold )
  48. {
  49. // --- NOT NOVEL ---
  50. return false;
  51. }
  52. else
  53. {
  54. // --- NOVEL ---
  55. return true;
  56. }
  57. }