SemanticSegmentation.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. namespace OBJREC
  14. {
  15. /** abstract interface for semantic segmentation algorithms */
  16. class SemanticSegmentation
  17. {
  18. protected:
  19. /** accessible class names and information about
  20. number of classes etc. */
  21. const ClassNames *classNames;
  22. /** enum type for imagetype */
  23. enum
  24. {
  25. IMAGETYPE_RGB = 0,
  26. IMAGETYPE_GRAY
  27. };
  28. /** whether to load images with color information */
  29. int imagetype;
  30. public:
  31. /** simple constructor
  32. @param conf global settings
  33. @param classNames this ClassNames object while be stored as a attribute
  34. */
  35. SemanticSegmentation ( const NICE::Config *conf,
  36. const ClassNames *classNames );
  37. /** simple destructor */
  38. virtual ~SemanticSegmentation();
  39. /** this function has to be overloaded by all subclasses
  40. @param ce image data
  41. @param segresult result of the semantic segmentation with a label for each
  42. pixel
  43. @param probabilities multi-channel image with one channel for each class and
  44. corresponding probabilities for each pixel
  45. */
  46. virtual void semanticseg ( OBJREC::CachedExample *ce,
  47. NICE::Image & segresult,
  48. NICE::MultiChannelImageT<double> & probabilities ) = 0;
  49. /**
  50. * convert different datatypes
  51. */
  52. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  53. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  54. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  55. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  56. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  57. /** load img from file call localize(CachedExample *ce) etc. */
  58. void semanticseg ( const std::string & filename,
  59. NICE::Image & segresult,
  60. NICE::MultiChannelImageT<double> & probabilities );
  61. };
  62. } // namespace
  63. #endif