SemanticSegmentation.h 2.2 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 <objrec/nice.h>
  10. #include "objrec/cbaselib/MultiDataset.h"
  11. #include "objrec/cbaselib/LocalizationResult.h"
  12. #include "objrec/cbaselib/CachedExample.h"
  13. #include "objrec/cbaselib/Example.h"
  14. namespace OBJREC {
  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. IMAGETYPE_RGB = 0,
  25. IMAGETYPE_GRAY
  26. };
  27. /** whether to load images with color information */
  28. int imagetype;
  29. public:
  30. /** simple constructor
  31. @param conf global settings
  32. @param classNames this ClassNames object while be stored as a attribute
  33. */
  34. SemanticSegmentation( const Config *conf,
  35. const ClassNames *classNames );
  36. /** simple destructor */
  37. virtual ~SemanticSegmentation();
  38. /** this function has to be overloaded by all subclasses
  39. @param ce image data
  40. @param segresult result of the semantic segmentation with a label for each
  41. pixel
  42. @param probabilities multi-channel image with one channel for each class and
  43. corresponding probabilities for each pixel
  44. */
  45. virtual void semanticseg ( CachedExample *ce,
  46. NICE::Image & segresult,
  47. GenericImage<double> & probabilities ) = 0;
  48. /**
  49. * convert different datatypes
  50. */
  51. void convertVVectorToExamples(VVector &feats,Examples &examples, vector<int> &label);
  52. void convertExamplesToVVector(VVector &feats,Examples &examples, vector<int> &label);
  53. void convertExamplesToLSet(Examples &examples, LabeledSetVector &lvec);
  54. void convertLSetToExamples(Examples &examples, LabeledSetVector &lvec);
  55. void convertLSetToSparseExamples(Examples &examples, LabeledSetVector &lvec);
  56. /** load img from file call localize(CachedExample *ce) etc. */
  57. void semanticseg ( const std::string & filename,
  58. NICE::Image & segresult,
  59. GenericImage<double> & probabilities);
  60. };
  61. } // namespace
  62. #endif