SemanticSegmentation.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * @file SemanticSegmentation.h
  3. * @brief abstract interface for semantic segmentation algorithms
  4. * @author Erik Rodner
  5. * @date 03/19/2009
  6. */
  7. #ifndef SEMANTICSEGMENTATIONINCLUDE
  8. #define SEMANTICSEGMENTATIONINCLUDE
  9. #include "vislearning/cbaselib/MultiDataset.h"
  10. #include "vislearning/cbaselib/LocalizationResult.h"
  11. #include "vislearning/cbaselib/CachedExample.h"
  12. #include "vislearning/cbaselib/Example.h"
  13. #define ROADWORKSADD fthrow(NICE::Exception, "addNewExample(const NICE::Vector & newExample, const int & newClassNo): not yet implemented!");
  14. #define ROADWORKSADDNOVEL fthrow(NICE::Exception, "addNovelExamples(): not yet implemented!");
  15. #define ROADWORKSGETNOVEL fthrow(NICE::Exception, "getNovelExamples(): not yet implemented!");
  16. namespace OBJREC
  17. {
  18. /** abstract interface for semantic segmentation algorithms */
  19. class SemanticSegmentation
  20. {
  21. protected:
  22. /** accessible class names and information about
  23. number of classes etc. */
  24. const ClassNames *classNames;
  25. /** enum type for imagetype */
  26. enum
  27. {
  28. IMAGETYPE_RGB = 0,
  29. IMAGETYPE_GRAY
  30. };
  31. /** whether to load images with color information */
  32. int imagetype;
  33. int iterationCountSuffix;
  34. public:
  35. /** simple constructor
  36. @param conf global settings
  37. @param classNames this ClassNames object while be stored as a attribute
  38. */
  39. SemanticSegmentation ( const NICE::Config *conf,
  40. const ClassNames *classNames );
  41. /** simple destructor */
  42. virtual ~SemanticSegmentation();
  43. /** this function has to be overloaded by all subclasses
  44. @param ce image data
  45. @param segresult result of the semantic segmentation with a label for each
  46. pixel
  47. @param probabilities multi-channel image with one channel for each class and
  48. corresponding probabilities for each pixel
  49. */
  50. virtual void semanticseg ( OBJREC::CachedExample *ce,
  51. NICE::Image & segresult,
  52. NICE::MultiChannelImageT<double> & probabilities ) = 0;
  53. /**
  54. * convert different datatypes
  55. */
  56. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  57. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  58. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  59. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec, const bool & removeOldDataPointer=false );
  60. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  61. /** load img from file call localize(CachedExample *ce) etc. */
  62. void semanticseg ( const std::string & filename,
  63. NICE::Image & segresult,
  64. NICE::MultiChannelImageT<double> & probabilities );
  65. virtual void addNewExample(const NICE::Vector & newExample, const int & newClassNo)
  66. {
  67. ROADWORKSADD;
  68. };
  69. /**
  70. * @brief Add those examples, which belong to the most novel region seen so far
  71. *
  72. * @return void
  73. **/
  74. virtual void addNovelExamples()
  75. {
  76. ROADWORKSADDNOVEL;
  77. };
  78. /**
  79. * @brief Get a pointer to the examples extracted from the most novel region seen so far
  80. *
  81. * @return Examples *
  82. **/
  83. virtual const Examples * getNovelExamples() const
  84. {
  85. ROADWORKSGETNOVEL;
  86. };
  87. void setIterationCountSuffix( const int & _iterationCountSuffix) { iterationCountSuffix = _iterationCountSuffix; };
  88. };
  89. } // namespace
  90. #endif