PPGraphCut.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. {
  20. class PPGraphCut : public NICE::Persistent
  21. {
  22. protected:
  23. //! the configfile
  24. const NICE::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 NICE::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, NICE::MultiChannelImageT<double> & probabilities );
  68. /**
  69. * use shape pp
  70. * @param regions
  71. * @param mask
  72. * @param probabilities for each region
  73. */
  74. void optimizeImage ( OBJREC::RegionGraph &regions, std::vector<std::vector<double> > & probabilities );
  75. /**
  76. * load data from an input stream
  77. * @param is input stream
  78. * @param format
  79. */
  80. void restore ( std::istream & is, int format = 0 );
  81. /**
  82. * write data to an output stream
  83. * @param os outputstream
  84. * @param format
  85. */
  86. void store ( std::ostream & os, int format = 0 ) const;
  87. /**
  88. * clear all informations
  89. */
  90. void clear ();
  91. };
  92. } //namespace
  93. #endif