RelativeLocationPrior.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. {
  19. class RelativeLocationPrior : public NICE::Persistent
  20. {
  21. protected:
  22. //! the priormaps
  23. std::vector<NICE::MultiChannelImageT<double> *> priormaps;
  24. //! the configfile
  25. const NICE::Config *conf;
  26. //! count of classes
  27. int classno;
  28. //! size of the priormaps (mapsize x mapsize)
  29. int mapsize;
  30. //! convert Image coordinates to priormaps coordinates
  31. void convertCoords ( int &x, int xsize );
  32. //! the trainingsdata will be added subsequently to this object
  33. Examples trainingsdata;
  34. //! the one vs all sparse logistic classifiers
  35. std::vector<SLR> classifiers;
  36. //! dimension of the features
  37. int featdim;
  38. public:
  39. /** simple constructor */
  40. RelativeLocationPrior();
  41. /** simple constructor */
  42. RelativeLocationPrior ( const NICE::Config *_conf );
  43. /** simple destructor */
  44. ~RelativeLocationPrior();
  45. /**
  46. * set the count of classes
  47. * @param _classno count of classes
  48. */
  49. void setClassNo ( int _classno );
  50. /** initialize the RelativeLocationPrior Variables*/
  51. void Init();
  52. /**
  53. * Bestimme aus dem Trainingsbild, die location priors maps
  54. * @param regions input regions with size, position and label
  55. */
  56. void trainPriorsMaps ( Examples &regions, int xsize, int ysize );
  57. /**
  58. * finish the priors maps
  59. */
  60. void finishPriorsMaps ( ClassNames &cn );
  61. /**
  62. * Bestimme aus dem Trainingsbild, die location priors maps
  63. * @param regions input regions with size and position
  64. * @param probabilities the probabiltiy maps
  65. */
  66. void trainClassifier ( Examples &regions, NICE::MultiChannelImageT<double> & probabilities );
  67. /**
  68. * finish the classfiers
  69. */
  70. void finishClassifier();
  71. /**
  72. * appends the featurevector to the given example
  73. * @param regions input regions with size and position
  74. * @param probabilities the probabiltiy maps
  75. */
  76. void getFeature ( Examples &regions, NICE::MultiChannelImageT<double> & probabilities );
  77. /**
  78. * uses the rlp for reclassification
  79. * @param regions
  80. * @param result
  81. * @param probabilities
  82. */
  83. void postprocess ( Examples &regions, NICE::MultiChannelImageT<double> & probabilities );
  84. /**
  85. * load data from an input stream
  86. * @param is input stream
  87. * @param format
  88. */
  89. void restore ( std::istream & is, int format = 0 );
  90. /**
  91. * write data to an output stream
  92. * @param os outputstream
  93. * @param format
  94. */
  95. void store ( std::ostream & os, int format = 0 ) const;
  96. /**
  97. * clear all informations
  98. */
  99. void clear ();
  100. };
  101. } //namespace
  102. #endif