PPGraphCut.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "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/randomforest/FPCRandomForests.h"
  14. #include <vislearning/cbaselib/VectorFeature.h>
  15. #include "vislearning/cbaselib/ClassNames.h"
  16. #include "objrec/segmentation/RSMeanShift.h"
  17. #include "objrec/mrf/mrfmin/GCoptimization.h"
  18. namespace OBJREC {
  19. class PPGraphCut : public Persistent
  20. {
  21. protected:
  22. //! the configfile
  23. const Config *conf;
  24. //! count of classes
  25. int classno;
  26. //! Shape features
  27. Examples shapefeats;
  28. //! classifier for shape features
  29. FPCRandomForests *rf;
  30. double *coocurence;
  31. public:
  32. /** simple constructor */
  33. PPGraphCut();
  34. /** simple constructor */
  35. PPGraphCut(const Config *_conf);
  36. /** simple destructor */
  37. ~PPGraphCut();
  38. /**
  39. * set the count of classes
  40. * @param _classno count of classes
  41. */
  42. void setClassNo(int _classno);
  43. /** initialize the RelativeLocationPrior Variables*/
  44. void Init();
  45. /**
  46. * train region
  47. * @param regions input regions with size and position
  48. * @param mask
  49. */
  50. void trainImage(Examples &regions, NICE::Matrix &mask);
  51. /**
  52. * train region
  53. * @param regions input regions with size and position
  54. */
  55. void trainImage(RegionGraph &regions);
  56. /**
  57. * finish the priors maps
  58. */
  59. void finishPP(ClassNames &cn);
  60. /**
  61. * use shape pp
  62. * @param regions
  63. * @param mask
  64. * @param probabilities probability maps for each pixel
  65. */
  66. void optimizeImage(Examples &regions, NICE::Matrix &mask, NICE::MultiChannelImageT<double> & probabilities);
  67. /**
  68. * use shape pp
  69. * @param regions
  70. * @param mask
  71. * @param probabilities for each region
  72. */
  73. void optimizeImage(OBJREC::RegionGraph &regions, std::vector<std::vector<double> > & probabilities);
  74. /**
  75. * load data from an input stream
  76. * @param is input stream
  77. * @param format
  78. */
  79. void restore (std::istream & is, int format = 0);
  80. /**
  81. * write data to an output stream
  82. * @param os outputstream
  83. * @param format
  84. */
  85. void store (std::ostream & os, int format = 0) const;
  86. /**
  87. * clear all informations
  88. */
  89. void clear ();
  90. };
  91. } //namespace
  92. #endif