PPGraphCut.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /**
  2. * @file PPGraphCut.h
  3. * @brief a post procession step after semantic segmentation which use a variant of GraphCut
  4. * @author Björn Fröhlich
  5. * @date 09/08/2009
  6. */
  7. #ifndef PPGRAPHCUTINCLUDE
  8. #define PPGRAPHCUTINCLUDE
  9. #include <objrec/nice.h>
  10. #include "objrec/image/GenericImage.h"
  11. #include "objrec/cbaselib/CachedExample.h"
  12. #include "objrec/baselib/Preprocess.h"
  13. #include "objrec/baselib/Globals.h"
  14. #include "objrec/classifier/fpclassifier/randomforest/FPCRandomForests.h"
  15. #include <objrec/cbaselib/VectorFeature.h>
  16. #include "objrec/cbaselib/ClassNames.h"
  17. #include "objrec/segmentation/RSMeanShift.h"
  18. #include "objrec/mrf/mrfmin/GCoptimization.h"
  19. namespace OBJREC {
  20. class PPGraphCut : public Persistent
  21. {
  22. protected:
  23. //! the configfile
  24. const Config *conf;
  25. //! count of classes
  26. int classno;
  27. //! Shape features
  28. Examples shapefeats;
  29. //! classifier for shape features
  30. FPCRandomForests *rf;
  31. double *coocurence;
  32. public:
  33. /** simple constructor */
  34. PPGraphCut();
  35. /** simple constructor */
  36. PPGraphCut(const Config *_conf);
  37. /** simple destructor */
  38. ~PPGraphCut();
  39. /**
  40. * set the count of classes
  41. * @param _classno count of classes
  42. */
  43. void setClassNo(int _classno);
  44. /** initialize the RelativeLocationPrior Variables*/
  45. void Init();
  46. /**
  47. * train region
  48. * @param regions input regions with size and position
  49. * @param mask
  50. */
  51. void trainImage(Examples &regions, NICE::Matrix &mask);
  52. /**
  53. * train region
  54. * @param regions input regions with size and position
  55. */
  56. void trainImage(RegionGraph &regions);
  57. /**
  58. * finish the priors maps
  59. */
  60. void finishPP(ClassNames &cn);
  61. /**
  62. * use shape pp
  63. * @param regions
  64. * @param mask
  65. * @param probabilities probability maps for each pixel
  66. */
  67. void optimizeImage(Examples &regions, NICE::Matrix &mask, GenericImage<double> & probabilities);
  68. /**
  69. * use shape pp
  70. * @param regions
  71. * @param mask
  72. * @param probabilities for each region
  73. */
  74. void optimizeImage(RegionGraph &regions, vector<vector<double> > & probabilities);
  75. /**
  76. * load data from an input stream
  77. * @param is input stream
  78. * @param format
  79. */
  80. void restore (istream & is, int format = 0);
  81. /**
  82. * write data to an output stream
  83. * @param os outputstream
  84. * @param format
  85. */
  86. void store (ostream & os, int format = 0) const;
  87. /**
  88. * clear all informations
  89. */
  90. void clear ();
  91. };
  92. } //namespace
  93. #endif