PHOGFeature.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * @file PHOGFeature.h
  3. * @author Alexander Lütz
  4. * @date 15/11/2011
  5. */
  6. #ifndef _NICE_OBJREC_PHOGFEATUREINCLUDE
  7. #define _NICE_OBJREC_PHOGFEATUREINCLUDE
  8. #include "core/basics/Config.h"
  9. // #include "vislearning/cbaselib/MultiDataset.h"
  10. #include "Image_tools.h"
  11. namespace OBJREC {
  12. /** @class PHOGFeature
  13. * Implementation of the PHOG-Features and corresponding Kernel as done by Anna Bosch et al.
  14. *
  15. * @author Alexander Lütz
  16. */
  17. class PHOGFeature
  18. {
  19. public:
  20. enum Histrogram_concatenation{NONE=0, LEVELWISE=1, ALL=2};
  21. protected:
  22. Image_tools image_tool;
  23. int number_Of_Bins;
  24. bool unsignedBins;
  25. int number_of_Levels;
  26. bool like_AnnaBosch;
  27. bool distances_only_between_levels;
  28. Histrogram_concatenation histrogram_concatenation;
  29. bool verbose;
  30. /** Calculates the PHOG-Pyramide for given gradient images (idea of Anna Bosch and Andrew Zisserman)*/
  31. void calculate_PHOG_Pyramide(const NICE::Image & gradient_orientations, const NICE::ImageT<float> & gradient_magnitudes,std::vector< std::vector<float> > & PHOG_descriptor);
  32. /** Calculates resulting PHOG-Features for the specified ROI in the given image*/
  33. std::vector< std::vector<float> > calculate_PHOG_Features(const NICE::Image & orig_Image, const NICE::Rect & roi);
  34. public:
  35. PHOGFeature();
  36. /** recommended constructor */
  37. PHOGFeature( const NICE::Config *conf, std::string section = "PHOGFeature");
  38. /** simple destructor */
  39. virtual ~PHOGFeature();
  40. // std::vector<std::vector< std::vector<float> > > createAllFeatureVectors(const OBJREC::LabeledSet::Permutation & order);
  41. //
  42. // std::vector<std::vector< std::vector<float> > > createAllFeatureVectors(const OBJREC::LabeledSet::Permutation & order, std::vector< NICE::Image > & gradient_orientations, std::vector< NICE::ImageT<float> > & gradient_magnitudes);
  43. //
  44. // std::vector<std::vector< std::vector<float> > > createAllFeatureVectors(const OBJREC::LabeledSet::Permutation & order, const std::vector<int> & trainSelection);
  45. std::vector< std::vector<float> > createOneFeatureVector(const std::string & imgfilename, const NICE::Rect & ROI);
  46. std::vector< std::vector<float> > createOneFeatureVector(const NICE::Image img, const NICE::Rect & ROI);
  47. std::vector< std::vector<float> > createOneFeatureVector(const std::string & imgfilename);
  48. std::vector< std::vector<float> > createOneFeatureVector(const NICE::Image img);
  49. /** computes the featurevector for the given image, which is already converted to a gradient-image*/
  50. std::vector< std::vector<float> > createOneFeatureVectorDirect(NICE::Image & gradient_orientations, NICE::ImageT<float> & gradient_magnitudes, const NICE::Rect & ROI);
  51. std::vector< std::vector<float> > createOneFeatureVectorDirect(NICE::Image & gradient_orientations, NICE::ImageT<float> & gradient_magnitudes);
  52. // std::vector< NICE::Image> calculate_gradient_orientations(const OBJREC::LabeledSet::Permutation & order);
  53. // std::vector< NICE::ImageT<float> > calculate_gradient_magnitudes(const OBJREC::LabeledSet::Permutation &
  54. NICE::Image calculate_gradient_orientations(const std::string & imgfilename);
  55. NICE::ImageT<float> calculate_gradient_magnitudes(const std::string & imgfilename);
  56. /**Compute the resulting kernel measuring the distance between the given feature-vectores*/
  57. void calculate_Kernel_from_Features(const std::vector<std::vector< std::vector<float> > > & PHoG_Features, NICE::Matrix & PHoG_Kernel);
  58. virtual double measureDistance ( const std::vector< std::vector<float> > & a, const std::vector< std::vector<float> > & b );
  59. virtual void sayYourName() {std::cerr << "I'm the PHOG-Feature." << std::endl;};
  60. void set_verbose(const bool & new_verbose);
  61. void set_histrogram_concatenation(const Histrogram_concatenation & _histrogram_concatenation){histrogram_concatenation = _histrogram_concatenation;};
  62. };
  63. }
  64. #endif