RelativeLocationPrior.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * @file RelativeLocationPrior.h
  3. * @brief a post procession step after semantic segmentation which use relative location priors
  4. * @author Björn Fröhlich
  5. * @date 06/10/2009
  6. */
  7. #ifndef RELATIVELOCATIONPRIORINCLUDE
  8. #define RELATIVELOCATIONPRIORINCLUDE
  9. #include "core/image/MultiChannelImageT.h"
  10. #include "vislearning/cbaselib/CachedExample.h"
  11. #include "vislearning/baselib/Preprocess.h"
  12. #include "vislearning/baselib/Globals.h"
  13. #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"
  14. #include "vislearning/classifier/fpclassifier/randomforest/FPCRandomForests.h"
  15. #include "vislearning/features/fpfeatures/SparseVectorFeature.h"
  16. #include "vislearning/cbaselib/ClassNames.h"
  17. namespace OBJREC {
  18. class RelativeLocationPrior : public Persistent
  19. {
  20. protected:
  21. //! the priormaps
  22. std::vector<NICE::MultiChannelImageT<double> *> priormaps;
  23. //! the configfile
  24. const Config *conf;
  25. //! count of classes
  26. int classno;
  27. //! size of the priormaps (mapsize x mapsize)
  28. int mapsize;
  29. //! convert Image coordinates to priormaps coordinates
  30. void convertCoords(int &x, int xsize);
  31. //! the trainingsdata will be added subsequently to this object
  32. Examples trainingsdata;
  33. //! the one vs all sparse logistic classifiers
  34. std::vector<SLR> classifiers;
  35. //! dimension of the features
  36. int featdim;
  37. public:
  38. /** simple constructor */
  39. RelativeLocationPrior();
  40. /** simple constructor */
  41. RelativeLocationPrior(const Config *_conf);
  42. /** simple destructor */
  43. ~RelativeLocationPrior();
  44. /**
  45. * set the count of classes
  46. * @param _classno count of classes
  47. */
  48. void setClassNo(int _classno);
  49. /** initialize the RelativeLocationPrior Variables*/
  50. void Init();
  51. /**
  52. * Bestimme aus dem Trainingsbild, die location priors maps
  53. * @param regions input regions with size, position and label
  54. */
  55. void trainPriorsMaps(Examples &regions, int xsize, int ysize);
  56. /**
  57. * finish the priors maps
  58. */
  59. void finishPriorsMaps(ClassNames &cn);
  60. /**
  61. * Bestimme aus dem Trainingsbild, die location priors maps
  62. * @param regions input regions with size and position
  63. * @param probabilities the probabiltiy maps
  64. */
  65. void trainClassifier(Examples &regions, NICE::MultiChannelImageT<double> & probabilities);
  66. /**
  67. * finish the classfiers
  68. */
  69. void finishClassifier();
  70. /**
  71. * appends the featurevector to the given example
  72. * @param regions input regions with size and position
  73. * @param probabilities the probabiltiy maps
  74. */
  75. void getFeature(Examples &regions, NICE::MultiChannelImageT<double> & probabilities);
  76. /**
  77. * uses the rlp for reclassification
  78. * @param regions
  79. * @param result
  80. * @param probabilities
  81. */
  82. void postprocess ( Examples &regions, NICE::MultiChannelImageT<double> & probabilities);
  83. /**
  84. * load data from an input stream
  85. * @param is input stream
  86. * @param format
  87. */
  88. void restore (std::istream & is, int format = 0);
  89. /**
  90. * write data to an output stream
  91. * @param os outputstream
  92. * @param format
  93. */
  94. void store (std::ostream & os, int format = 0) const;
  95. /**
  96. * clear all informations
  97. */
  98. void clear ();
  99. };
  100. } //namespace
  101. #endif